|
|
| |||
| returns LEFTTURN, if lies to the left of the oriented line defined by and , returns RIGHTTURN if lies to the right of , and returns COLLINEAR if lies on . | ||||
The following functions return true or false
depending on whether the orientation of three points is equal to
one of the constants mentioned in
.
|
|
| |
|
|
| |
|
|
| |
Finally, there are some special cases of collinearity. If we not only want to know if three points are collinear but also if they respect a certain order on the line, these are the functions to call:
|
|
| |||
| returns true, iff the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. | ||||
|
|
| |||
| returns true, iff the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. | ||||
If we already know that three points are collinear, we should not check it again.
|
|
| |||
|
returns true, iff q lies between p
and r. Precondition: p, q and r are collinear. | ||||
|
|
| |||
|
returns true, iff q lies strictly between p
and r. Precondition: p, q and r are collinear. | ||||
#include <CGAL/predicates_on_points_2.h>
Instead of constructing a circle and performing the test if a given point lies inside or outside you might use the following predicate:
|
|
| |||
|
returns the relative position of point test
to the circle defined by , and . The order
of the points , and does not matter. Precondition: p, q and r are not collinear. | ||||
|
|
| |||
|
returns the relative position of point test
to the oriented circle defined by , and .
The order of the points , and is important,
since it determines the orientation of the implicitly
constructed circle. Precondition: p, q and r are not collinear. | ||||
In order to check if two points have the same or coordinate we provide the following functions. They allow to write code that does not depend on the representation type.
#include <CGAL/predicates_on_points_2.h>
|
|
| |
| returns true, iff p and q have the same x-coordinate. | ||
|
|
| |
| returns true, iff p and q have the same y-coordinate. | ||
The above functions, returning a bool, are decision versions of the following comparison functions, returning a Comparison_result.
|
|
| |
|
|
| |
CGAL offers the same functions for points given implicitly as intersection of two lines. We provide these functions because we can provide better code for the test, than simply computing the intersection and calling the respective function for points.
Precondition: Lines that define an intersection point may not be parallel.
#include <CGAL/predicates_on_lines_2.h>
|
|
| |||
| compares the -coordinates of and the intersection of lines and , see (a) in the figure below. | ||||
|
|
| |||
| compares the -coordinates of the intersection of line with line and with line , see (b) in the figure below. | ||||
|
|
| |||
| compares the -coordinates of the intersection of lines and and the intersection of lines and , see (c) in the figure below. | ||||
|
|
| |||
| compares the -coordinates of and the intersection of lines and , see (a) in the figure above. | ||||
|
|
| |||
| compares the -coordinates of the intersection of line with line and with line , see (b) in the figure above. | ||||
|
|
| |||
| compares the -coordinates of the intersection of lines and and the intersection of lines and , see (c) in the figure above. | ||||
The following functions compare the y coordinate of a point (that may be given implicitly) with a line.
Precondition: If the point is given as an intersection of two lines these
lines may not be parallel. Lines where points are projected on may not be
vertical.
|
|
| |||
| compares the -coordinates of and the vertical projection of p on h, see (d) in the figure below. | ||||
|
|
| |||
| This function compares the -coordinates of the vertical projection of p on h1 and on h2, see (e) in the figure below. | ||||
|
|
| |||
| Let be the intersection of lines and . This function compares the -coordinates of and the vertical projection of p on h, see (f) in the figure below. | ||||
|
|
| |||
| Let be the intersection of lines and . This function compares the -coordinates of the vertical projection of p on h1 and on h2, see (g) in the figure below. | ||||
For lexicographical comparison CGAL provides
|
|
| |||
| Compares the Cartesian coordinates of points p and q lexicographically in order: first -coordinates are compared, if they are equal, -coordinates are compared. | ||||
In addition, CGAL provides the following comparison functions returning true or false depending on the result of compare_lexicographically_xy(p,q).
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
Distance comparisons, Section
.