Horizon
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
SEG Class Reference

Public Types

using ecoord = VECTOR2I::extended_type
 
using ecoord = VECTOR2I::extended_type
 

Public Member Functions

 SEG ()
 Default constructor Creates an empty (0, 0) segment.
 
 SEG (int aX1, int aY1, int aX2, int aY2)
 Constructor Creates a segment between (aX1, aY1) and (aX2, aY2)
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB)
 Constructor Creates a segment between (aA) and (aB)
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB, int aIndex)
 Constructor Creates a segment between (aA) and (aB), referenced to a multi-segment shape. More...
 
 SEG (const SEG &aSeg)
 Copy constructor.
 
SEGoperator= (const SEG &aSeg)
 
bool operator== (const SEG &aSeg) const
 
bool operator!= (const SEG &aSeg) const
 
VECTOR2I LineProject (const VECTOR2I &aP) const
 Function LineProject() More...
 
int Side (const VECTOR2I &aP) const
 Function Side() More...
 
int LineDistance (const VECTOR2I &aP, bool aDetermineSide=false) const
 Function LineDistance() More...
 
const VECTOR2I NearestPoint (const VECTOR2I &aP) const
 Function NearestPoint() More...
 
const VECTOR2I NearestPoint (const SEG &aSeg) const
 Computes a point on the segment (this) that is closest to any point on aSeg. More...
 
OPT_VECTOR2I Intersect (const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
 Function Intersect() More...
 
OPT_VECTOR2I IntersectLines (const SEG &aSeg) const
 Function IntersectLines() More...
 
bool Collide (const SEG &aSeg, int aClearance) const
 
ecoord SquaredDistance (const SEG &aSeg) const
 
int Distance (const SEG &aSeg) const
 Function Distance() More...
 
ecoord SquaredDistance (const VECTOR2I &aP) const
 
int Distance (const VECTOR2I &aP) const
 Function Distance() More...
 
void CanonicalCoefs (ecoord &qA, ecoord &qB, ecoord &qC) const
 
bool Collinear (const SEG &aSeg) const
 Function Collinear() More...
 
bool ApproxCollinear (const SEG &aSeg) const
 
bool ApproxParallel (const SEG &aSeg) const
 
bool Overlaps (const SEG &aSeg) const
 
int Length () const
 Function Length() More...
 
ecoord SquaredLength () const
 
ecoord TCoef (const VECTOR2I &aP) const
 
int Index () const
 Function Index() More...
 
bool Contains (const VECTOR2I &aP) const
 
bool PointCloserThan (const VECTOR2I &aP, int aDist) const
 
void Reverse ()
 
VECTOR2I Center () const
 

Returns the center point of the line


 
 SEG ()
 Default constructor Creates an empty (0, 0) segment.
 
 SEG (int aX1, int aY1, int aX2, int aY2)
 Constructor Creates a segment between (aX1, aY1) and (aX2, aY2)
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB)
 Constructor Creates a segment between (aA) and (aB)
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB, int aIndex)
 Constructor Creates a segment between (aA) and (aB), referenced to a multi-segment shape. More...
 
 SEG (const SEG &aSeg)
 Copy constructor.
 
SEGoperator= (const SEG &aSeg)
 
bool operator== (const SEG &aSeg) const
 
bool operator!= (const SEG &aSeg) const
 
VECTOR2I LineProject (const VECTOR2I &aP) const
 Function LineProject() More...
 
int Side (const VECTOR2I &aP) const
 Function Side() More...
 
int LineDistance (const VECTOR2I &aP, bool aDetermineSide=false) const
 Function LineDistance() More...
 
const VECTOR2I NearestPoint (const VECTOR2I &aP) const
 Function NearestPoint() More...
 
const VECTOR2I NearestPoint (const SEG &aSeg) const
 Computes a point on the segment (this) that is closest to any point on aSeg. More...
 
OPT_VECTOR2I Intersect (const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
 Function Intersect() More...
 
OPT_VECTOR2I IntersectLines (const SEG &aSeg) const
 Function IntersectLines() More...
 
bool Collide (const SEG &aSeg, int aClearance) const
 
ecoord SquaredDistance (const SEG &aSeg) const
 
int Distance (const SEG &aSeg) const
 Function Distance() More...
 
ecoord SquaredDistance (const VECTOR2I &aP) const
 
int Distance (const VECTOR2I &aP) const
 Function Distance() More...
 
void CanonicalCoefs (ecoord &qA, ecoord &qB, ecoord &qC) const
 
bool Collinear (const SEG &aSeg) const
 Function Collinear() More...
 
bool ApproxCollinear (const SEG &aSeg) const
 
bool ApproxParallel (const SEG &aSeg) const
 
bool Overlaps (const SEG &aSeg) const
 
int Length () const
 Function Length() More...
 
ecoord SquaredLength () const
 
ecoord TCoef (const VECTOR2I &aP) const
 
int Index () const
 Function Index() More...
 
bool Contains (const VECTOR2I &aP) const
 
bool PointCloserThan (const VECTOR2I &aP, int aDist) const
 
void Reverse ()
 
VECTOR2I Center () const
 

Returns the center point of the line


 

Public Attributes

VECTOR2I A
 
VECTOR2I B
 

Friends

std::ostream & operator<< (std::ostream &aStream, const SEG &aSeg)
 
std::ostream & operator<< (std::ostream &aStream, const SEG &aSeg)
 

Constructor & Destructor Documentation

◆ SEG() [1/2]

SEG::SEG ( const VECTOR2I aA,
const VECTOR2I aB,
int  aIndex 
)
inline

Constructor Creates a segment between (aA) and (aB), referenced to a multi-segment shape.

Parameters
aAreference to the start point in the parent shape
aBreference to the end point in the parent shape
aIndexindex of the segment within the parent shape

◆ SEG() [2/2]

SEG::SEG ( const VECTOR2I aA,
const VECTOR2I aB,
int  aIndex 
)
inline

Constructor Creates a segment between (aA) and (aB), referenced to a multi-segment shape.

Parameters
aAreference to the start point in the parent shape
aBreference to the end point in the parent shape
aIndexindex of the segment within the parent shape

Member Function Documentation

◆ Collinear() [1/2]

bool SEG::Collinear ( const SEG aSeg) const
inline

Function Collinear()

Checks if segment aSeg lies on the same line as (this).

Parameters
aSegthe segment to chech colinearity with
Returns
true, when segments are collinear.

◆ Collinear() [2/2]

bool SEG::Collinear ( const SEG aSeg) const
inline

Function Collinear()

Checks if segment aSeg lies on the same line as (this).

Parameters
aSegthe segment to chech colinearity with
Returns
true, when segments are collinear.

◆ Distance() [1/4]

int SEG::Distance ( const SEG aSeg) const
inline

Function Distance()

Computes minimum Euclidean distance to segment aSeg.

Parameters
aSegother segment
Returns
minimum distance

◆ Distance() [2/4]

int SEG::Distance ( const SEG aSeg) const
inline

Function Distance()

Computes minimum Euclidean distance to segment aSeg.

Parameters
aSegother segment
Returns
minimum distance

◆ Distance() [3/4]

int SEG::Distance ( const VECTOR2I aP) const
inline

Function Distance()

Computes minimum Euclidean distance to point aP.

Parameters
aPthe point
Returns
minimum distance

◆ Distance() [4/4]

int SEG::Distance ( const VECTOR2I aP) const
inline

Function Distance()

Computes minimum Euclidean distance to point aP.

Parameters
aPthe point
Returns
minimum distance

◆ Index() [1/2]

int SEG::Index ( ) const
inline

Function Index()

Return the index of this segment in its parent shape (applicable only to non-local segments)

Returns
index value

◆ Index() [2/2]

int SEG::Index ( ) const
inline

Function Index()

Return the index of this segment in its parent shape (applicable only to non-local segments)

Returns
index value

◆ Intersect() [1/2]

OPT_VECTOR2I SEG::Intersect ( const SEG aSeg,
bool  aIgnoreEndpoints = false,
bool  aLines = false 
) const

Function Intersect()

Computes intersection point of segment (this) with segment aSeg.

Parameters
aSegsegment to intersect with
aIgnoreEndpointsdon't treat corner cases (i.e. end of one segment touching the other) as intersections.
aLinestreat segments as infinite lines
Returns
intersection point, if exists

◆ Intersect() [2/2]

OPT_VECTOR2I SEG::Intersect ( const SEG aSeg,
bool  aIgnoreEndpoints = false,
bool  aLines = false 
) const

Function Intersect()

Computes intersection point of segment (this) with segment aSeg.

Parameters
aSegsegment to intersect with
aIgnoreEndpointsdon't treat corner cases (i.e. end of one segment touching the other) as intersections.
aLinestreat segments as infinite lines
Returns
intersection point, if exists

◆ IntersectLines() [1/2]

OPT_VECTOR2I SEG::IntersectLines ( const SEG aSeg) const
inline

Function IntersectLines()

Computes the intersection point of lines passing through ends of (this) and aSeg

Parameters
aSegsegment defining the line to intersect with
Returns
intersection point, if exists

◆ IntersectLines() [2/2]

OPT_VECTOR2I SEG::IntersectLines ( const SEG aSeg) const
inline

Function IntersectLines()

Computes the intersection point of lines passing through ends of (this) and aSeg

Parameters
aSegsegment defining the line to intersect with
Returns
intersection point, if exists

◆ Length() [1/2]

int SEG::Length ( ) const
inline

Function Length()

Returns the length (this)

Returns
length

◆ Length() [2/2]

int SEG::Length ( ) const
inline

Function Length()

Returns the length (this)

Returns
length

◆ LineDistance() [1/2]

int SEG::LineDistance ( const VECTOR2I aP,
bool  aDetermineSide = false 
) const
inline

Function LineDistance()

Returns the closest Euclidean distance between point aP and the line defined by the ends of segment (this).

Parameters
aPthe point to test
aDetermineSidewhen true, the sign of the returned value indicates the side of the line at which we are (negative = left)
Returns
the distance

◆ LineDistance() [2/2]

int SEG::LineDistance ( const VECTOR2I aP,
bool  aDetermineSide = false 
) const

Function LineDistance()

Returns the closest Euclidean distance between point aP and the line defined by the ends of segment (this).

Parameters
aPthe point to test
aDetermineSidewhen true, the sign of the returned value indicates the side of the line at which we are (negative = left)
Returns
the distance

◆ LineProject() [1/2]

VECTOR2I SEG::LineProject ( const VECTOR2I aP) const
inline

Function LineProject()

Computes the perpendicular projection point of aP on a line passing through ends of the segment.

Parameters
aPpoint to project
Returns
projected point

◆ LineProject() [2/2]

VECTOR2I SEG::LineProject ( const VECTOR2I aP) const

Function LineProject()

Computes the perpendicular projection point of aP on a line passing through ends of the segment.

Parameters
aPpoint to project
Returns
projected point

◆ NearestPoint() [1/4]

const VECTOR2I SEG::NearestPoint ( const SEG aSeg) const

Computes a point on the segment (this) that is closest to any point on aSeg.

Returns
the nearest point

◆ NearestPoint() [2/4]

const VECTOR2I SEG::NearestPoint ( const SEG aSeg) const

Computes a point on the segment (this) that is closest to any point on aSeg.

Returns
the nearest point

◆ NearestPoint() [3/4]

const VECTOR2I SEG::NearestPoint ( const VECTOR2I aP) const
inline

Function NearestPoint()

Computes a point on the segment (this) that is closest to point aP.

Returns
the nearest point

◆ NearestPoint() [4/4]

const VECTOR2I SEG::NearestPoint ( const VECTOR2I aP) const

Function NearestPoint()

Computes a point on the segment (this) that is closest to point aP.

Returns
the nearest point

◆ Side() [1/2]

int SEG::Side ( const VECTOR2I aP) const
inline

Function Side()

Determines on which side of directed line passing via segment ends point aP lies.

Parameters
aPpoint to determine the orientation wrs to self
Returns
: < 0: left, 0 : on the line, > 0 : right

◆ Side() [2/2]

int SEG::Side ( const VECTOR2I aP) const
inline

Function Side()

Determines on which side of directed line passing via segment ends point aP lies.

Parameters
aPpoint to determine the orientation wrs to self
Returns
: < 0: left, 0 : on the line, > 0 : right

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