Bentley-Otmann Algorithm 2.0
An implementation of Bentley-Ottmann algorithm in order to count the m,n-cubes
Public Member Functions | Private Attributes
Segment Class Reference

2D segment lines More...

#include <geometry.hpp>

Collaboration diagram for Segment:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

Segment::Segment ( const Segment seg) [inline]

Copy constructor.

Parameters:
segSegment to copy

Definition at line 127 of file geometry.hpp.

Segment::Segment ( const Point a,
const Point b 
) [inline]

Assign constructor.

Parameters:
a,bPoints 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.

Parameters:
xa,yaCoordinates of the left endpoint
xb,ybCoordinates of the right endpoint

Definition at line 146 of file geometry.hpp.


Member Function Documentation

Point Segment::get_left ( ) const

Reads private memeber left.

Returns:
Left endpoint

Definition at line 72 of file geometry.cpp.

Point Segment::get_right ( ) const

Reads private member right.

Returns:
Right endpoint

Definition at line 80 of file geometry.cpp.

rat Segment::high ( const Point p_sweep) const

Computes the high of a segment line.

Parameters:
p_sweepSweeping point to use in the comparison.
Returns:
High of the segment line

We define the high of a segment line regarding to a point as :

  • not defined if the segment line does not cross the vertical line with abscissa the abscissa of the point.
  • if the segment line is vertical
    • the y-coordinate of the point if the segment line contains the point.
    • the y-coordinate of the left endpoint if the point is laying below the segment line.
    • the y-coordinate of the right endpoint if the point is laying above the segment line.
  • the y-coordinate of the crossing point of the segment and the vertical line with abscissa the abscissa of the point else.

Definition at line 141 of file geometry.cpp.

bool Segment::intersect ( const Segment seg,
Point inter 
) const

Search for intersections.

Parameters:
segSegment to check if it is crossing the current one.
interIf there is an intersection, used to report it.
Returns:
True if and only if there is an intersection.

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.

Parameters:
pPoint to test.
Returns:
True if and only if p is in the interior.

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.

Parameters:
pPoint to test.
Returns:
True if and only if p is the left endpoint.

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.

Parameters:
pPoint to test.
Returns:
True if and only if p is the right endpoint.

Definition at line 187 of file geometry.cpp.

bool Segment::less ( const Segment s,
const Point p_sweep 
) const

Order of the segment relatively to a point.

Parameters:
sSegment to compare with.
p_sweepSweeping point.
Returns:
True if and only if the current segment is less than s

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations