Horizon
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
SEG Class Reference

Public Types

using ecoord = VECTOR2I::extended_type
 

Public Member Functions

 SEG ()
 Create an empty (0, 0) segment.
 
 SEG (int aX1, int aY1, int aX2, int aY2)
 Create a segment between (aX1, aY1) and (aX2, aY2).
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB)
 Create a segment between (aA) and (aB).
 
 SEG (const VECTOR2I &aA, const VECTOR2I &aB, int aIndex)
 Create a segment between (aA) and (aB), referenced to a multi-segment shape.
 
 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
 Compute the perpendicular projection point of aP on a line passing through ends of the segment.
 
int Side (const VECTOR2I &aP) const
 Determine on which side of directed line passing via segment ends point aP lies.
 
int LineDistance (const VECTOR2I &aP, bool aDetermineSide=false) const
 Return the closest Euclidean distance between point aP and the line defined by the ends of segment (this).
 
double AngleDegrees (const SEG &aOther) const
 Determine the smallest angle between two segments (result in degrees)
 
const VECTOR2I NearestPoint (const VECTOR2I &aP) const
 Compute a point on the segment (this) that is closest to point aP.
 
const VECTOR2I NearestPoint (const SEG &aSeg) const
 Compute a point on the segment (this) that is closest to any point on aSeg.
 
const VECTOR2I ReflectPoint (const VECTOR2I &aP) const
 Reflect a point using this segment as axis.
 
OPT_VECTOR2I Intersect (const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
 Compute intersection point of segment (this) with segment aSeg.
 
bool Intersects (const SEG &aSeg) const
 
OPT_VECTOR2I IntersectLines (const SEG &aSeg) const
 Compute the intersection point of lines passing through ends of (this) and aSeg.
 
SEG PerpendicularSeg (const VECTOR2I &aP) const
 Compute a segment perpendicular to this one, passing through point aP.
 
SEG ParallelSeg (const VECTOR2I &aP) const
 Compute a segment parallel to this one, passing through point aP.
 
bool Collide (const SEG &aSeg, int aClearance, int *aActual=nullptr) const
 
ecoord SquaredDistance (const SEG &aSeg) const
 
int Distance (const SEG &aSeg) const
 Compute minimum Euclidean distance to segment aSeg.
 
ecoord SquaredDistance (const VECTOR2I &aP) const
 
int Distance (const VECTOR2I &aP) const
 Compute minimum Euclidean distance to point aP.
 
void CanonicalCoefs (ecoord &qA, ecoord &qB, ecoord &qC) const
 
bool Collinear (const SEG &aSeg) const
 Check if segment aSeg lies on the same line as (this).
 
bool ApproxCollinear (const SEG &aSeg) const
 
bool ApproxParallel (const SEG &aSeg, int aDistanceThreshold=1) const
 
bool ApproxPerpendicular (const SEG &aSeg) const
 
bool Overlaps (const SEG &aSeg) const
 
bool Contains (const SEG &aSeg) const
 
int Length () const
 Return the length (this).
 
ecoord SquaredLength () const
 
ecoord TCoef (const VECTOR2I &aP) const
 
int Index () const
 Return the index of this segment in its parent shape (applicable only to non-local segments).
 
bool Contains (const VECTOR2I &aP) const
 
void Reverse ()
 
SEG Reversed () const
 Returns the center point of the line.
 
VECTOR2I Center () const
 

Static Public Member Functions

static SEG::ecoord Square (int a)
 

Public Attributes

VECTOR2I A
 
VECTOR2I B
 

Friends

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

Constructor & Destructor Documentation

◆ SEG()

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

Create 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

◆ AngleDegrees()

double SEG::AngleDegrees ( const SEG aOther) const

Determine the smallest angle between two segments (result in degrees)

Parameters
aOtherpoint to determine the orientation wrs to self
Returns
smallest angle between this and aOther (degrees)

◆ Collinear()

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

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

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

◆ Distance() [1/2]

int SEG::Distance ( const SEG aSeg) const

Compute minimum Euclidean distance to segment aSeg.

Parameters
aSegother segment
Returns
minimum distance

◆ Distance() [2/2]

int SEG::Distance ( const VECTOR2I aP) const

Compute minimum Euclidean distance to point aP.

Parameters
aPthe point
Returns
minimum distance

◆ Index()

int SEG::Index ( ) const
inline

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

Returns
index value

◆ Intersect()

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

Compute 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()

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

Compute 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()

int SEG::Length ( ) const
inline

Return the length (this).

Returns
length

◆ LineDistance()

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

Return 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()

VECTOR2I SEG::LineProject ( const VECTOR2I aP) const

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

Parameters
aPpoint to project
Returns
projected point

◆ NearestPoint() [1/2]

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

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

Returns
the nearest point

◆ NearestPoint() [2/2]

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

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

Returns
the nearest point

◆ ParallelSeg()

SEG SEG::ParallelSeg ( const VECTOR2I aP) const

Compute a segment parallel to this one, passing through point aP.

Parameters
aPPoint through which the new segment will pass
Returns
SEG parallel to this passing through point aP

◆ PerpendicularSeg()

SEG SEG::PerpendicularSeg ( const VECTOR2I aP) const

Compute a segment perpendicular to this one, passing through point aP.

Parameters
aPPoint through which the new segment will pass
Returns
SEG perpendicular to this passing through point aP

◆ ReflectPoint()

const VECTOR2I SEG::ReflectPoint ( const VECTOR2I aP) const

Reflect a point using this segment as axis.

Returns
the reflected point

◆ Side()

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

Determine 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: