Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vertex.hh
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 #ifndef VERTEX_HH
26 #define VERTEX_HH
27 //******************************************************************************
28 #include "math-extension.hh"
29 #include "inline-macro.hh"
30 
31 #include <iostream>
32 //******************************************************************************
47 class CVertex
48 {
49 private:
50  TCoordinate FCoord[3];
51 
52 public:
53  // @name Constructeurs et destructeur
54  // @{
55 
63  CVertex();
64 
76 
85  CVertex(TCoordinate ATab[3]);
86 
95  CVertex(const CVertex& AVertex);
96 
100  ~CVertex();
101 
102  // @}
103  // @name Accesseurs
104  // @{
105 
109  TCoordinate getX() const;
110 
114  TCoordinate getY() const;
115 
119  TCoordinate getZ() const;
120 
126  TCoordinate getCoord(int ADim) const;
127 
133  void setX(TCoordinate ANewX);
134 
140  void setY(TCoordinate ANewY);
141 
147  void setZ(TCoordinate ANewZ);
148 
155  void setCoord(int ADim, TCoordinate ANewCoord);
156 
164  void setXYZ(TCoordinate ANewX, TCoordinate ANewY, TCoordinate ANewZ);
165 
166  // @}
167  // @name Divers opérateurs
168  // @{
169 
170  CVertex& operator=(const CVertex& AVertex);
171 
172  bool operator==(const CVertex& AVertex) const;
173  bool operator!=(const CVertex& AVertex) const;
174 
175  CVertex& operator+=(const CVertex&);
176  CVertex& operator-=(const CVertex&);
177 
180 
183 
184  CVertex operator+(const CVertex&) const;
185  CVertex operator-(const CVertex&) const;
186  CVertex operator+( ) const;
187  CVertex operator-( ) const;
188 
189  // @}
190  // @name Fonctions mathématiques
191  // @{
192 
196  CVertex operator*(const CVertex& AVector) const;
197 
201  TCoordinate dot(const CVertex& AVector) const;
202 
203  // @}
204  // @name Fonctions diverses
205  // @{
206 
210  TCoordinate norm() const;
211 
216 
220  CVertex normalized() const;
221 
225  TCoordinate sqrNorm() const;
226 
231  bool isNull() const;
232 
239  CVertex multiply(const CVertex& AVector) const;
240 
247  CVertex divide(const CVertex& AVector) const;
248 
249  // @}
250 };
251 
252 // @name Produit d'un vecteur par une constante
253 // @{
254 
259 CVertex operator*(TCoordinate ACoef, const CVertex& AVertex);
260 
261 // @}
262 // @name Affichage
263 // @{
264 
270 std::ostream& operator<<(std::ostream& AStream, const CVertex& AVertex);
271 
272 // @}
273 // @name Constantes
274 // @{
275 
279 static const CVertex ORIGIN(0,0,0);
280 
284 static const CVertex OX(1,0,0);
285 
289 static const CVertex OY(0,1,0);
290 
294 static const CVertex OZ(0,0,1);
295 
299 static const CVertex BASE[3] = { OX, OY, OZ };
300 
301 // @}
302 //******************************************************************************
303 #include INCLUDE_INLINE("vertex.icc")
304 //******************************************************************************
305 #endif // VERTEX_HH
306 //******************************************************************************