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
plane.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
INLINE
26
CPlane::CPlane
()
27
: FNormal(0.0, 0.0, 0.0), FNormalNorm(0.0), FD(0.0)
28
{
29
}
30
//******************************************************************************
31
INLINE
32
CPlane::CPlane
(
TCoordinate
Aa,
TCoordinate
Ab,
TCoordinate
Ac,
TCoordinate
Ad)
33
{
34
setPlane
(Aa, Ab, Ac, Ad);
35
}
36
//******************************************************************************
37
INLINE
38
CPlane::CPlane
(
const
CVertex
& APoint1,
39
const
CVertex
& APoint2,
40
const
CVertex
& APoint3)
41
{
42
setPlane
(APoint1, APoint2, APoint3);
43
}
44
//******************************************************************************
45
INLINE
46
CPlane::CPlane
(
const
CVertex
& ANormal,
const
CVertex
& APoint)
47
{
48
setPlane
(ANormal, APoint);
49
}
50
//******************************************************************************
51
INLINE
52
CPlane::~CPlane
()
53
{
54
}
55
//******************************************************************************
56
INLINE
57
void
CPlane::setPlane
(
TCoordinate
Aa,
TCoordinate
Ab,
TCoordinate
Ac,
TCoordinate
Ad)
58
{
59
FNormal.
setXYZ
(Aa, Ab, Ac);
60
FNormalNorm = FNormal.
norm
();
61
FD = Ad;
62
}
63
//******************************************************************************
64
INLINE
65
void
CPlane::setPlane
(
const
CVertex
& APoint1,
66
const
CVertex
& APoint2,
67
const
CVertex
& APoint3)
68
{
69
FNormal = (APoint2 - APoint1) * (APoint3 - APoint1);
70
FNormalNorm = FNormal.
norm
();
71
FD = - (APoint1.
getX
() * FNormal.
getX
() +
72
APoint1.
getY
() * FNormal.
getY
() +
73
APoint1.
getZ
() * FNormal.
getZ
());
74
}
75
//******************************************************************************
76
INLINE
77
void
CPlane::setPlane
(
const
CVertex
& ANormal,
const
CVertex
& APoint)
78
{
79
FNormal = ANormal;
80
FNormalNorm = FNormal.
norm
();
81
FD = - (APoint.
getX
() * FNormal.
getX
() +
82
APoint.
getY
() * FNormal.
getY
() +
83
APoint.
getZ
() * FNormal.
getZ
());
84
}
85
//******************************************************************************
86
INLINE
87
const
CVertex
&
CPlane::getNormal
()
const
88
{
89
return
FNormal;
90
}
91
//******************************************************************************
92
INLINE
93
TCoordinate
CPlane::getNormalNorm
()
const
94
{
95
return
FNormalNorm;
96
}
97
//******************************************************************************
98
INLINE
99
TCoordinate
CPlane::getA
()
const
100
{
101
return
FNormal.
getX
();
102
}
103
//******************************************************************************
104
INLINE
105
TCoordinate
CPlane::getB
()
const
106
{
107
return
FNormal.
getY
();
108
}
109
//******************************************************************************
110
INLINE
111
TCoordinate
CPlane::getC
()
const
112
{
113
return
FNormal.
getZ
();
114
}
115
//******************************************************************************
116
INLINE
117
TCoordinate
CPlane::getD
()
const
118
{
119
return
FD;
120
}
121
//******************************************************************************
122
INLINE
123
void
CPlane::reverseOrientation
()
124
{
125
FNormal = -FNormal;
126
FD = -FD;
127
}
128
//******************************************************************************
129
INLINE
130
bool
CPlane::isPointOnPlane
(
const
CVertex
& APoint)
const
131
{
132
return
isZero
(FNormal.
getX
() * APoint.
getX
() +
133
FNormal.
getY
() * APoint.
getY
() +
134
FNormal.
getZ
() * APoint.
getZ
() +
135
FD);
136
}
137
//******************************************************************************
138
INLINE
139
TCoordinate
CPlane::pointDistance
(
const
CVertex
& APoint)
const
140
{
141
return
(FNormal.
getX
() * APoint.
getX
() +
142
FNormal.
getY
() * APoint.
getY
() +
143
FNormal.
getZ
() * APoint.
getZ
() +
144
FD) / FNormalNorm;
145
}
146
//******************************************************************************
147
INLINE
148
bool
CPlane::getLineIntersection
(
const
CVertex
& APoint,
149
const
CVertex
& ADirection,
150
TCoordinate
* AInterParam)
const
151
{
152
TCoordinate
d = FNormal.
dot
(ADirection);
153
154
if
(d != 0.0) {
155
*AInterParam = - (FNormal.
dot
(APoint) + FD) / d;
156
}
157
else
158
return
false
;
159
160
return
true
;
161
}
162
//******************************************************************************
163
INLINE
164
bool
CPlane::getLineIntersection
(
const
CVertex
& APoint,
165
const
CVertex
& ADirection,
166
CVertex
* AInter)
const
167
{
168
TCoordinate
d = FNormal.
dot
(ADirection);
169
170
if
(d != 0.0) {
171
d = - (FNormal.
dot
(APoint) + FD) / d;
172
*AInter = APoint + ADirection * d;
173
}
174
else
175
return
false
;
176
177
return
true
;
178
}
179
//******************************************************************************
180
INLINE
181
TProjection
CPlane::getBestProjection
()
const
182
{
183
if
(fabs(FNormal.
getZ
()) > fabs(FNormal.
getX
())) {
184
if
(fabs(FNormal.
getZ
()) > fabs(FNormal.
getY
()))
185
return
XY_Proj
;
186
else
187
return
XZ_Proj
;
188
}
189
else
{
190
if
(fabs(FNormal.
getX
()) > fabs(FNormal.
getY
()))
191
return
YZ_Proj
;
192
else
193
return
XZ_Proj
;
194
}
195
}
196
//******************************************************************************
197
INLINE
198
CVertex
CPlane::projectPoint
(
const
CVertex
& APoint)
const
199
{
200
CVertex
pt;
201
if
(
getLineIntersection
(APoint,
getNormal
(), &pt))
202
return
pt;
203
else
204
return
APoint;
205
}
206
//******************************************************************************
207
INLINE
208
CVertex
CPlane::projectPoint
(
const
CVertex
& APoint,
TProjection
AProj)
const
209
{
210
switch
(AProj) {
211
case
XY_Proj
:
212
return
CVertex
(APoint.
getX
(), APoint.
getY
(), 0.0);
213
case
YZ_Proj
:
214
return
CVertex
(APoint.
getY
(), APoint.
getZ
(), 0.0);
215
case
XZ_Proj
:
216
return
CVertex
(APoint.
getX
(), APoint.
getZ
(), 0.0);
217
}
218
219
return
APoint;
220
}
221
//******************************************************************************
222
INLINE
223
CVertex
CPlane::unprojectPoint
(
const
CVertex
& APoint,
TProjection
AProj)
const
224
{
225
switch
(AProj) {
226
case
XY_Proj
:
227
assert(FNormal.
getZ
() != 0.0);
228
return
CVertex
(APoint.
getX
(),
229
APoint.
getY
(),
230
-(APoint.
getX
() * FNormal.
getX
() +
231
APoint.
getY
() * FNormal.
getY
() +
232
FD) / FNormal.
getZ
());
233
case
YZ_Proj
:
234
assert(FNormal.
getX
() != 0.0);
235
return
CVertex
(-(APoint.
getX
() * FNormal.
getY
() +
236
APoint.
getY
() * FNormal.
getZ
() +
237
FD) / FNormal.
getX
(),
238
APoint.
getX
(),
239
APoint.
getY
());
240
case
XZ_Proj
:
241
assert(FNormal.
getY
() != 0.0);
242
return
CVertex
(APoint.
getX
(),
243
-(APoint.
getX
() * FNormal.
getX
() +
244
APoint.
getY
() * FNormal.
getZ
() +
245
FD) / FNormal.
getY
(),
246
APoint.
getY
());
247
}
248
249
return
APoint;
250
}
251
//******************************************************************************
lib-gmapkernel
tools
geometry
plane.icc
Generated on Tue Apr 9 2013 09:51:36 for Moka kernel by
1.8.2