Code_TYMPAN  4.4.0
Industrial site acoustic simulation
3d.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2014> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #ifndef TY_MC_3D
17 #define TY_MC_3D
18 
24 #include <cmath>
25 #include <math.h>
26 #include <vector>
27 #include <ostream>
28 
29 // Defines for intersection calculations.
31 #define INTERS_CONFONDU 2
33 #define INTERS_OUI 1
35 #define INTERS_NULLE 0
36 
37 #define EPSILON_3 0.001 // 10e-3
38 #define EPSILON_5 0.00001 // 10e-5
39 #define EPSILON_6 0.000001 // 10e-6
40 #define EPSILON_7 0.0000001 // 10e-7
41 #define EPSILON_13 0.0000000000001 // 10e-13
42 #define EPSILON_50 1.e-50
43 
44 /* From this threshold (in meters), two elements are considered as at the same
45  * position
46  * */
47 #define TYSEUILCONFONDUS EPSILON_3 // 1 mm
48 
49 #ifndef M_PI
51  #define M_PI 3.1415926535897932384626433832795
52 #endif
53 
55 #define M_2PI 6.283185307179586476925287766559
56 
58 // Macros
60 
67 inline double ABS(double a)
68 {
69  return (a >= 0.0 ? a : -a);
70 }
71 
78 inline double SIGNE(double a)
79 {
80  return (a >= 0.0 ? 1 : -1);
81 }
82 
90 inline double MAX(double a, double b)
91 {
92  return (a > b ? a : b);
93 }
94 
103 inline double MAX3(double a, double b, double c)
104 {
105  return MAX(MAX(a, b), c);
106 }
107 
115 inline double MIN(double a, double b)
116 {
117  return (a < b ? a : b);
118 }
119 
126 inline double DEGTORAD(double a)
127 {
128  return (a / 180.0 * M_PI);
129 }
130 
137 inline double RADTODEG(double a)
138 {
139  return (a / M_PI * 180.0);
140 }
141 
148 inline double GRATORAD(double a)
149 {
150  return (a / 200.0 * M_PI);
151 }
152 
159 inline double RADTOGRA(double a)
160 {
161  return (a / M_PI * 200.0);
162 }
163 
170 inline double GRATODEG(double a)
171 {
172  return (a / 200.0 * 180.0);
173 }
174 
181 inline double DEGTOGRA(double a)
182 {
183  return (a / 180.0 * 200.0);
184 }
185 
192 inline int ROUND(double a)
193 {
194  return (a >= 0.0 ? (int)(a + 0.5) : (int)(a - 0.5));
195 }
196 
205 inline double BORNE(double a, double b, double c)
206 {
207  return (a < b ? b : (a > c ? c : a));
208 }
209 
216 inline int BORNE(int a)
217 {
218  return (int)BORNE((double)a, 0, 255);
219 }
220 
225 class OCoord3D
226 {
227 public:
229  OCoord3D();
231  OCoord3D(const OCoord3D& coord);
233  OCoord3D(double x, double y, double z);
235  virtual ~OCoord3D();
236 
237  OCoord3D& operator=(const OCoord3D& coord);
238  bool operator==(const OCoord3D& coord) const;
239  bool operator!=(const OCoord3D& coord) const;
240 
245  void setCoords(double x, double y, double z);
250  void setCoords(double coords[3]);
255  void getCoords(double coords[3]);
260  double* getCoords();
261 
265  operator const double*() const
266  {
267  return &_value[0];
268  }
272  operator double*()
273  {
274  return &_value[0];
275  }
276 
277 public:
278  union
279  {
280  struct
281  {
282  double _x;
283  double _y;
284  double _z;
285  };
286  double _value[3];
287  };
288 };
289 
290 ::std::ostream& operator<<(::std::ostream& os, const OCoord3D& c);
291 
297 class OVector3D : public OCoord3D
298 {
299 public:
301  OVector3D();
303  OVector3D(const OVector3D& vector);
309  OVector3D(const OCoord3D& coord);
317  OVector3D(const OCoord3D& coordFrom, const OCoord3D& coordTo);
326  OVector3D(double x, double y, double z);
328  virtual ~OVector3D();
329 
334  void reset();
336  OVector3D& operator=(const OVector3D& vector);
337  bool operator==(const OVector3D& vector) const;
338  bool operator!=(const OVector3D& vector) const;
339  OVector3D operator+(const OVector3D& vector) const;
340  OVector3D operator-(const OVector3D& vector) const;
341  // XXX meaningless component wise multiplication whereas a dot product would have been expected.
342  OVector3D operator*(const OVector3D& vector) const;
349  OVector3D operator*(const double a) const;
357  friend OVector3D operator*(const double a, const OVector3D& vector);
358 
362  double dot(const OVector3D& v)
363  {
364  return _x * v._x + _y * v._y + _z * v._z;
365  }
366 
375  OVector3D cross(const OVector3D& vector) const;
376 
385  void balance(double c1, const OVector3D& vector2, double c2);
386 
395  double scalar(const OVector3D& vector) const;
396 
403  double norme() const;
404 
411  OVector3D normal(const OVector3D& vector2, const OVector3D& vector3) const;
412 
417  void normalize();
418 
423  void invert();
424 
431  double angle(const OVector3D& vector) const;
432 
439  OVector3D getRotationOz(double alpha);
440 
447  OVector3D getRotationOzBase2(double alpha);
448 
453  OVector3D getRotationOy(double alpha);
454 
461  OVector3D getRotationOyBase2(double alpha);
462 
469  OVector3D getRotationOzOy(double alpha, double theta);
470 };
472 inline OCoord3D operator+(const OCoord3D& coord, const OVector3D& vect)
473 {
474  return OCoord3D(coord._x + vect._x, coord._y + vect._y, coord._z + vect._z);
475 }
476 
477 ::std::ostream& operator<<(::std::ostream& os, const OVector3D& v);
478 
483 class OPoint3D;
484 typedef std::vector<OPoint3D> TabPoint3D;
485 
486 class OPoint3D : public OCoord3D
487 {
488  // Methods
489 public:
493  OPoint3D();
494 
500  OPoint3D(const OPoint3D& pt);
501 
507  OPoint3D(const OCoord3D& coord);
508 
517  OPoint3D(double x, double y, double z);
518 
525  OPoint3D(double v[]);
526 
530  virtual ~OPoint3D();
531 
539  virtual void set(double x, double y, double z);
540 
548  virtual void setFromOGL(double x, double y, double z);
549  virtual void setFromOGL(float x, float y, float z);
555  virtual void setFromOGL(float coords[3]);
561  virtual void setFromOGL(double coords[3])
562  {
563  setFromOGL(coords[0], coords[1], coords[2]);
564  }
572  virtual void getToOGL(double& x, double& y, double& z);
578  virtual void getToOGL(double coords[3]);
579 
586  double distFrom(const OPoint3D& pt) const;
587 
592  double dist2DFrom(const OPoint3D& pt) const;
593 
595  bool isEqual(const OPoint3D& oPoint) const
596  {
597  return *this == oPoint;
598  }
599 
609  static TabPoint3D checkPointsMaxDistance(const TabPoint3D& points, const double& distanceMax);
610 
614  static TabPoint3D checkPointsMaxDistance(const OPoint3D& point1, const OPoint3D& point2,
615  const double& distanceMax);
616 };
617 
618 ::std::ostream& operator<<(::std::ostream& os, const OPoint3D& v);
619 
624 class OMatrix
625 {
626 public:
628  OMatrix();
630  OMatrix(const OMatrix& matrix);
631  OMatrix(double matrix[4][4]);
633  virtual ~OMatrix();
635  OMatrix& operator=(const OMatrix& matrix);
636  bool operator==(const OMatrix& matrix) const;
637  bool operator!=(const OMatrix& matrix) const;
638  OMatrix operator+(const OMatrix& matrix) const;
639  OMatrix operator-(const OMatrix& matrix) const;
640  OMatrix operator*(const OMatrix& matrix) const;
641 
648  OVector3D multNormal(const OVector3D& normal) const;
649 
654  void show();
655 
665  void reset();
666 
676  void unite();
677 
689  int setTranslation(double x, double y, double z);
690 
702  int setScale(double x, double y, double z);
703 
713  int setRotationOx(double a);
714 
724  int setRotationOy(double a);
725 
735  int setRotationOz(double a);
736 
778  int aligneVecteurSurOx(const OVector3D& vector);
779 
821  int aligneVecteurSurOy(const OVector3D& vector);
822 
839  int invert();
840 
849  OMatrix getInvert(int* ok = 0) const;
850 
875  void adjoint();
876 
884 
892  double determinant();
893 
898  static double mat2x2Det(double a, double b, double c, double d);
899 
904  static double mat3x3Det(double a1, double a2, double a3, double b1, double b2, double b3, double c1,
905  double c2, double c3);
906 
913  OCoord3D dot(const OCoord3D& coord) const;
914 
917  OCoord3D scale(const OCoord3D& coord) const;
918 
919  // Members
920 public:
922  double _m[4][4];
923 };
924 
925 OVector3D operator*(const OMatrix& mat, const OVector3D& vec);
926 OPoint3D operator*(const OMatrix& mat, const OPoint3D& pt);
927 
933 {
934 public:
946  static bool intersDemiSegmentAvecSegment(const OPoint3D& ptS, const OPoint3D& ptA, const OPoint3D& ptB);
947 
961  static int intersDroitesPoints(const OPoint3D& ptA, const OPoint3D& ptB, const OPoint3D& ptC,
962  const OPoint3D& ptD, OPoint3D& ptI);
963 
977  static int intersDroitesPointVecteur(const OPoint3D& ptA, const OVector3D& vecA, const OPoint3D& ptB,
978  const OVector3D& vecB, OPoint3D& ptI);
979 
992  static double symPointDroite(const OPoint3D& ptA, const OPoint3D& ptB, const OPoint3D& ptP,
993  OPoint3D& ptI);
994 
1019  static bool pointInPolygonAngleSum(const OPoint3D& ptP, const OPoint3D* pts, int nbPts);
1020 
1032  static bool pointInPolygonRayCasting(const OPoint3D& ptP, const OPoint3D* pts, int nbPts);
1033 
1058  static bool shortestSegBetween2Lines(const OPoint3D& pt1, const OPoint3D& pt2, const OPoint3D& pt3,
1059  const OPoint3D& pt4, OPoint3D& ptA, OPoint3D& ptB, double* mua,
1060  double* mub);
1061 
1071  static void boundingBox(OPoint3D* pts, int nbPts, OPoint3D& ptMin, OPoint3D& ptMax);
1072 
1081  static void computeNormal(OPoint3D* pts, int nbPts, OVector3D& normal);
1082 };
1083 
1089 {
1090 public:
1092  OSegment3D();
1094  OSegment3D(const OSegment3D& other);
1095  OSegment3D(const OPoint3D& ptA, const OPoint3D& ptB);
1097  virtual ~OSegment3D();
1098 
1099  virtual OSegment3D& operator=(const OSegment3D& other);
1100  virtual bool operator==(const OSegment3D& other) const;
1101  virtual bool operator!=(const OSegment3D& other) const;
1102 
1111  virtual OSegment3D operator*(const OMatrix& matrix) const;
1112 
1117  virtual double longueur() const;
1118 
1128  virtual int symetrieOf(const OPoint3D& pt, OPoint3D& ptSym) const;
1129 
1141  virtual int projection(const OPoint3D& pt, OPoint3D& ptProj, double seuilConfondus) const;
1142 
1156  virtual int intersects(const OSegment3D& seg, OPoint3D& pt, double seuilConfondus) const;
1157 
1164  virtual OPoint3D centreOf() const;
1165 
1172  virtual OPoint3D centerOfCurvedPath(const double& R) const;
1173 
1180  virtual double lengthOfCurvedPath(const double& R);
1181 
1188  virtual OVector3D toVector3D() const
1189  {
1190  return OVector3D(_ptA, _ptB);
1191  }
1192 
1197  virtual OSegment3D swap() const;
1198 
1199 public:
1204 };
1205 
1211 {
1212 public:
1214  ORepere3D();
1216  ORepere3D(const ORepere3D& repere);
1225  ORepere3D(const OPoint3D& origin, const OVector3D& vecI, const OVector3D& vecJ, const OVector3D& vecK);
1230  ORepere3D(const OPoint3D& origin, const OVector3D& vec);
1236  ORepere3D(const OMatrix& matrix);
1238  virtual ~ORepere3D();
1239 
1240  ORepere3D& operator=(const ORepere3D& repere);
1241  bool operator==(const ORepere3D& repere) const;
1242  bool operator!=(const ORepere3D& repere) const;
1243 
1253  void set(const OPoint3D& origin, const OVector3D& vecI, const OVector3D& vecJ, const OVector3D& vecK);
1254 
1261  void set(const OMatrix& matrix);
1262 
1267  void normalize();
1268 
1275  OMatrix asMatrix() const;
1276 
1277 public:
1286 };
1287 
1293 class OBox
1294 {
1295 public:
1297  OBox();
1299  OBox(const OBox& box);
1300  OBox(const OCoord3D& min, const OCoord3D& max);
1301  OBox(double x1, double y1, double z1, double x2, double y2, double z2);
1303  virtual ~OBox() {}
1304 
1305  virtual OBox& operator=(const OBox& box);
1306  virtual bool operator==(const OBox& box) const;
1307  virtual bool operator!=(const OBox& box) const
1308  {
1309  return !operator==(box);
1310  }
1311 
1318  virtual bool isInside(const OPoint3D& pt) const;
1319 
1326  virtual bool isInside2D(const OPoint3D& pt) const;
1327 
1334  virtual bool isInContact(const OBox& box) const;
1335 
1342  virtual void Enlarge(const OPoint3D& pt);
1343 
1352  virtual void Enlarge(float x, float y, float z);
1353 
1360  virtual void Enlarge(const OBox& box);
1361 
1368  virtual void Translate(const OPoint3D& vectorTranslate);
1369 
1370 public:
1373 };
1374 
1379 class OBox2 : public OBox
1380 {
1381  // Methods
1382 public:
1384  OBox2();
1386  OBox2(const OBox2& box);
1392  OBox2(const OBox& box);
1397  OBox2(const double& length, const double& width, const double& height);
1398 
1399 private: // Set private for security seems to an "af hoc" adaptation and is used only by an internal member
1400  // function
1408  OBox2(const OBox2& box, const ORepere3D& repere, const OPoint3D& centre);
1409 
1410 public:
1412  virtual ~OBox2() {}
1413 
1414  virtual OBox2& operator=(const OBox2& box);
1415  virtual bool operator==(const OBox2& box) const;
1416  virtual bool operator!=(const OBox2& box) const
1417  {
1418  return !operator==(box);
1419  }
1420 
1430  OPoint3D BoxCoord(int N) const;
1436  virtual bool isInside(const OPoint3D& pt) const;
1442  virtual bool isInside2D(const OPoint3D& pt) const;
1447  virtual void Translate(const OVector3D& vect);
1451  OBox2 boxRotation(const OPoint3D& O, const OPoint3D& P2);
1458  void BoxRotationOzOy(double alpha, double theta);
1463  void moveAndRotate(const OPoint3D& origin, const OVector3D& vec);
1464 
1465 private:
1470  OBox2 rotInXOYOnly(const OVector3D& v1, const OVector3D& v2, const OPoint3D& O, const OPoint3D& P2);
1475  OBox2 rotInXOZOnly(const OVector3D& v1, const OVector3D& v2, const OPoint3D& O, const OPoint3D& P2);
1480  OBox2 rot3D(const OVector3D& v1, const OVector3D& v2, const OPoint3D& O, const OPoint3D& P2);
1481 
1482 public:
1493  double _length;
1494  double _height;
1495  double _width;
1496 };
1497 
1514 {
1515 public:
1517  OHPlane3D();
1519  OHPlane3D(const OHPlane3D& Plane);
1526  OHPlane3D(const OVector3D& normal, const OPoint3D& origin);
1528  virtual ~OHPlane3D();
1529 
1536  void set(const OVector3D& normal, const OPoint3D& origin);
1537 
1538  OHPlane3D& operator=(const OHPlane3D& Plane);
1539  bool operator==(const OHPlane3D& Plane) const;
1540  bool operator!=(const OHPlane3D& Plane) const;
1541 
1560  int intersects(const OPoint3D& pt1, const OPoint3D& pt2, OPoint3D& ptIntersec, double& t) const;
1577  int intersects(const OSegment3D& seg, OPoint3D& ptIntersec) const;
1578 
1579 private:
1582  double _p;
1583 };
1584 
1585 #endif // TY_MC_3D
double RADTODEG(double a)
Converts an angle from radians to degrees.
Definition: 3d.h:137
double MAX3(double a, double b, double c)
Return the biggest number of three ones.
Definition: 3d.h:103
double MIN(double a, double b)
Return the smallest number of two ones.
Definition: 3d.h:115
double BORNE(double a, double b, double c)
Limit a number.
Definition: 3d.h:205
double GRATORAD(double a)
Converts an angle from gradians to radians.
Definition: 3d.h:148
::std::ostream & operator<<(::std::ostream &os, const OCoord3D &c)
Definition: 3d.cpp:106
OCoord3D operator+(const OCoord3D &coord, const OVector3D &vect)
Return a OCoord3D from an operator+ between a OCoord3D and a OVector3D.
Definition: 3d.h:472
double GRATODEG(double a)
Converts an angle from gradians to degrees.
Definition: 3d.h:170
OVector3D operator*(const OMatrix &mat, const OVector3D &vec)
Definition: 3d.cpp:568
double DEGTORAD(double a)
Converts an angle from degrees to radians.
Definition: 3d.h:126
double DEGTOGRA(double a)
Converts an angle from degrees to gradians.
Definition: 3d.h:181
int ROUND(double a)
Compute the rounded value of a number.
Definition: 3d.h:192
double RADTOGRA(double a)
Converts an angle from radians to gradians.
Definition: 3d.h:159
#define M_PI
Pi.
Definition: 3d.h:51
double SIGNE(double a)
Return the number sign.
Definition: 3d.h:78
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
double MAX(double a, double b)
Return the biggest number of two ones.
Definition: 3d.h:90
std::vector< OPoint3D > TabPoint3D
Definition: 3d.h:483
NxReal c
Definition: NxVec3.cpp:317
#define min(a, b)
Class to define a box (not necessary parallel to the axis as OBox)
Definition: 3d.h:1380
virtual bool operator==(const OBox2 &box) const
Definition: 3d.cpp:1791
OPoint3D _H
Definition: 3d.h:1492
ORepere3D _repere
Definition: 3d.h:1483
double _width
Definition: 3d.h:1495
OPoint3D _D
Definition: 3d.h:1488
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
Definition: 3d.cpp:1887
OBox2 rotInXOZOnly(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
Definition: 3d.cpp:2028
OPoint3D _E
Definition: 3d.h:1489
double _length
Definition: 3d.h:1493
virtual ~OBox2()
Destructor.
Definition: 3d.h:1412
OBox2()
Default constructor.
Definition: 3d.cpp:1700
OPoint3D _center
Definition: 3d.h:1484
virtual bool isInside2D(const OPoint3D &pt) const
Test whether the point is inside the box or not (from upper point of view).
Definition: 3d.cpp:1900
OPoint3D BoxCoord(int N) const
Returns the coordinates of one of the box corner. \ We consider that the first corner is the one on t...
Definition: 3d.cpp:1859
double _height
Definition: 3d.h:1494
virtual bool operator!=(const OBox2 &box) const
Definition: 3d.h:1416
OPoint3D _C
Definition: 3d.h:1487
OBox2 boxRotation(const OPoint3D &O, const OPoint3D &P2)
Definition: 3d.cpp:1927
OPoint3D _G
Definition: 3d.h:1491
OPoint3D _F
Definition: 3d.h:1490
OBox2 rot3D(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
Definition: 3d.cpp:2050
virtual OBox2 & operator=(const OBox2 &box)
Definition: 3d.cpp:1769
virtual void Translate(const OVector3D &vect)
Translate this box.
Definition: 3d.cpp:1914
void moveAndRotate(const OPoint3D &origin, const OVector3D &vec)
Move and rotate the box.
Definition: 3d.cpp:2090
OBox2 rotInXOYOnly(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
Definition: 3d.cpp:2009
OPoint3D _B
Definition: 3d.h:1486
void BoxRotationOzOy(double alpha, double theta)
Computes the box rotation around Oz and Oy (usual coordinates system).
Definition: 3d.cpp:1976
OPoint3D _A
Definition: 3d.h:1485
The box class.
Definition: 3d.h:1294
virtual bool isInContact(const OBox &box) const
Test whether the boxes are in contact or not.
Definition: 3d.cpp:1585
virtual bool isInside2D(const OPoint3D &pt) const
Test whether the point is inside the box or not (from upper point of view).
Definition: 3d.cpp:1564
virtual ~OBox()
Destructor.
Definition: 3d.h:1303
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
Definition: 3d.cpp:1535
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1614
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1371
virtual bool operator==(const OBox &box) const
Definition: 3d.cpp:1519
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1372
virtual bool operator!=(const OBox &box) const
Definition: 3d.h:1307
virtual void Translate(const OPoint3D &vectorTranslate)
Translate this box.
Definition: 3d.cpp:1688
OBox()
Default constructor.
Definition: 3d.cpp:1486
virtual OBox & operator=(const OBox &box)
Definition: 3d.cpp:1509
The 3D coordinate class.
Definition: 3d.h:226
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
OCoord3D & operator=(const OCoord3D &coord)
operator=
Definition: 3d.cpp:40
OCoord3D()
Default constructor.
Definition: 3d.cpp:29
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
bool operator==(const OCoord3D &coord) const
operator==
Definition: 3d.cpp:51
void setCoords(double x, double y, double z)
Sets the coordinates as an array of double.
Definition: 3d.cpp:76
bool operator!=(const OCoord3D &coord) const
operator!=
Definition: 3d.cpp:71
double _value[3]
Definition: 3d.h:286
double * getCoords()
Gets the coordinates as an array of double.
Definition: 3d.cpp:97
virtual ~OCoord3D()
Destructor.
Definition: 3d.cpp:38
Class Geometry utilities.
Definition: 3d.h:933
static void boundingBox(OPoint3D *pts, int nbPts, OPoint3D &ptMin, OPoint3D &ptMax)
Computes the simple bounding box for a volume using min-max method.
Definition: 3d.cpp:1109
static bool intersDemiSegmentAvecSegment(const OPoint3D &ptS, const OPoint3D &ptA, const OPoint3D &ptB)
Return true if the horizontal from the ptS point intersects the segment defined by ptA and ptB.
Definition: 3d.cpp:915
static void computeNormal(OPoint3D *pts, int nbPts, OVector3D &normal)
Computes the normal of the list of points.
Definition: 3d.cpp:1147
static bool shortestSegBetween2Lines(const OPoint3D &pt1, const OPoint3D &pt2, const OPoint3D &pt3, const OPoint3D &pt4, OPoint3D &ptA, OPoint3D &ptB, double *mua, double *mub)
Calculates the line segment PaPb that is the shortest route between two lines P1P2 and P3P4.
Definition: 3d.cpp:1063
static double symPointDroite(const OPoint3D &ptA, const OPoint3D &ptB, const OPoint3D &ptP, OPoint3D &ptI)
Calculate the symmetrical of a point with respect to a line (defined by two points).
Definition: 3d.cpp:987
static bool pointInPolygonAngleSum(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using angle sum algorithm.
Definition: 3d.cpp:1016
static bool pointInPolygonRayCasting(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using ray casting algorithm.
Definition: 3d.cpp:1046
static int intersDroitesPointVecteur(const OPoint3D &ptA, const OVector3D &vecA, const OPoint3D &ptB, const OVector3D &vecB, OPoint3D &ptI)
Calculate the intersection between two lines each defined by a point and a vector.
Definition: 3d.cpp:977
static int intersDroitesPoints(const OPoint3D &ptA, const OPoint3D &ptB, const OPoint3D &ptC, const OPoint3D &ptD, OPoint3D &ptI)
Calculate the intersection between two lines each defined by two points.
Definition: 3d.cpp:938
The 3D Plane class using Hessian normal form.
Definition: 3d.h:1514
bool operator!=(const OHPlane3D &Plane) const
Definition: 3d.cpp:2148
bool operator==(const OHPlane3D &Plane) const
Definition: 3d.cpp:2140
double _p
Definition: 3d.h:1582
int intersects(const OPoint3D &pt1, const OPoint3D &pt2, OPoint3D &ptIntersec, double &t) const
Calculate the intersection with a segment defined by two points.
Definition: 3d.cpp:2167
OHPlane3D & operator=(const OHPlane3D &Plane)
Definition: 3d.cpp:2132
virtual ~OHPlane3D()
Destructor.
Definition: 3d.cpp:2123
void set(const OVector3D &normal, const OPoint3D &origin)
set a new Plane.
Definition: 3d.cpp:2125
OVector3D _N
Definition: 3d.h:1580
OHPlane3D()
Default constructor.
Definition: 3d.cpp:2107
OPoint3D _O
Definition: 3d.h:1581
The 4x4 matrix class.
Definition: 3d.h:625
virtual ~OMatrix()
Destructor.
Definition: 3d.cpp:461
OCoord3D scale(const OCoord3D &coord) const
Definition: 3d.cpp:554
static double mat3x3Det(double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
Compute a 3 x 3 matrix determinant.
Definition: 3d.cpp:906
int setRotationOz(double a)
Update a rotation matrix (Oz axis).
Definition: 3d.cpp:688
int setRotationOy(double a)
Update a rotation matrix (Oy axis).
Definition: 3d.cpp:676
int invert()
Matrix inversion.
Definition: 3d.cpp:792
void reset()
Set the matrix elements to zero.
Definition: 3d.cpp:622
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
Definition: 3d.cpp:813
static double mat2x2Det(double a, double b, double c, double d)
Compute a 2 x 2 matrix determinant.
Definition: 3d.cpp:901
void unite()
Initialize the matrix to the identity matrix.
Definition: 3d.cpp:634
OMatrix operator*(const OMatrix &matrix) const
Definition: 3d.cpp:527
OVector3D multNormal(const OVector3D &normal) const
Multiplication with a normal (the translation is removed).
Definition: 3d.cpp:585
int aligneVecteurSurOx(const OVector3D &vector)
Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des x.
Definition: 3d.cpp:700
OMatrix & operator=(const OMatrix &matrix)
operators
Definition: 3d.cpp:463
OMatrix operator-(const OMatrix &matrix) const
Definition: 3d.cpp:514
OMatrix()
Default constructor.
Definition: 3d.cpp:439
int setRotationOx(double a)
Update a rotation matrix (Ox axis).
Definition: 3d.cpp:664
bool operator==(const OMatrix &matrix) const
Definition: 3d.cpp:478
OMatrix operator+(const OMatrix &matrix) const
Definition: 3d.cpp:501
void adjoint()
Calculate the adjoint matrix from this matrix.
Definition: 3d.cpp:824
bool operator!=(const OMatrix &matrix) const
Definition: 3d.cpp:496
void show()
Print a matrix (debug).
Definition: 3d.cpp:609
int setTranslation(double x, double y, double z)
Update a translation matrix.
Definition: 3d.cpp:646
OMatrix getAdjoint()
Return the adjoint matrix.
Definition: 3d.cpp:865
double determinant()
Compute the matrix determinant.
Definition: 3d.cpp:873
int aligneVecteurSurOy(const OVector3D &vector)
Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des y.
Definition: 3d.cpp:743
OCoord3D dot(const OCoord3D &coord) const
Multiplication with a 3D coordinate.
Definition: 3d.cpp:545
int setScale(double x, double y, double z)
Update a zoom matrix.
Definition: 3d.cpp:655
double _m[4][4]
The 4x4 matrix array.
Definition: 3d.h:922
The 3D point class.
Definition: 3d.h:487
virtual ~OPoint3D()
Destructor.
Definition: 3d.cpp:338
virtual void set(double x, double y, double z)
Definition: 3d.cpp:381
double dist2DFrom(const OPoint3D &pt) const
Computes the distance from this point to another in 2D plan.
Definition: 3d.cpp:376
double distFrom(const OPoint3D &pt) const
Computes the distance from this point to another.
Definition: 3d.cpp:371
OPoint3D()
Default constructor.
Definition: 3d.cpp:328
virtual void getToOGL(double &x, double &y, double &z)
Definition: 3d.cpp:359
bool isEqual(const OPoint3D &oPoint) const
Compatibility alias for operator==.
Definition: 3d.h:595
virtual void setFromOGL(double x, double y, double z)
Definition: 3d.cpp:340
virtual void setFromOGL(double coords[3])
Definition: 3d.h:561
static TabPoint3D checkPointsMaxDistance(const TabPoint3D &points, const double &distanceMax)
Definition: 3d.cpp:386
3D frame with a point and 3 vectors.
Definition: 3d.h:1211
void normalize()
Normalize each vectors composing this frame.
Definition: 3d.cpp:1455
OVector3D _vecK
Vector K for the Z axis.
Definition: 3d.h:1285
bool operator==(const ORepere3D &repere) const
operator==
Definition: 3d.cpp:1398
OVector3D _vecJ
Vector J for the Y axis.
Definition: 3d.h:1283
ORepere3D & operator=(const ORepere3D &repere)
operator=
Definition: 3d.cpp:1386
void set(const OPoint3D &origin, const OVector3D &vecI, const OVector3D &vecJ, const OVector3D &vecK)
Sets with a point and 3 vectors.
Definition: 3d.cpp:1427
OVector3D _vecI
Vector I for the X axis.
Definition: 3d.h:1281
OPoint3D _origin
The origin point.
Definition: 3d.h:1279
ORepere3D()
Default constructor.
Definition: 3d.cpp:1347
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
Definition: 3d.cpp:1462
bool operator!=(const ORepere3D &repere) const
operator!=
Definition: 3d.cpp:1422
virtual ~ORepere3D()
Destructor.
Definition: 3d.cpp:1384
Class to define a segment.
Definition: 3d.h:1089
virtual double longueur() const
Return the segment length.
Definition: 3d.cpp:1238
virtual OPoint3D centreOf() const
Return the position of the segment middle.
Definition: 3d.cpp:1294
virtual ~OSegment3D()
Destructor.
Definition: 3d.cpp:1200
virtual OPoint3D centerOfCurvedPath(const double &R) const
Return the position of the arc circle center of radius R passing by the segment extremities.
Definition: 3d.cpp:1303
OSegment3D()
Default constructor.
Definition: 3d.cpp:1179
virtual int symetrieOf(const OPoint3D &pt, OPoint3D &ptSym) const
Return the symmetrical of a point.
Definition: 3d.cpp:1243
virtual double lengthOfCurvedPath(const double &R)
Calculate the path length of radius R passing by the segment extremities.
Definition: 3d.cpp:1327
OPoint3D _ptA
Point A of the segment.
Definition: 3d.h:1201
virtual OVector3D toVector3D() const
Build a OVector3D from a segment used for the direction of the sources.
Definition: 3d.h:1188
virtual bool operator!=(const OSegment3D &other) const
operator!=
Definition: 3d.cpp:1228
virtual int projection(const OPoint3D &pt, OPoint3D &ptProj, double seuilConfondus) const
Return the projection of a point.
Definition: 3d.cpp:1258
virtual int intersects(const OSegment3D &seg, OPoint3D &pt, double seuilConfondus) const
Return the intersection point with another segment.
Definition: 3d.cpp:1267
virtual OSegment3D swap() const
Return the segment.
Definition: 3d.cpp:1336
virtual OSegment3D operator*(const OMatrix &matrix) const
Multiplication with a matrix.
Definition: 3d.cpp:1233
virtual bool operator==(const OSegment3D &other) const
operator==
Definition: 3d.cpp:1212
virtual OSegment3D & operator=(const OSegment3D &other)
operator=
Definition: 3d.cpp:1202
OPoint3D _ptB
Point B of the segment.
Definition: 3d.h:1203
The 3D vector class.
Definition: 3d.h:298
OVector3D operator*(const OVector3D &vector) const
Definition: 3d.cpp:171
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:215
OVector3D getRotationOzBase2(double alpha)
Returns the vector after a rotation around z axis \ and gives back the coordinates of xprime or yprim...
Definition: 3d.cpp:280
void invert()
Inverts this vector.
Definition: 3d.cpp:236
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
Definition: 3d.cpp:220
void balance(double c1, const OVector3D &vector2, double c2)
Balances this vector.
Definition: 3d.cpp:205
virtual ~OVector3D()
Destructor.
Definition: 3d.cpp:128
OVector3D operator-(const OVector3D &vector) const
Definition: 3d.cpp:162
OVector3D getRotationOzOy(double alpha, double theta)
Returns the vector after 2 rotations around z axis and y axis. It gives the coordinates of xsecond,...
Definition: 3d.cpp:306
bool operator!=(const OVector3D &vector) const
Definition: 3d.cpp:148
bool operator==(const OVector3D &vector) const
Definition: 3d.cpp:143
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
double scalar(const OVector3D &vector) const
Performs the scalar product between this object and another vector.
Definition: 3d.cpp:210
OVector3D cross(const OVector3D &vector) const
Cross product.
Definition: 3d.cpp:196
double angle(const OVector3D &vector) const
Computes the angle between this vector and another vector.
Definition: 3d.cpp:243
OVector3D()
Default constructor.
Definition: 3d.cpp:113
OVector3D operator+(const OVector3D &vector) const
Definition: 3d.cpp:153
OVector3D getRotationOz(double alpha)
Returns the vector after a rotation around z axis \ x -> xprime. Both of these vectors will be given ...
Definition: 3d.cpp:254
OVector3D & operator=(const OVector3D &vector)
operators
Definition: 3d.cpp:137
OVector3D getRotationOyBase2(double alpha)
Returns the vector after a rotation around y axis \ and gives back the coordinates of xprime or zprim...
Definition: 3d.cpp:293
OVector3D getRotationOy(double alpha)
Returns the vector after a rotation around z axis.
Definition: 3d.cpp:267
double dot(const OVector3D &v)
dot product (assuming an orthonormal reference frame)
Definition: 3d.h:362
void reset()
Reset this vector.
Definition: 3d.cpp:130