2D line segment - Double More...
#include <line_segment.h>
Public Member Functions | |
CL_LineSegment2d () | |
CL_LineSegment2d (const CL_Vec2< double > &point_p, const CL_Vec2< double > &point_q) | |
CL_LineSegment2d (const CL_LineSegment2x< double > ©) | |
Attributes | |
CL_Vec2< double > | get_midpoint () const |
Get the midpoint of this line. | |
double | point_distance (const CL_Vec2< double > &point) |
Return the distance from a point to a line. | |
bool | collinear (const CL_LineSegment2x< double > &second) const |
Return true if two line segments are collinear. (All points are on the same line.). | |
bool | intersects (const CL_LineSegment2x< double > &second, bool collinear_intersect) const |
Return true if two line segments intersect. | |
CL_Vec2< double > | get_intersection (const CL_LineSegment2x< double > &second, bool &intersect) const |
Return the intersection point of two lines. | |
double | point_right_of_line (const CL_Vec2< double > &point) const |
Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B. | |
CL_Vec2< double > | normal () const |
Return the normal vector of the line from point A to point B. | |
Operations | |
CL_LineSegment2x< double > & | clip (const CL_Rectx< double > &rect, bool &clipped) |
Clip this line to a rectangle. | |
Operators | |
bool | operator== (const CL_LineSegment2x< double > &line) const |
== operator. | |
bool | operator!= (const CL_LineSegment2x< double > &line) const |
!= operator. | |
Public Attributes | |
CL_Vec2< double > | p |
Start point on the line. | |
CL_Vec2< double > | q |
2D line segment - Double
A line segment has a start point and an end point
CL_LineSegment2d::CL_LineSegment2d | ( | ) | [inline] |
CL_LineSegment2d::CL_LineSegment2d | ( | const CL_LineSegment2x< double > & | copy | ) | [inline] |
CL_LineSegment2d::CL_LineSegment2d | ( | const CL_Vec2< double > & | point_p, | |
const CL_Vec2< double > & | point_q | |||
) | [inline] |
CL_LineSegment2x<double >& CL_LineSegment2x< double >::clip | ( | const CL_Rectx< double > & | rect, | |
bool & | clipped | |||
) | [inherited] |
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 CL_LineSegment2x< double >::collinear | ( | const CL_LineSegment2x< double > & | second | ) | const [inherited] |
Return true if two line segments are collinear. (All points are on the same line.).
second | = The second line to check with |
CL_Vec2<double > CL_LineSegment2x< double >::get_intersection | ( | const CL_LineSegment2x< double > & | second, | |
bool & | intersect | |||
) | const [inherited] |
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 |
CL_Vec2<double > CL_LineSegment2x< double >::get_midpoint | ( | ) | const [inline, inherited] |
Get the midpoint of this line.
bool CL_LineSegment2x< double >::intersects | ( | const CL_LineSegment2x< double > & | second, | |
bool | collinear_intersect | |||
) | const [inherited] |
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. |
CL_Vec2<double > CL_LineSegment2x< double >::normal | ( | ) | const [inherited] |
Return the normal vector of the line from point A to point B.
When using CL_Vec2i, the vector is an 8 bit fraction (multiplied by 256)
bool CL_LineSegment2x< double >::operator!= | ( | const CL_LineSegment2x< double > & | line | ) | const [inline, inherited] |
!= operator.
bool CL_LineSegment2x< double >::operator== | ( | const CL_LineSegment2x< double > & | line | ) | const [inline, inherited] |
== operator.
double CL_LineSegment2x< double >::point_distance | ( | const CL_Vec2< double > & | point | ) | [inherited] |
Return the distance from a point to a line.
point | = The point. |
double CL_LineSegment2x< double >::point_right_of_line | ( | const CL_Vec2< double > & | point | ) | const [inline, inherited] |
Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B.
point | = The point |
CL_Vec2<double > CL_LineSegment2x< double >::p [inherited] |
Start point on the line.
CL_Vec2<double > CL_LineSegment2x< double >::q [inherited] |