2D line segment - Integer More...

#include <line_segment.h>

+ Inheritance diagram for clan::LineSegment2:

Public Member Functions

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

Public Attributes

Vec2< int > p
 Start point on the line. More...
 
Vec2< int > q
 

Detailed Description

2D line segment - Integer

A line segment has a start point and an end point

Member Function Documentation

LineSegment2x<int >& clan::LineSegment2x< int >::clip ( const 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 clan::LineSegment2x< int >::collinear ( const 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
Vec2<int > clan::LineSegment2x< int >::get_intersection ( const LineSegment2x< int > &  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
Vec2<int > clan::LineSegment2x< int >::get_midpoint ( ) const
inlineinherited

Get the midpoint of this line.

Returns
The midpoint

References clan::LineSegment2x< Type >::p, and clan::LineSegment2x< Type >::q.

bool clan::LineSegment2x< int >::intersects ( const 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
Vec2<int > clan::LineSegment2x< int >::normal ( ) const
inherited

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)

Returns
The normal vector
bool clan::LineSegment2x< int >::operator!= ( const LineSegment2x< int > &  line) const
inlineinherited
bool clan::LineSegment2x< int >::operator== ( const LineSegment2x< int > &  line) const
inlineinherited
int clan::LineSegment2x< int >::point_distance ( const Vec2< int > &  point)
inherited

Return the distance from a point to a line.

Parameters
point= The point.
int clan::LineSegment2x< int >::point_right_of_line ( const Vec2< int > &  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)

References clan::LineSegment2x< Type >::p, clan::LineSegment2x< Type >::q, clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

Member Data Documentation

Vec2<int > clan::LineSegment2x< int >::p
inherited

Start point on the line.

Vec2<int > clan::LineSegment2x< int >::q
inherited

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