VisiLibity v1 Source Code 1.0
Public Member Functions | Protected Attributes | List of all members
VisiLibity::Line_Segment Class Reference

line segment in the plane represented by its endpoints More...

#include <visilibity.hpp>

Public Member Functions

 Line_Segment ()
 default to empty
 
 Line_Segment (const Line_Segment &line_segment_temp)
 copy constructor
 
 Line_Segment (const Point &point_temp)
 construct degenerate segment from a single Point
 
 Line_Segment (const Point &first_point_temp, const Point &second_point_temp, double epsilon=0)
 Line_Segment pointing from first_point_temp to second_point_temp.
 
Point first () const
 first endpoint More...
 
Point second () const
 second endpoint More...
 
unsigned size () const
 number of distinct endpoints More...
 
Point midpoint () const
 midpoint More...
 
double length () const
 Euclidean length. More...
 
bool is_in_standard_form () const
 true iff vertices in lex. order More...
 
Line_Segmentoperator= (const Line_Segment &line_segment_temp)
 assignment operator
 
void set_first (const Point &point_temp, double epsilon=0.0)
 set first endpoint More...
 
void set_second (const Point &point_temp, double epsilon=0.0)
 set second endpoint More...
 
void reverse ()
 reverse order of endpoints More...
 
void enforce_standard_form ()
 enforce that lex. smallest endpoint first More...
 
void clear ()
 erase both endpoints and set line segment empty (size 0)
 
virtual ~Line_Segment ()
 destructor
 

Protected Attributes

Pointendpoints_
 
unsigned size_
 

Detailed Description

line segment in the plane represented by its endpoints

Closed and oriented line segment in the plane represented by its endpoints.

Remarks
may be degenerate (colocated endpoints) or empty

Member Function Documentation

◆ enforce_standard_form()

void VisiLibity::Line_Segment::enforce_standard_form ( )

enforce that lex. smallest endpoint first

Postcondition
the lexicographically smallest endpoint (lowest x, then lowest y) is first
Remarks
lex. comparison is very sensitive to perturbations if two Points nearly define a line parallel to one of the axes

◆ first()

Point VisiLibity::Line_Segment::first ( ) const

first endpoint

Precondition
size() > 0
Returns
the first Point of the Line_Segment
Remarks
If size() == 1, then both first() and second() are valid and will return the same Point

◆ is_in_standard_form()

bool VisiLibity::Line_Segment::is_in_standard_form ( ) const

true iff vertices in lex. order

Precondition
size() > 0
Returns
true iff vertices are listed beginning with the vertex which is lexicographically smallest (lowest x, then lowest y)
Remarks
lex. comparison is very sensitive to perturbations if two Points nearly define a line parallel to one of the axes

◆ length()

double VisiLibity::Line_Segment::length ( ) const

Euclidean length.

Precondition
size() > 0

◆ midpoint()

Point VisiLibity::Line_Segment::midpoint ( ) const

midpoint

Precondition
size() > 0

◆ reverse()

void VisiLibity::Line_Segment::reverse ( )

reverse order of endpoints

Postcondition
order of endpoints is reversed.

◆ second()

Point VisiLibity::Line_Segment::second ( ) const

second endpoint

Precondition
size() > 0
Returns
the second Point of the Line_Segment
Remarks
If size() == 1, then both first() and second() are valid and will return the same Point

◆ set_first()

void VisiLibity::Line_Segment::set_first ( const Point point_temp,
double  epsilon = 0.0 
)

set first endpoint

Remarks
if point_temp is w/in a distance epsilon of an existing endpoint, the coordinates of point_temp are used and size is set to 1 as appropriate

◆ set_second()

void VisiLibity::Line_Segment::set_second ( const Point point_temp,
double  epsilon = 0.0 
)

set second endpoint

Remarks
if point_temp is w/in a distance epsilon of an existing endpoint, the coordinates of point_temp are used and size is set to 1 as appropriate

◆ size()

unsigned VisiLibity::Line_Segment::size ( ) const
inline

number of distinct endpoints

Remarks
size 0 => empty line segment; size 1 => degenerate (single point) line segment; size 2 => full-fledged (bona fide) line segment

The documentation for this class was generated from the following files: