Core 1.0
Public Member Functions | Static Public Attributes | List of all members
Line2 Class Reference

Lines in the plane. More...

#include <segment.h>

Inheritance diagram for Line2:
Segment2

Public Member Functions

 Line2 ()
 Empty.
 
 Line2 (const Vector2 &, const Vector2 &)
 Creates a line in the plane. More...
 
 Line2 (const Segment2 &)
 Creates a line from a segment. More...
 
Vector2 Vertex (int) const
 Return one of the vertices of the line.
 
Vector2Vertex (int)
 Return one of the vertices of the line.
 
bool Intersection (const Line2 &, Vector2 &) const
 Compute the intersection between two lines. More...
 
bool Intersection (const Segment2 &, Vector2 &) const
 Compute the intersection between a line and a segment. More...
 
Vector2 Symmetry (const Vector2 &) const
 Compute the point symmetric to the line. More...
 
Box2 Symmetry (const Box2 &) const
 Compute the box bounding the box symmetric to the line. More...
 
Circle2 Symmetry (const Circle2 &) const
 Compute the circle symmetric to the line. More...
 
double R (const Vector2 &) const
 Compute the squared distance to the line. More...
 
bool IsLeftOrOn (const Vector2 &, const double &=0.0) const
 Compute the position of a point with respect to a line. More...
 
bool IsRightOrOn (const Vector2 &, const double &=0.0) const
 Compute the position of a point with respect to a line. More...
 
- Public Member Functions inherited from Segment2
 Segment2 ()
 Empty.
 
 Segment2 (const Vector2 &, const Vector2 &)
 Creates a planar segment given end vertices. More...
 
 Segment2 (const Segment &)
 Creates a planar segment given a three dimensional segment. More...
 
 ~Segment2 ()
 Empty.
 
Vector2 Vertex (int) const
 Return one of the end vertex of the axis.
 
Vector2Vertex (int)
 Return one of the end vertex of the axis.
 
Vector2 VertexAt (const double &) const
 Compute a point on the segment. More...
 
Vector2 Center () const
 Compute the center of the segment.
 
Vector2 GetAxis () const
 Returns the normalized axis vector.
 
Box2 GetBox () const
 Compute the bounding box of the segment.
 
Vector2 Orthogonal () const
 Compute an orthogonal vector to the segment. More...
 
void Translate (const Vector2 &)
 Translates a segment. More...
 
void Rotate (const Matrix2 &)
 Translates a segment. More...
 
void Scale (const double &)
 Uniformly scales a segment. More...
 
double Length () const
 Return axis length.
 
void Draw (QGraphicsScene &, const QPen &=QPen()) const
 Draw a segment. More...
 
void DrawArrow (QGraphicsScene &, const double &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draw a segment as an arrow. More...
 
double R (const Vector2 &) const
 Compute the squared distance to the segment. More...
 
double R (const Vector2 &, double &) const
 Compute the squared distance to the axis edge characterized by its end points. More...
 
Vector2 Normal (const Vector2 &) const
 Compute the normal vector between a point and its projection onto the segment. More...
 
bool Intersect (const Segment2 &) const
 Test if two segments intersect. More...
 
bool IntersectOpen (const Segment2 &) const
 This functions tests if two segments intersect. More...
 
bool Intersection (const Segment2 &, Vector2 &) const
 Compute the intersection between two segments. More...
 

Static Public Attributes

static const Line2 X
 Horizontal.
 
static const Line2 Y
 Vertical.
 
- Static Public Attributes inherited from Segment2
static constexpr const double epsilon = 1e-8
 Epsilon value for intersection test.
 

Additional Inherited Members

- Static Public Member Functions inherited from Segment2
static Vector2 Intersect (const Vector2 &, const Vector2 &, const double, const double, const double=0.0)
 Compute the intersection between the line f(x)=y and a line such that f(a)=va and f(b)=vb, on the segment ab. More...
 
- Protected Attributes inherited from Segment2
Vector2 b = Vector2::X
 End vertices of the segment.
 

Detailed Description

Lines in the plane.

See also
Segment2

Constructor & Destructor Documentation

◆ Line2() [1/2]

Line2::Line2 ( const Vector2 a,
const Vector2 b 
)
inlineexplicit

Creates a line in the plane.

Parameters
a,bTwo points.

◆ Line2() [2/2]

Line2::Line2 ( const Segment2 s)
inlineexplicit

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.