Bentley-Otmann Algorithm 2.0
An implementation of Bentley-Ottmann algorithm in order to count the m,n-cubes
|
2D segment lines More...
#include <geometry.hpp>
Public Member Functions | |
Segment () | |
Default constructor. | |
Segment (const Segment &seg) | |
Copy constructor. | |
Segment (const Point &a, const Point &b) | |
Assign constructor. | |
Segment (const rat &xa, const rat &ya, const rat &xb, const rat &yb) | |
Assign constructor. | |
Point | get_left () const |
Reads private memeber left. | |
Point | get_right () const |
Reads private member right. | |
rat | high (const Point &) const |
Computes the high of a segment line. | |
bool | less (const Segment &, const Point &) const |
Order of the segment relatively to a point. | |
bool | intersect (const Segment &, Point &) const |
Search for intersections. | |
bool | is_rend (const Point &) const |
Checks if a point is the right endpoint of the segment line. | |
bool | is_lend (const Point &) const |
Checks if a point is the left endpoint of the segment line. | |
bool | is_in (const Point &) const |
Checks if a point is in the interior of the segment line. | |
Private Attributes | |
Point | left |
Left endpoint. | |
Point | right |
Right endpoint. | |
Slope | slope |
Slope. |
2D segment lines
Using class Point for the endpoints of the segment line, and struct Slope to indicate the direction of the segment line.
For a couple of point, one is said to be the left one and the other the right one regarding to the lexographic order on the (x,y)-coordinates.
Definition at line 110 of file geometry.hpp.
Segment::Segment | ( | const Segment & | seg | ) | [inline] |
Assign constructor.
a,b | Points to be left and right ones of the segment line |
Definition at line 137 of file geometry.hpp.
Segment::Segment | ( | const rat & | xa, |
const rat & | ya, | ||
const rat & | xb, | ||
const rat & | yb | ||
) | [inline] |
Assign constructor.
xa,ya | Coordinates of the left endpoint |
xb,yb | Coordinates of the right endpoint |
Definition at line 146 of file geometry.hpp.
Point Segment::get_left | ( | ) | const |
Point Segment::get_right | ( | ) | const |
rat Segment::high | ( | const Point & | p_sweep | ) | const |
Computes the high of a segment line.
p_sweep | Sweeping point to use in the comparison. |
We define the high of a segment line regarding to a point as :
Definition at line 141 of file geometry.cpp.
Search for intersections.
seg | Segment to check if it is crossing the current one. |
inter | If there is an intersection, used to report it. |
The searching is done by computing the determinant of the classic system induced by the segment lines.
Definition at line 93 of file geometry.cpp.
bool Segment::is_in | ( | const Point & | p | ) | const |
Checks if a point is in the interior of the segment line.
p | Point to test. |
Definition at line 207 of file geometry.cpp.
bool Segment::is_lend | ( | const Point & | p | ) | const |
Checks if a point is the left endpoint of the segment line.
p | Point to test. |
Definition at line 197 of file geometry.cpp.
bool Segment::is_rend | ( | const Point & | p | ) | const |
Checks if a point is the right endpoint of the segment line.
p | Point to test. |
Definition at line 187 of file geometry.cpp.
Order of the segment relatively to a point.
s | Segment to compare with. |
p_sweep | Sweeping point. |
A segment is less than an other if its high is less than the other's high or if its high is equal to the other's high and its slope is less than the other's slope.
Definition at line 172 of file geometry.cpp.