41 double zCross = (SR.
x * SP.
y) - (SR.
y * SP.
x);
47 return (
x *
x +
y *
y);
57 double XDiff = (P1->
x - P2->
x);
58 double YDiff = (P1->
y - P2->
y);
59 double dNormeCarre = XDiff * XDiff + YDiff * YDiff;
70 bool bDuMemeCoteQueR =
Scalaire(S, R, S, P) >= 0;
79 double dAbscisseCarree = (bDuMemeCoteQueR ? dNormeCSP / dNormeCSR : -dNormeCSP / dNormeCSR);
80 return dAbscisseCarree;
85 return vecteur1.
x * vecteur2.
x + vecteur1.
y * vecteur2.
y;
93 return Scalaire(aTYPointParcours_P1P2, aTYPointParcours_P3P4);
98 bool bP3OrP4MustNotCoincideWithP)
104 double detP3 =
ZCross(P1P2, P1P3);
105 double detP4 =
ZCross(P1P2, P1P4);
106 if (detP3 && detP4 && (detP3 * detP4) > 0)
112 if (!bIntersectionDroites)
129 if (
Confondus(&P3, &P) && bP3OrP4MustNotCoincideWithP)
135 if (
Confondus(&P4, &P) && bP3OrP4MustNotCoincideWithP)
173 alpha = (P.
x - P3.
x) / (P4.
x - P3.
x);
174 P.
y = P3.
y + alpha * (P4.
y - P3.
y);
176 P.
z = P3.
z + alpha * (P4.
z - P3.
z);
179 else if (P2.
y == P1.
y)
188 alpha = (P.
y - P3.
y) / (P4.
y - P3.
y);
189 P.
x = P3.
x + alpha * (P4.
x - P3.
x);
191 P.
z = P3.
z + alpha * (P4.
z - P3.
z);
194 else if ((P4.
y == P3.
y) || (P4.
x == P3.
x))
199 double a = (P2.
y - P1.
y) / (P2.
x - P1.
x);
200 double b = -a * P1.
x + P1.
y;
201 double ap = (P4.
y - P3.
y) / (P4.
x - P3.
x);
202 double bp = -ap * P3.
x + P3.
y;
209 P.
x = (bp - b) / (a - ap);
213 P.
z = P1.
z + (P.
x - P1.
x) * (P2.
z - P1.
z) / (P2.
x - P1.
x);
#define SEUIL_DISTANCE_POINTS_CONFONDUS
Below a distance of 2 centimeters, the points are considered on the same location.
double z
z coordinate of the point
static bool Confondus(TYPointParcours *P1, TYPointParcours *P2)
static bool IntersectionSegments(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P, bool bP3OrP4MustNotCoincideWithP=false)
Return true if [P1P2] intersects [P3P4] if P1 or P2 coincide with the intersection point P,...
static double ZCross(TYPointParcours SR, TYPointParcours SP)
Return cross product applied to SR and SP points.
double y
y coordinate of the point
bool operator==(TYPointParcours &p)
Return true if this point and p are on same location.
static double Scalaire(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4)
Compute the scalar product of the vector P1P2 and P3P4.
double x
x coordinate of the point
double normeCarree()
Return x^2+y^2.
static const double _dSeuilDistanceCarre
static bool IntersectionDroites(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P)
static double AbscisseCurviligneCarreSurSR(TYPointParcours &P, TYPointParcours &S, TYPointParcours &R)
Return the square of the curvilinear abscissa of point P on [SR].
static TYPointParcours vecteur2D(TYPointParcours &P1, TYPointParcours &P2)
Compute the 2 dimensional vector P1P2 in the XY plane.