CL_LineSegment2 Class Reference
[clanCore Math]

2D line segment - Integer More...

#include <line_segment.h>

Inheritance diagram for CL_LineSegment2:

CL_LineSegment2x< int > List of all members.

Public Member Functions

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

Public Attributes

CL_Vec2< int > p
 Start point on the line.
CL_Vec2< int > q

Detailed Description

2D line segment - Integer

A line segment has a start point and an end point


Constructor & Destructor Documentation

CL_LineSegment2::CL_LineSegment2  )  [inline]
 

CL_LineSegment2::CL_LineSegment2 const CL_LineSegment2x< int > &  copy  )  [inline]
 

CL_LineSegment2::CL_LineSegment2 const CL_Vec2< int > &  point_p,
const CL_Vec2< int > &  point_q
[inline]
 


Member Function Documentation

CL_LineSegment2x<int >& CL_LineSegment2x< int >::clip const CL_Rectx< int > &  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< int >::collinear const CL_LineSegment2x< int >  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<int > CL_LineSegment2x< int >::get_intersection const CL_LineSegment2x< int >  second,
bool &  intersect
const [inherited]
 

Return the intersection point of two lines.

Parameters:
second = Second line.
dest_intercept = 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<int > CL_LineSegment2x< int >::get_midpoint  )  const [inline, inherited]
 

Get the midpoint of this line.

Returns:
The midpoint

bool CL_LineSegment2x< int >::intersects const CL_LineSegment2x< int >  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<int > CL_LineSegment2x< int >::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< int >::operator!= const CL_LineSegment2x< int > &  line  )  const [inline, inherited]
 

!= operator.

bool CL_LineSegment2x< int >::operator== const CL_LineSegment2x< int > &  line  )  const [inline, inherited]
 

== operator.

int CL_LineSegment2x< int >::point_distance const CL_Vec2< int > &  point  )  [inherited]
 

Return the distance from a point to a line.

Parameters:
point = The point.

int CL_LineSegment2x< int >::point_right_of_line CL_Vec2< int >  point  )  const [inline, inherited]
 

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<int > CL_LineSegment2x< int >::p [inherited]
 

Start point on the line.

CL_Vec2<int > CL_LineSegment2x< int >::q [inherited]
 


The documentation for this class was generated from the following file:
Generated on Thu Dec 3 02:39:38 2009 for ClanLib by  doxygen 1.4.6