Moka kernel
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Moka kernel
Todo List
Namespaces
Classes
Files
File List
lib-gmapkernel
g-map
g-map-generic
g-map-vertex
tools
geometry
geometry.cc
geometry.hh
geometry.icc
math-extension.cc
math-extension.hh
plane.cc
plane.hh
plane.icc
transformation-matrix.cc
transformation-matrix.hh
transformation-matrix.icc
vector.cc
vector.hh
vector.icc
vertex.cc
vertex.hh
vertex.icc
streams
alt-stdint.hh
attributes-id.hh
chrono.hh
inline-macro.hh
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
vertex.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 <cassert>
26
#include <cmath>
27
//******************************************************************************
28
INLINE
29
CVertex::CVertex
()
30
{
31
setXYZ
(0,0,0);
32
}
33
//******************************************************************************
34
INLINE
35
CVertex::CVertex
(
TCoordinate
Ax,
TCoordinate
Ay,
TCoordinate
Az)
36
{
37
setXYZ
(Ax,Ay,Az);
38
}
39
//******************************************************************************
40
INLINE
41
CVertex::CVertex
(
TCoordinate
ATab[3])
42
{
43
setXYZ
(ATab[0],ATab[1],ATab[2]);
44
}
45
//******************************************************************************
46
INLINE
47
CVertex::CVertex
(
const
CVertex
& AVector)
48
{
49
setXYZ
(AVector.
getX
(), AVector.
getY
(), AVector.
getZ
());
50
}
51
//******************************************************************************
52
INLINE
53
TCoordinate
CVertex::getX
()
const
54
{
55
return
FCoord[0];
56
}
57
//******************************************************************************
58
INLINE
59
TCoordinate
CVertex::getY
()
const
60
{
61
return
FCoord[1];
62
}
63
//******************************************************************************
64
INLINE
65
TCoordinate
CVertex::getZ
()
const
66
{
67
return
FCoord[2];
68
}
69
//******************************************************************************
70
INLINE
71
TCoordinate
CVertex::getCoord
(
int
ADim)
const
72
{
73
assert(0<=ADim && ADim<=2);
74
return
FCoord[ADim];
75
}
76
//******************************************************************************
77
INLINE
78
void
CVertex::setX
(
TCoordinate
ANewX)
79
{
80
FCoord[0] = ANewX;
81
}
82
//******************************************************************************
83
INLINE
84
void
CVertex::setY
(
TCoordinate
ANewY)
85
{
86
FCoord[1] = ANewY;
87
}
88
//******************************************************************************
89
INLINE
90
void
CVertex::setZ
(
TCoordinate
ANewZ)
91
{
92
FCoord[2] = ANewZ;
93
}
94
//******************************************************************************
95
INLINE
96
void
CVertex::setCoord
(
int
ADim,
TCoordinate
ANewCoord)
97
{
98
assert(0<=ADim && ADim<=2);
99
FCoord[ADim] = ANewCoord;
100
}
101
//******************************************************************************
102
INLINE
103
void
CVertex::setXYZ
(
TCoordinate
ANewX,
TCoordinate
ANewY,
TCoordinate
ANewZ)
104
{
105
setX
(ANewX);
106
setY
(ANewY);
107
setZ
(ANewZ);
108
}
109
//******************************************************************************
110
INLINE
111
CVertex
&
CVertex::operator=
(
const
CVertex
& AVector)
112
{
113
setXYZ
(AVector.
getX
(), AVector.
getY
(), AVector.
getZ
());
114
return
*
this
;
115
}
116
//******************************************************************************
117
INLINE
118
bool
CVertex::operator==
(
const
CVertex
& AVector)
const
119
{
120
return
121
isZero
(this->
getX
() - AVector.
getX
()) &&
122
isZero
(this->
getY
() - AVector.
getY
()) &&
123
isZero
(this->
getZ
() - AVector.
getZ
());
124
}
125
//******************************************************************************
126
INLINE
127
bool
CVertex::operator!=
(
const
CVertex
& AVector)
const
128
{
129
return
! (*
this
== AVector);
130
}
131
//******************************************************************************
132
INLINE
133
CVertex
&
CVertex::operator+=
(
const
CVertex
& AVector)
134
{
135
*
this
= *
this
+ AVector;
136
return
*
this
;
137
}
138
//******************************************************************************
139
INLINE
140
CVertex
&
CVertex::operator-=
(
const
CVertex
& AVector)
141
{
142
return
*
this
= *
this
- AVector;
143
}
144
//******************************************************************************
145
INLINE
146
CVertex
CVertex::operator*
(
TCoordinate
ACoef)
const
147
{
148
return
CVertex
(
getX
()*ACoef,
getY
()*ACoef,
getZ
()*ACoef);
149
}
150
//******************************************************************************
151
INLINE
152
CVertex
CVertex::operator/
(
TCoordinate
ACoef)
const
153
{
154
assert(!
isZero
(ACoef));
155
return
CVertex
(
getX
()/ACoef,
getY
()/ACoef,
getZ
()/ACoef);
156
}
157
//******************************************************************************
158
INLINE
159
CVertex
&
CVertex::operator*=
(
TCoordinate
ACoef)
160
{
161
return
*
this
= *
this
* ACoef;
162
}
163
//******************************************************************************
164
INLINE
165
CVertex
&
CVertex::operator/=
(
TCoordinate
ACoef)
166
{
167
return
*
this
= *
this
/ ACoef;
168
}
169
//******************************************************************************
170
INLINE
171
CVertex
CVertex::operator+
(
const
CVertex
& AVector)
const
172
{
173
return
CVertex
(
getX
() + AVector.
getX
(),
174
getY
() + AVector.
getY
(),
175
getZ
() + AVector.
getZ
());
176
}
177
//******************************************************************************
178
INLINE
179
CVertex
CVertex::operator-
(
const
CVertex
& AVector)
const
180
{
181
return
CVertex
(
getX
() - AVector.
getX
(),
182
getY
() - AVector.
getY
(),
183
getZ
() - AVector.
getZ
());
184
}
185
//******************************************************************************
186
INLINE
187
CVertex
CVertex::operator+
()
const
188
{
189
return
*
this
;
190
}
191
//******************************************************************************
192
INLINE
193
CVertex
CVertex::operator-
()
const
194
{
195
return
CVertex
(-
getX
(),-
getY
(),-
getZ
());
196
}
197
//******************************************************************************
198
INLINE
199
CVertex
CVertex::operator*
(
const
CVertex
& AVector)
const
200
{
201
return
CVertex
(
getY
()*AVector.
getZ
() - AVector.
getY
()*
getZ
(),
202
getZ
()*AVector.
getX
() - AVector.
getZ
()*
getX
(),
203
getX
()*AVector.
getY
() - AVector.
getX
()*
getY
());
204
}
205
//******************************************************************************
206
INLINE
207
CVertex
CVertex::multiply
(
const
CVertex
& AVector)
const
208
{
209
return
CVertex
(
getX
()*AVector.
getX
(),
210
getY
()*AVector.
getY
(),
211
getZ
()*AVector.
getZ
());
212
}
213
//******************************************************************************
214
INLINE
215
CVertex
CVertex::divide
(
const
CVertex
& AVector)
const
216
{
217
assert(!
isZero
(AVector.
getX
()));
218
assert(!
isZero
(AVector.
getY
()));
219
assert(!
isZero
(AVector.
getZ
()));
220
221
return
CVertex
(
getX
()/AVector.
getX
(),
222
getY
()/AVector.
getY
(),
223
getZ
()/AVector.
getZ
());
224
}
225
//******************************************************************************
226
INLINE
227
TCoordinate
CVertex::dot
(
const
CVertex
& AVector)
const
228
{
229
return
230
getX
()*AVector.
getX
() +
231
getY
()*AVector.
getY
() +
232
getZ
()*AVector.
getZ
();
233
}
234
//******************************************************************************
235
INLINE
236
bool
CVertex::isNull
()
const
237
{
238
return
239
isZero
(
getX
()) &&
240
isZero
(
getY
()) &&
241
isZero
(
getZ
());
242
}
243
//******************************************************************************
244
INLINE
245
TCoordinate
CVertex::norm
()
const
246
{
247
return
sqrt(
sqrNorm
());
248
}
249
//******************************************************************************
250
INLINE
251
TCoordinate
CVertex::normalize
()
252
{
253
TCoordinate
n =
norm
();
254
if
(!
isNull
()) *
this
/= n;
255
return
n;
256
}
257
//******************************************************************************
258
INLINE
259
CVertex
CVertex::normalized
()
const
260
{
261
CVertex
result(*
this
);
262
result.
normalize
();
263
return
result;
264
}
265
//******************************************************************************
266
INLINE
267
TCoordinate
CVertex::sqrNorm
()
const
268
{
269
return
sqr
(
getX
()) +
sqr
(
getY
()) +
sqr
(
getZ
());
270
}
271
//******************************************************************************
272
INLINE
273
CVertex
operator*
(
TCoordinate
ACoef,
const
CVertex
& AVertex)
274
{
275
return
AVertex*ACoef;
276
}
277
//******************************************************************************
278
INLINE
279
std::ostream&
operator<<
(std::ostream& AStream,
const
CVertex
& AVertex)
280
{
281
AStream <<
"("
;
282
AStream <<
"x="
; AStream << AVertex.
getX
() <<
"\t"
;
283
// AStream.form("% .5f", AVertex.getX());
284
AStream <<
","
;
285
AStream <<
"y="
; AStream << AVertex.
getY
() <<
"\t"
;
286
// AStream.form("% .5f", AVertex.getY());
287
AStream <<
","
;
288
AStream <<
"z="
; AStream << AVertex.
getZ
() <<
"\t"
;
289
// AStream.form("% .5f", AVertex.getZ());
290
AStream <<
")"
;
291
292
return
AStream;
293
}
294
//******************************************************************************
lib-gmapkernel
tools
geometry
vertex.icc
Generated on Tue Apr 9 2013 09:51:36 for Moka kernel by
1.8.2