2D line segment More...
#include <line_segment.h>
Public Member Functions | |
LineSegment2x () | |
LineSegment2x (const LineSegment2x< Type > ©) | |
LineSegment2x (const Vec2< Type > &point_p, const Vec2< Type > &point_q) | |
LineSegment2x< Type > & | clip (const Rectx< Type > &rect, bool &clipped) |
Clip this line to a rectangle. More... | |
bool | collinear (const LineSegment2x< Type > &second) const |
Return true if two line segments are collinear. (All points are on the same line.) More... | |
Vec2< Type > | intersection (const LineSegment2x< Type > &second, bool &intersect) const |
Return the intersection point of two lines. More... | |
bool | intersects (const LineSegment2x< Type > &second, bool collinear_intersect) const |
Return true if two line segments intersect. More... | |
Vec2< Type > | midpoint () const |
Get the midpoint of this line. More... | |
Vec2< Type > | normal () const |
Return the normal vector of the line from point A to point B. More... | |
bool | operator!= (const LineSegment2x< Type > &line) const |
!= operator. More... | |
LineSegment2x< Type > & | operator= (const LineSegment2x< Type > ©) |
= operator. More... | |
bool | operator== (const LineSegment2x< Type > &line) const |
== operator. More... | |
Type | point_distance (const Vec2< Type > &point) |
Return the distance from a point to a line. More... | |
Type | point_right_of_line (const Vec2< Type > &point) const |
Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B. More... | |
Public Attributes | |
Vec2< Type > | p |
Start point on the line. More... | |
Vec2< Type > | q |
2D line segment
A line segment has a start point and an end point
These line templates are defined for: int (LineSegment2i), float (LineSegment2f), double (LineSegment2d)
|
inline |
|
inline |
|
inline |
LineSegment2x<Type>& uicore::LineSegment2x< Type >::clip | ( | const Rectx< Type > & | rect, |
bool & | clipped | ||
) |
Clip this line to a rectangle.
If clipping was not successful, this object is undefined
rect | = Rectangle to clip to |
clipped | = On Return: true if the line could be clipped, false if line exists outside the rectangle |
bool uicore::LineSegment2x< Type >::collinear | ( | const LineSegment2x< Type > & | second | ) | const |
Return true if two line segments are collinear. (All points are on the same line.)
second | = The second line to check with |
Vec2<Type> uicore::LineSegment2x< Type >::intersection | ( | const LineSegment2x< Type > & | second, |
bool & | intersect | ||
) | const |
Return the intersection point of two lines.
second | = Second line. |
intersect | = On Return: The intercept. If the lines are parallel, this contains this line's first point |
bool uicore::LineSegment2x< Type >::intersects | ( | const LineSegment2x< Type > & | second, |
bool | collinear_intersect | ||
) | const |
Return true if two line segments intersect.
second | = Second line. |
collinear_intersect | = true if a collision is reported when all points are on the same line. |
|
inline |
Get the midpoint of this line.
Vec2<Type> uicore::LineSegment2x< Type >::normal | ( | ) | const |
Return the normal vector of the line from point A to point B.
When using Vec2i, the vector is an 8 bit fraction (multiplied by 256)
|
inline |
!= operator.
|
inline |
= operator.
|
inline |
== operator.
Type uicore::LineSegment2x< Type >::point_distance | ( | const Vec2< Type > & | point | ) |
Return the distance from a point to a line.
point | = The point. |
|
inline |
Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B.
point | = The point |
Vec2<Type> uicore::LineSegment2x< Type >::p |
Start point on the line.
Vec2<Type> uicore::LineSegment2x< Type >::q |