ClanLib  2.3.7
Public Member Functions | Public Attributes | List of all members
CL_LineSegment2f Class Reference

2D line segment - Float More...

#include <line_segment.h>

Inheritance diagram for CL_LineSegment2f:
Inheritance graph
[legend]

Public Member Functions

 CL_LineSegment2f ()
 
 CL_LineSegment2f (const CL_LineSegment2x< float > &copy)
 
 CL_LineSegment2f (const CL_Vec2< float > &point_p, const CL_Vec2< float > &point_q)
 
Attributes
CL_Vec2< float > get_midpoint () const
 Get the midpoint of this line. More...
 
float point_distance (const CL_Vec2< float > &point)
 Return the distance from a point to a line. More...
 
bool collinear (const CL_LineSegment2x< float > &second) const
 Return true if two line segments are collinear. (All points are on the same line.) More...
 
bool intersects (const CL_LineSegment2x< float > &second, bool collinear_intersect) const
 Return true if two line segments intersect. More...
 
CL_Vec2< float > get_intersection (const CL_LineSegment2x< float > &second, bool &intersect) const
 Return the intersection point of two lines. More...
 
float point_right_of_line (const CL_Vec2< float > &point) const
 Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B. More...
 
CL_Vec2< float > normal () const
 Return the normal vector of the line from point A to point B. More...
 
Operations
CL_LineSegment2x< float > & clip (const CL_Rectx< float > &rect, bool &clipped)
 Clip this line to a rectangle. More...
 
Operators
bool operator== (const CL_LineSegment2x< float > &line) const
 == operator. More...
 
bool operator!= (const CL_LineSegment2x< float > &line) const
 != operator. More...
 

Public Attributes

CL_Vec2< float > p
 Start point on the line. More...
 
CL_Vec2< float > q
 

Detailed Description

2D line segment - Float

A line segment has a start point and an end point

Constructor & Destructor Documentation

CL_LineSegment2f::CL_LineSegment2f ( )
inline
CL_LineSegment2f::CL_LineSegment2f ( const CL_LineSegment2x< float > &  copy)
inline
CL_LineSegment2f::CL_LineSegment2f ( const CL_Vec2< float > &  point_p,
const CL_Vec2< float > &  point_q 
)
inline

Member Function Documentation

CL_LineSegment2x<float >& CL_LineSegment2x< float >::clip ( const CL_Rectx< float > &  rect,
bool &  clipped 
)
inherited

Clip this line to a rectangle.

If clipping was not successful, this object is undefined

Parameters
rect= Rectangle to clip to
clipped= On Return: true if the line could be clipped, false if line exists outside the rectangle
Returns
reference to this object
bool CL_LineSegment2x< float >::collinear ( const CL_LineSegment2x< float > &  second) const
inherited

Return true if two line segments are collinear. (All points are on the same line.)

Parameters
second= The second line to check with
Returns
true = They are collinear
CL_Vec2<float > CL_LineSegment2x< float >::get_intersection ( const CL_LineSegment2x< float > &  second,
bool &  intersect 
) const
inherited

Return the intersection point of two lines.

Parameters
second= Second line.
intersect= On Return: The intercept. If the lines are parallel, this contains this line's first point
Returns
true if the lines intersect, false if the lines are parallel
CL_Vec2<float > CL_LineSegment2x< float >::get_midpoint ( ) const
inlineinherited

Get the midpoint of this line.

Returns
The midpoint
bool CL_LineSegment2x< float >::intersects ( const CL_LineSegment2x< float > &  second,
bool  collinear_intersect 
) const
inherited

Return true if two line segments intersect.

Parameters
second= Second line.
collinear_intersect= true if a collision is reported when all points are on the same line.
Returns
true = Intersects
CL_Vec2<float > CL_LineSegment2x< float >::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)

Returns
The normal vector
bool CL_LineSegment2x< float >::operator!= ( const CL_LineSegment2x< float > &  line) const
inlineinherited

!= operator.

bool CL_LineSegment2x< float >::operator== ( const CL_LineSegment2x< float > &  line) const
inlineinherited

== operator.

float CL_LineSegment2x< float >::point_distance ( const CL_Vec2< float > &  point)
inherited

Return the distance from a point to a line.

Parameters
point= The point.
float CL_LineSegment2x< float >::point_right_of_line ( const CL_Vec2< float > &  point) const
inlineinherited

Return [<0, 0, >0] if the Point P is right, on or left of the line trough A,B.

Parameters
point= The point
Returns
Value representing - left (>0), centre (=0), or right (<0)

Member Data Documentation

CL_Vec2<float > CL_LineSegment2x< float >::p
inherited

Start point on the line.

CL_Vec2<float > CL_LineSegment2x< float >::q
inherited

The documentation for this class was generated from the following file: