Core 1.0
Line2 Class Reference

Lines in the plane. More...

#include <segment.h>

Public Member Functions

 Line2 ()
 Direction.
 
 Line2 (const Vector2 &, const Vector2 &)
 Creates a line in the plane.
 
 Line2 (const Segment2 &)
 Creates a line from a segment.
 
Vector2 Point () const
 Return one of the vertices of the line.
 
Vector2 Direction () const
 Return the direction of the line.
 
bool Intersection (const Line2 &, Vector2 &) const
 Compute the intersection between two lines.
 
bool Intersection (const Segment2 &, Vector2 &) const
 Compute the intersection between a line and a segment.
 
Vector2 Symmetry (const Vector2 &) const
 Compute the point symmetric to the line.
 
Box2 Symmetry (const Box2 &) const
 Compute the box bounding the box symmetric to the line.
 
Circle2 Symmetry (const Circle2 &) const
 Compute the circle symmetric to the line.
 
void Translate (const Vector2 &)
 Translation.
 
double R (const Vector2 &) const
 Compute the squared distance to the line.
 
bool IsLeftOrOn (const Vector2 &, const double &=0.0) const
 Compute the position of a point with respect to a line.
 
bool IsRightOrOn (const Vector2 &, const double &=0.0) const
 Compute the position of a point with respect to a line.
 

Static Public Attributes

static const Line2 X
 Horizontal.
 
static const Line2 Y
 Vertical.
 

Protected Attributes

Vector2 n = Vector2::X
 Vertex.
 

Detailed Description

Lines in the plane.

Lines implicitly define half spaces in the plane. The corresponding positive half-space is in the direction orthogonal to the direction of the line.

See also
Segment2

Constructor & Destructor Documentation

◆ Line2() [1/3]

Line2::Line2 ( )
inline

Direction.

Empty

◆ Line2() [2/3]

Line2::Line2 ( const Vector2 & o,
const Vector2 & d )
explicit

Creates a line in the plane.

Parameters
oOrigin.
dDirection.

◆ Line2() [3/3]

Line2::Line2 ( const Segment2 & s)
explicit

Creates a line from a segment.

Parameters
sSegment.

Member Function Documentation

◆ Intersection() [1/2]

bool Line2::Intersection ( const Line2 & l,
Vector2 & p ) const

Compute the intersection between two lines.

Note that the algorithm is the same as for segments, except that the range of the intersection parameters is not checked.

Parameters
lOther line.
pIntersection point.

◆ Intersection() [2/2]

bool Line2::Intersection ( const Segment2 & e,
Vector2 & p ) const

Compute the intersection between a line and a segment.

Note that the algorithm is the same as for segments, except that the range of the intersection parameters is checked only for the segment.

Parameters
eSegment.
pIntersection point.

◆ IsLeftOrOn()

bool Line2::IsLeftOrOn ( const Vector2 & p,
const double & epsilon = 0.0 ) const

Compute the position of a point with respect to a line.

Parameters
pPoint
epsilonPrecision.

◆ IsRightOrOn()

bool Line2::IsRightOrOn ( const Vector2 & p,
const double & epsilon = 0.0 ) const

Compute the position of a point with respect to a line.

Parameters
pPoint
epsilonPrecision.

◆ R()

double Line2::R ( const Vector2 & p) const

Compute the squared distance to the line.

Parameters
pPoint.

◆ Symmetry() [1/3]

Box2 Line2::Symmetry ( const Box2 & box) const

Compute the box bounding the box symmetric to the line.

Parameters
boxThe box.

◆ Symmetry() [2/3]

Circle2 Line2::Symmetry ( const Circle2 & c) const

Compute the circle symmetric to the line.

Parameters
cCircle.

◆ Symmetry() [3/3]

Vector2 Line2::Symmetry ( const Vector2 & p) const

Compute the point symmetric to the line.

Parameters
pPoint.

◆ Translate()

void Line2::Translate ( const Vector2 & t)

Translation.

Parameters
tTranslation vector.