Delaunator
2D Delaunay Triangulation in C++ with Python wrapper.
 All Classes Namespaces Functions
Functions
geometry Namespace Reference

Functions

void unit_tests ()
float squareDistanceBetweenPoints (Coordinates A, Coordinates B)
float squareDistanceBetweenPoints (float x1, float y1, float x2, float y2)
bool pointInCircumcircleOf (Coordinates p1, Coordinates p2, Coordinates p3, Coordinates p0)
Coordinates circumcenterOf (Coordinates A, Coordinates B, Coordinates C)
bool pointInTriangle (Coordinates p1, Coordinates p2, Coordinates p3, Coordinates p0)
float squareDistanceBetweenSegmentAndPoint (float x1, float x2, float y1, float y2, float px, float py)
bool parallelLines (Coordinates A, Coordinates B, Coordinates C, Coordinates D)
Coordinates intersectionOfLines (Coordinates A, Coordinates B, Coordinates C, Coordinates D)
Coordinates behindIntersectionOfLines (Coordinates A, Coordinates B, Coordinates C, Coordinates D)
bool collisionBetweenSegmentAndLine (Coordinates O, Coordinates P, Coordinates A, Coordinates B)
bool collisionBetweenSegmentAndSegment (Coordinates A, Coordinates B, Coordinates C, Coordinates D)
bool collisionBetweenLineAndCircle (Coordinates A, Coordinates B, Coordinates C, float radius)
bool pointInsideCircle (Coordinates A, Coordinates C, float radius)
bool pointOnCircle (Coordinates A, Coordinates C, float radius)
bool collisionBetweenSegmentAndCircle (Coordinates A, Coordinates B, Coordinates C, float radius)
Coordinates projectionOfPointOnLine (Coordinates A, Coordinates B, Coordinates C)
unsigned int intersectionsBetweenLineAndCircle (Coordinates A, Coordinates B, Coordinates C, float square_radius, Coordinates *S1, Coordinates *S2)
unsigned int intersectionsBetweenSegmentAndCircle (Coordinates A, Coordinates B, Coordinates C, float square_radius, Coordinates *S1, Coordinates *S2)
bool coeffAndOrdnOfLine (Coordinates A, Coordinates B, float *coef, float *ordn)

Detailed Description

Geometry is a namespace that define lots of useful geometry functions.

Function Documentation

Coordinates geometry::behindIntersectionOfLines ( Coordinates  A,
Coordinates  B,
Coordinates  C,
Coordinates  D 
)
Parameters
ACoordinates of a line point
BCoordinates of another line point
CCoordinates of a line point
DCoordinates of another line point
Returns
Coordinates of a point that is behind the intersection of the lines, and on (A;B)
Note
distance between returned point and intersection of lines is equal to EPSILON
returned point is nearer of A than B; difference is about EPSILON lines are not parallel
Coordinates geometry::circumcenterOf ( Coordinates  A,
Coordinates  B,
Coordinates  C 
)
Parameters
ACoordinates of a point of triangle
BCoordinates of a point of triangle
CCoordinates of a point of triangle
Returns
C Coordinates of triangle's circumcenter
bool geometry::coeffAndOrdnOfLine ( Coordinates  A,
Coordinates  B,
float *  coef,
float *  ordn 
)
Parameters
ACoordinates of a point on the line
BCoordinates of another point on the line
coefref of float, modified
ordnref of float, modified
Returns
false if line is vertical, else true
Warning
if line is vertical, ordn only is modifed and represent the offset in x axis
bool geometry::collisionBetweenLineAndCircle ( Coordinates  A,
Coordinates  B,
Coordinates  C,
float  radius 
)
Parameters
ACoordinates of a line point
BCoordinates of another line point
CCoordinates of circle's center
radiusof the circle
Returns
true if circle collide with (AB) line
bool geometry::collisionBetweenSegmentAndCircle ( Coordinates  A,
Coordinates  B,
Coordinates  C,
float  radius 
)
Parameters
ACoordinates of segment point
BCoordinates of segment point
CCoordinates of circle's center
radiusof the circle
Returns
true if circle collide with [AB] segment
bool geometry::collisionBetweenSegmentAndLine ( Coordinates  O,
Coordinates  P,
Coordinates  A,
Coordinates  B 
)
Parameters
OCoordinates of a segment point
PCoordinates of another segment point
ACoordinates of a line point
BCoordinates of another line point
Returns
true if [OP] segment cross with (AB) line
0 if [OP] and (AB) don't cross, 1 if ]OP[ cross (AB) or 2 if O or P are on (AB)
bool geometry::collisionBetweenSegmentAndSegment ( Coordinates  A,
Coordinates  B,
Coordinates  C,
Coordinates  D 
)
Parameters
ACoordinates of a first segment point
BCoordinates of another first segment point
CCoordinates of a second segment point
DCoordinates of another second segment point
Returns
true if [AB] segment cross with [CD] segment
Coordinates geometry::intersectionOfLines ( Coordinates  A,
Coordinates  B,
Coordinates  C,
Coordinates  D 
)
Parameters
ACoordinates of a line point
BCoordinates of another line point
CCoordinates of a line point
DCoordinates of another line point
Returns
Coordinates of intersection of the lines lines are not parallel
unsigned int geometry::intersectionsBetweenLineAndCircle ( Coordinates  A,
Coordinates  B,
Coordinates  C,
float  square_radius,
Coordinates S1,
Coordinates S2 
)
Parameters
ACoordinates of a point on the line
BCoordinates of another point on the line
CCoordinates of center of circle
square_radiusof the circle
S1reference to Coordinates of the first find point of intersection between cricle and line
S2reference to Coordinates of the second find point
Returns
number of solution, 0, 1 or 2
Note
if return 0, S1 and S2 are not modified, if 1, S1 only is modifed, else, both modified
unsigned int geometry::intersectionsBetweenSegmentAndCircle ( Coordinates  A,
Coordinates  B,
Coordinates  C,
float  square_radius,
Coordinates S1,
Coordinates S2 
)
Parameters
ACoordinates of extremity of [AB]
BCoordinates of extremity of [AB]
CCoordinates of center of circle
square_radiusof the circle
S1reference to Coordinates of the first find point of intersection between cricle and [AB]
S2reference to Coordinates of the second find point
Returns
number of solution, 0, 1 or 2
Note
if return 2, S1 and S2 are modified, if 1, S1 is modified and maybe S2, else both can be modified
bool geometry::parallelLines ( Coordinates  A,
Coordinates  B,
Coordinates  C,
Coordinates  D 
)
Parameters
ACoordinates of a line point
BCoordinates of another line point
CCoordinates of a line point
DCoordinates of another line point
Returns
true if lines are parallels
Warning
if A == B or C == D, lines are parallel
bool geometry::pointInCircumcircleOf ( Coordinates  p1,
Coordinates  p2,
Coordinates  p3,
Coordinates  p0 
)
Parameters
p1Coordinates of a point of triangle
p2Coordinates of a point of triangle
p3Coordinates of a point of triangle
p0Coordinates of tested point
Returns
true iff tested point is in circumcircle of triangle composed by p1, p2 and p3.
bool geometry::pointInsideCircle ( Coordinates  A,
Coordinates  C,
float  radius 
)
Parameters
ACoordinates of tested point
CCoordinates of circle's center
radiusof the circle
Returns
true if tested point is inside circle
Note
return false if point is exactly on circle
bool geometry::pointInTriangle ( Coordinates  p1,
Coordinates  p2,
Coordinates  p3,
Coordinates  p0 
)
Parameters
p1Coordinates of a point of triangle
p2Coordinates of a point of triangle
p3Coordinates of a point of triangle
p0Coordinates of tested point
Returns
true iff tested point is in triangle composed by p1, p2 and p3.
bool geometry::pointOnCircle ( Coordinates  A,
Coordinates  C,
float  radius 
)
Parameters
ACoordinates of tested point
CCoordinates of circle's center
radiusof the circle
Returns
true if tested point is on circle, false if tested point is inside or outside the circle
Coordinates geometry::projectionOfPointOnLine ( Coordinates  A,
Coordinates  B,
Coordinates  C 
)
Parameters
Aa point on the line
Banother point on the line
Cthe evaluated point
Returns
the projection of evaluated point on the line
float geometry::squareDistanceBetweenPoints ( Coordinates  A,
Coordinates  B 
)
Parameters
ACoordinates of a point of triangle
BCoordinates of a point of triangle
Returns
square distance between the two points
Warning
return value is square of distance, not real distance
float geometry::squareDistanceBetweenPoints ( float  x1,
float  y1,
float  x2,
float  y2 
)
Parameters
x1coordinate in x for first point
y1coordinate in y for first point
x2coordinate in x for second point
y2coordinate in y for second point
Returns
square distance between the two points
Warning
return value is square of distance, not real distance
float geometry::squareDistanceBetweenSegmentAndPoint ( float  x1,
float  y1,
float  x2,
float  y2,
float  px,
float  py 
)
Parameters
x1coordinate in x for first point of segment
y1coordinate in y for first point of segment
x2coordinate in x for second point of segment
y2coordinate in y for second point of segment
pxcoordinate in x of tested point
pycoordinate in y of tested point
Returns
shorter square distance between segment and point
Warning
return value is square of distance, not real distance
void geometry::unit_tests ( )

call that once for verify integrity of geometry fonctions

Warning
: assertion fail if detected problem