Moka kernel
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
vector.icc
Go to the documentation of this file.
1
/*
2
* lib-gmapkernel : Un noyau de 3-G-cartes et des opérations.
3
* Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4
* http://www.sic.sp2mi.univ-poitiers.fr/
5
* Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6
* guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7
*
8
* This file is part of lib-gmapkernel
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU Lesser General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
19
*
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
//******************************************************************************
25
#include "
transformation-matrix.hh
"
26
27
#include <cassert>
28
//******************************************************************************
29
INLINE
30
CVector::CVector
(
TVectorType
AType)
31
{
32
FElements =
new
TCoordinate
[4];
33
34
if
(AType==
NullVector
)
35
setToNull
();
36
}
37
//******************************************************************************
38
INLINE
39
CVector::CVector
(
const
CVector
& AVector)
40
{
41
FElements =
new
TCoordinate
[4];
42
43
for
(
int
i=0; i<4; ++i)
44
(*
this
)[i] = AVector[i];
45
}
46
//******************************************************************************
47
INLINE
48
CVector::CVector
(
TCoordinate
A0,
TCoordinate
A1,
TCoordinate
A2,
TCoordinate
A3)
49
{
50
FElements =
new
TCoordinate
[4];
51
52
FElements[0] = A0;
53
FElements[1] = A1;
54
FElements[2] = A2;
55
FElements[3] = A3;
56
}
57
//******************************************************************************
58
INLINE
59
CVector::~CVector
()
60
{
61
delete
[] FElements;
62
}
63
//******************************************************************************
64
INLINE
65
void
CVector::setToNull
()
66
{
67
for
(
int
i=0; i<4; ++i)
68
FElements[i] = 0;
69
}
70
//******************************************************************************
71
INLINE
72
CVector
&
CVector::operator=
(
const
CVector
& AVector)
73
{
74
if
(&AVector !=
this
)
75
for
(
int
i=0; i<4; ++i)
76
FElements[i] = AVector.FElements[i];
77
78
return
*
this
;
79
}
80
//******************************************************************************
81
INLINE
82
TCoordinate
&
CVector::operator[]
(
int
AIndex)
const
83
{
84
assert(0 <= AIndex && AIndex <= 3);
85
86
return
FElements[AIndex];
87
}
88
//******************************************************************************
89
INLINE
90
CVector
CVector::operator*
(
const
CTransformationMatrix
& AMatrix)
const
91
{
92
CVector
temp(
NullVector
);
93
94
for
(
int
row=0; row<4; ++row)
95
for
(
int
col=0; col<4; ++col)
96
temp[col] +=
97
(*
this
)[row] * AMatrix[row][col];
98
99
return
temp;
100
}
101
//******************************************************************************
102
INLINE
103
TCoordinate
CVector::operator*
(
const
CVector
& AVector)
const
104
{
105
TCoordinate
temp = 0;
106
107
for
(
int
k=0; k<4; ++k)
108
temp +=
109
(*
this
)[k] * AVector[k];
110
111
return
temp;
112
}
113
//******************************************************************************
114
INLINE
115
std::ostream&
operator<<
(std::ostream& AStream,
const
CVector
& AVector)
116
{
117
AStream << std::endl;
118
119
AStream <<
"["
;
120
121
for
(
int
i=0; i<4; ++i)
122
AStream << AVector[i] <<
"\t"
;
123
// AStream.form("% .3f ", AVector[i]);
124
125
AStream <<
"]"
<< std::endl;
126
127
return
AStream;
128
}
129
//******************************************************************************
lib-gmapkernel
tools
geometry
vector.icc
Generated on Tue Apr 9 2013 09:51:36 for Moka kernel by
1.8.2