31 #define INTERS_CONFONDU 2
35 #define INTERS_NULLE 0
37 #define EPSILON_3 0.001
38 #define EPSILON_5 0.00001
39 #define EPSILON_6 0.000001
40 #define EPSILON_7 0.0000001
41 #define EPSILON_13 0.0000000000001
42 #define EPSILON_50 1.e-50
47 #define TYSEUILCONFONDUS EPSILON_3
51 #define M_PI 3.1415926535897932384626433832795
55 #define M_2PI 6.283185307179586476925287766559
67 inline double ABS(
double a)
69 return (a >= 0.0 ? a : -a);
80 return (a >= 0.0 ? 1 : -1);
90 inline double MAX(
double a,
double b)
92 return (a > b ? a : b);
103 inline double MAX3(
double a,
double b,
double c)
115 inline double MIN(
double a,
double b)
117 return (a < b ? a : b);
128 return (a / 180.0 *
M_PI);
139 return (a /
M_PI * 180.0);
150 return (a / 200.0 *
M_PI);
161 return (a /
M_PI * 200.0);
172 return (a / 200.0 * 180.0);
183 return (a / 180.0 * 200.0);
194 return (a >= 0.0 ? (
int)(a + 0.5) : (
int)(a - 0.5));
205 inline double BORNE(
double a,
double b,
double c)
207 return (a < b ? b : (a >
c ?
c : a));
218 return (
int)
BORNE((
double)a, 0, 255);
233 OCoord3D(
double x,
double y,
double z);
245 void setCoords(
double x,
double y,
double z);
265 operator const double*()
const
403 double norme()
const;
517 OPoint3D(
double x,
double y,
double z);
539 virtual void set(
double x,
double y,
double z);
548 virtual void setFromOGL(
double x,
double y,
double z);
549 virtual void setFromOGL(
float x,
float y,
float z);
572 virtual void getToOGL(
double& x,
double& y,
double& z);
578 virtual void getToOGL(
double coords[3]);
597 return *
this == oPoint;
615 const double& distanceMax);
702 int setScale(
double x,
double y,
double z);
898 static double mat2x2Det(
double a,
double b,
double c,
double d);
904 static double mat3x3Det(
double a1,
double a2,
double a3,
double b1,
double b2,
double b3,
double c1,
905 double c2,
double c3);
1301 OBox(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2);
1352 virtual void Enlarge(
float x,
float y,
float z);
1397 OBox2(
const double& length,
const double& width,
const double& height);
double RADTODEG(double a)
Converts an angle from radians to degrees.
double MAX3(double a, double b, double c)
Return the biggest number of three ones.
double MIN(double a, double b)
Return the smallest number of two ones.
double BORNE(double a, double b, double c)
Limit a number.
double GRATORAD(double a)
Converts an angle from gradians to radians.
::std::ostream & operator<<(::std::ostream &os, const OCoord3D &c)
OCoord3D operator+(const OCoord3D &coord, const OVector3D &vect)
Return a OCoord3D from an operator+ between a OCoord3D and a OVector3D.
double GRATODEG(double a)
Converts an angle from gradians to degrees.
OVector3D operator*(const OMatrix &mat, const OVector3D &vec)
double DEGTORAD(double a)
Converts an angle from degrees to radians.
double DEGTOGRA(double a)
Converts an angle from degrees to gradians.
int ROUND(double a)
Compute the rounded value of a number.
double RADTOGRA(double a)
Converts an angle from radians to gradians.
double SIGNE(double a)
Return the number sign.
double ABS(double a)
Return the absolute value.
double MAX(double a, double b)
Return the biggest number of two ones.
std::vector< OPoint3D > TabPoint3D
Class to define a box (not necessary parallel to the axis as OBox)
virtual bool operator==(const OBox2 &box) const
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
OBox2 rotInXOZOnly(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
virtual ~OBox2()
Destructor.
OBox2()
Default constructor.
virtual bool isInside2D(const OPoint3D &pt) const
Test whether the point is inside the box or not (from upper point of view).
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...
virtual bool operator!=(const OBox2 &box) const
OBox2 boxRotation(const OPoint3D &O, const OPoint3D &P2)
OBox2 rot3D(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
virtual OBox2 & operator=(const OBox2 &box)
virtual void Translate(const OVector3D &vect)
Translate this box.
void moveAndRotate(const OPoint3D &origin, const OVector3D &vec)
Move and rotate the box.
OBox2 rotInXOYOnly(const OVector3D &v1, const OVector3D &v2, const OPoint3D &O, const OPoint3D &P2)
void BoxRotationOzOy(double alpha, double theta)
Computes the box rotation around Oz and Oy (usual coordinates system).
virtual bool isInContact(const OBox &box) const
Test whether the boxes are in contact or not.
virtual bool isInside2D(const OPoint3D &pt) const
Test whether the point is inside the box or not (from upper point of view).
virtual ~OBox()
Destructor.
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
OPoint3D _min
Minimal coordinates of the OBox.
virtual bool operator==(const OBox &box) const
OPoint3D _max
Maximal coordinates of the OBox.
virtual bool operator!=(const OBox &box) const
virtual void Translate(const OPoint3D &vectorTranslate)
Translate this box.
OBox()
Default constructor.
virtual OBox & operator=(const OBox &box)
double _y
y coordinate of OCoord3D
OCoord3D & operator=(const OCoord3D &coord)
operator=
OCoord3D()
Default constructor.
double _z
z coordinate of OCoord3D
double _x
x coordinate of OCoord3D
bool operator==(const OCoord3D &coord) const
operator==
void setCoords(double x, double y, double z)
Sets the coordinates as an array of double.
bool operator!=(const OCoord3D &coord) const
operator!=
double * getCoords()
Gets the coordinates as an array of double.
virtual ~OCoord3D()
Destructor.
Class Geometry utilities.
static void boundingBox(OPoint3D *pts, int nbPts, OPoint3D &ptMin, OPoint3D &ptMax)
Computes the simple bounding box for a volume using min-max method.
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.
static void computeNormal(OPoint3D *pts, int nbPts, OVector3D &normal)
Computes the normal of the list of points.
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.
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).
static bool pointInPolygonAngleSum(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using angle sum algorithm.
static bool pointInPolygonRayCasting(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using ray casting algorithm.
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.
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.
The 3D Plane class using Hessian normal form.
bool operator!=(const OHPlane3D &Plane) const
bool operator==(const OHPlane3D &Plane) const
int intersects(const OPoint3D &pt1, const OPoint3D &pt2, OPoint3D &ptIntersec, double &t) const
Calculate the intersection with a segment defined by two points.
OHPlane3D & operator=(const OHPlane3D &Plane)
virtual ~OHPlane3D()
Destructor.
void set(const OVector3D &normal, const OPoint3D &origin)
set a new Plane.
OHPlane3D()
Default constructor.
virtual ~OMatrix()
Destructor.
OCoord3D scale(const OCoord3D &coord) const
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.
int setRotationOz(double a)
Update a rotation matrix (Oz axis).
int setRotationOy(double a)
Update a rotation matrix (Oy axis).
int invert()
Matrix inversion.
void reset()
Set the matrix elements to zero.
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
static double mat2x2Det(double a, double b, double c, double d)
Compute a 2 x 2 matrix determinant.
void unite()
Initialize the matrix to the identity matrix.
OMatrix operator*(const OMatrix &matrix) const
OVector3D multNormal(const OVector3D &normal) const
Multiplication with a normal (the translation is removed).
int aligneVecteurSurOx(const OVector3D &vector)
Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des x.
OMatrix & operator=(const OMatrix &matrix)
operators
OMatrix operator-(const OMatrix &matrix) const
OMatrix()
Default constructor.
int setRotationOx(double a)
Update a rotation matrix (Ox axis).
bool operator==(const OMatrix &matrix) const
OMatrix operator+(const OMatrix &matrix) const
void adjoint()
Calculate the adjoint matrix from this matrix.
bool operator!=(const OMatrix &matrix) const
void show()
Print a matrix (debug).
int setTranslation(double x, double y, double z)
Update a translation matrix.
OMatrix getAdjoint()
Return the adjoint matrix.
double determinant()
Compute the matrix determinant.
int aligneVecteurSurOy(const OVector3D &vector)
Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des y.
OCoord3D dot(const OCoord3D &coord) const
Multiplication with a 3D coordinate.
int setScale(double x, double y, double z)
Update a zoom matrix.
double _m[4][4]
The 4x4 matrix array.
virtual ~OPoint3D()
Destructor.
virtual void set(double x, double y, double z)
double dist2DFrom(const OPoint3D &pt) const
Computes the distance from this point to another in 2D plan.
double distFrom(const OPoint3D &pt) const
Computes the distance from this point to another.
OPoint3D()
Default constructor.
virtual void getToOGL(double &x, double &y, double &z)
bool isEqual(const OPoint3D &oPoint) const
Compatibility alias for operator==.
virtual void setFromOGL(double x, double y, double z)
virtual void setFromOGL(double coords[3])
static TabPoint3D checkPointsMaxDistance(const TabPoint3D &points, const double &distanceMax)
3D frame with a point and 3 vectors.
void normalize()
Normalize each vectors composing this frame.
OVector3D _vecK
Vector K for the Z axis.
bool operator==(const ORepere3D &repere) const
operator==
OVector3D _vecJ
Vector J for the Y axis.
ORepere3D & operator=(const ORepere3D &repere)
operator=
void set(const OPoint3D &origin, const OVector3D &vecI, const OVector3D &vecJ, const OVector3D &vecK)
Sets with a point and 3 vectors.
OVector3D _vecI
Vector I for the X axis.
OPoint3D _origin
The origin point.
ORepere3D()
Default constructor.
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
bool operator!=(const ORepere3D &repere) const
operator!=
virtual ~ORepere3D()
Destructor.
Class to define a segment.
virtual double longueur() const
Return the segment length.
virtual OPoint3D centreOf() const
Return the position of the segment middle.
virtual ~OSegment3D()
Destructor.
virtual OPoint3D centerOfCurvedPath(const double &R) const
Return the position of the arc circle center of radius R passing by the segment extremities.
OSegment3D()
Default constructor.
virtual int symetrieOf(const OPoint3D &pt, OPoint3D &ptSym) const
Return the symmetrical of a point.
virtual double lengthOfCurvedPath(const double &R)
Calculate the path length of radius R passing by the segment extremities.
OPoint3D _ptA
Point A of the segment.
virtual OVector3D toVector3D() const
Build a OVector3D from a segment used for the direction of the sources.
virtual bool operator!=(const OSegment3D &other) const
operator!=
virtual int projection(const OPoint3D &pt, OPoint3D &ptProj, double seuilConfondus) const
Return the projection of a point.
virtual int intersects(const OSegment3D &seg, OPoint3D &pt, double seuilConfondus) const
Return the intersection point with another segment.
virtual OSegment3D swap() const
Return the segment.
virtual OSegment3D operator*(const OMatrix &matrix) const
Multiplication with a matrix.
virtual bool operator==(const OSegment3D &other) const
operator==
virtual OSegment3D & operator=(const OSegment3D &other)
operator=
OPoint3D _ptB
Point B of the segment.
OVector3D operator*(const OVector3D &vector) const
double norme() const
Computes the length of this vector.
OVector3D getRotationOzBase2(double alpha)
Returns the vector after a rotation around z axis \ and gives back the coordinates of xprime or yprim...
void invert()
Inverts this vector.
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
void balance(double c1, const OVector3D &vector2, double c2)
Balances this vector.
virtual ~OVector3D()
Destructor.
OVector3D operator-(const OVector3D &vector) const
OVector3D getRotationOzOy(double alpha, double theta)
Returns the vector after 2 rotations around z axis and y axis. It gives the coordinates of xsecond,...
bool operator!=(const OVector3D &vector) const
bool operator==(const OVector3D &vector) const
void normalize()
Normalizes this vector.
double scalar(const OVector3D &vector) const
Performs the scalar product between this object and another vector.
OVector3D cross(const OVector3D &vector) const
Cross product.
double angle(const OVector3D &vector) const
Computes the angle between this vector and another vector.
OVector3D()
Default constructor.
OVector3D operator+(const OVector3D &vector) const
OVector3D getRotationOz(double alpha)
Returns the vector after a rotation around z axis \ x -> xprime. Both of these vectors will be given ...
OVector3D & operator=(const OVector3D &vector)
operators
OVector3D getRotationOyBase2(double alpha)
Returns the vector after a rotation around y axis \ and gives back the coordinates of xprime or zprim...
OVector3D getRotationOy(double alpha)
Returns the vector after a rotation around z axis.
double dot(const OVector3D &v)
dot product (assuming an orthonormal reference frame)
void reset()
Reset this vector.