A two dimensional line segment. More...
#include <ignition/math/Line2.hh>
Public Member Functions | |
Line2 (const math::Vector2< T > &_ptA, const math::Vector2< T > &_ptB) | |
Constructor. | |
Line2 (double _x1, double _y1, double _x2, double _y2) | |
Constructor. | |
bool | Collinear (const math::Line2< T > &_line, double _epsilon=1e-6) const |
Check if the given line is collinear with this line. | |
bool | Collinear (const math::Vector2< T > &_pt, double _epsilon=1e-6) const |
Check if the given point is collinear with this line. | |
double | CrossProduct (const Line2< T > &_line) const |
Return the cross product of this line and the given line. | |
double | CrossProduct (const Vector2< T > &_pt) const |
Return the cross product of this line and the given point. | |
bool | Intersect (const Line2< T > &_line, double _epsilon=1e-6) const |
Check if this line intersects the given line segment. | |
bool | Intersect (const Line2< T > &_line, math::Vector2< T > &_pt, double _epsilon=1e-6) const |
Check if this line intersects the given line segment. | |
T | Length () const |
Get the length of the line. | |
bool | OnSegment (const math::Vector2< T > &_pt, double _epsilon=1e-6) const |
Return whether the given point is on this line segment. | |
bool | operator!= (const Line2< T > &_line) const |
Inequality operator. | |
bool | operator== (const Line2< T > &_line) const |
Equality operator. | |
math::Vector2< T > | operator[] (size_t _index) const |
Get the start or end point. | |
bool | Parallel (const math::Line2< T > &_line, double _epsilon=1e-6) const |
Check if the given line is parallel with this line. | |
void | Set (const math::Vector2< T > &_ptA, const math::Vector2< T > &_ptB) |
Set the start and end point of the line segment. | |
void | Set (double _x1, double _y1, double _x2, double _y2) |
Set the start and end point of the line segment. | |
double | Slope () const |
Get the slope of the line. | |
bool | Within (const math::Vector2< T > &_pt, double _epsilon=1e-6) const |
Check if the given point is between the start and end points of the line segment. | |
A two dimensional line segment.
The line is defined by a start and end point.
|
inline |
Constructor.
[in] | _ptA | Start point of the line segment |
[in] | _ptB | End point of the line segment |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Set().
|
inline |
Constructor.
[in] | _x1 | X coordinate of the start point. |
[in] | _y1 | Y coordinate of the start point. |
[in] | _x2 | X coordinate of the end point. |
[in] | _y2 | Y coordinate of the end point. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Set().
|
inline |
Check if the given line is collinear with this line.
This is the AND of Parallel and Intersect.
[in] | _line | The line to check. |
[in] | _epsilon | The error bounds within which the collinear check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Intersect(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Parallel().
|
inline |
Check if the given point is collinear with this line.
[in] | _pt | The point to check. |
[in] | _epsilon | The error bounds within which the collinear check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::CrossProduct().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::OnSegment().
|
inline |
Return the cross product of this line and the given line.
Give 'a' as this line and 'b' as given line, the equation is: (a.start.x - a.end.x) * (b.start.y - b.end.y) - (a.start.y - a.end.y) * (b.start.x - b.end.x)
[in] | _line | Line for the cross product computation. |
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Collinear(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Intersect(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Parallel().
|
inline |
Return the cross product of this line and the given point.
Given 'a' and 'b' as the start and end points, the equation is:
[in] | _pt | Point for the cross product computation. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::X(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Y().
|
inline |
Check if this line intersects the given line segment.
[in] | _line | The line to check for intersection. |
[in] | _epsilon | The error bounds within which the intersection check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Intersect().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Collinear(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Intersect(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Triangle< T >::Intersects().
|
inline |
Check if this line intersects the given line segment.
The point of intersection is returned in the _result parameter.
[in] | _line | The line to check for intersection. |
[out] | _pt | The point of intersection. This value is only valid if the return value is true. |
[in] | _epsilon | The error bounds within which the intersection check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::CrossProduct(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Within(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::X(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Y().
|
inline |
Get the length of the line.
|
inline |
Return whether the given point is on this line segment.
[in] | _pt | Point to check. |
[in] | _epsilon | The error bounds within which the OnSegment check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Collinear(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Within().
|
inline |
Inequality operator.
[in] | _line | Line to compare for inequality. |
|
inline |
Equality operator.
[in] | _line | Line to compare for equality. |
|
inline |
Get the start or end point.
[in] | _index | 0 = start point, 1 = end point. The _index is clamped to the range [0, 1] |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ONE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.
|
inline |
Check if the given line is parallel with this line.
[in] | _line | The line to check. |
[in] | _epsilon | The error bounds within which the parallel check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::CrossProduct().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Collinear().
|
inline |
Set the start and end point of the line segment.
[in] | _ptA | Start point of the line segment |
[in] | _ptB | End point of the line segment |
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Line2(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Line2().
|
inline |
Set the start and end point of the line segment.
[in] | _x1 | X coordinate of the start point. |
[in] | _y1 | Y coordinate of the start point. |
[in] | _x2 | X coordinate of the end point. |
[in] | _y2 | Y coordinate of the end point. |
|
inline |
Get the slope of the line.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::NAN_D.
|
inline |
Check if the given point is between the start and end points of the line segment.
This does not imply that the point is on the segment.
[in] | _pt | Point to check. |
[in] | _epsilon | The error bounds within which the within check will return true. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::X(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector2< T >::Y().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::Intersect(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Line2< T >::OnSegment().