All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Nimble::LineSegment2T< T > Class Template Reference

2D line segment More...

#include <Nimble/LineSegment2.hpp>

Public Member Functions

Vector2T< T > & begin ()
 Returns the first end point of the line segment.
 
const Vector2T< T > & begin () const
 Returns the first end point of the line segment.
 
Vector2T< T > directionNormalized () const
 Returns normalized direction of this line segment.
 
float distanceInfinite (const Vector2T< T > &point)
 Calculates the distance between this (infinite) line and a point. More...
 
Vector2T< T > & end ()
 Returns the second end point of the line segment.
 
const Vector2T< T > & end () const
 Returns the second end point of the line segment.
 
bool intersects (const LineSegment2T &that, Vector2T< T > *point=0) const
 Returns true if the two line segments intersect. More...
 
bool intersectsBezier (Vector2T< T > cp[4])
 Returns true if the line segment intersects with the given bezier curve.
 
bool intersectsInfinite (const LineSegment2T &that, Vector2T< T > *point) const
 Tests for intersection with a given line. More...
 
length () const
 Returns the length of the line segment.
 
 LineSegment2T ()
 Construct line segment object, without initializing its values.
 
 LineSegment2T (T x1, T y1, T x2, T y2)
 Initialize line segment from given coordinate values.
 
 LineSegment2T (const Vector2T< T > &p1, const Vector2T< T > &p2)
 Constructs a new line segment between two points.
 
bool operator== (const LineSegment2T &that) const
 Compares the end points of two line segments and returns true if they are equal.
 
bool pointMatch (const LineSegment2T &that) const
 Compares the given point against both end points and returns true if the point is equal to either one.
 

Detailed Description

template<typename T>
class Nimble::LineSegment2T< T >

2D line segment

Where lines are of infinite length, line segments have a finite length.

Member Function Documentation

template<typename T >
float Nimble::LineSegment2T< T >::distanceInfinite ( const Vector2T< T > &  point)
inline

Calculates the distance between this (infinite) line and a point.

Parameters
point2D point
Returns
Distance between a line and point
template<typename T >
bool Nimble::LineSegment2T< T >::intersects ( const LineSegment2T< T > &  that,
Vector2T< T > *  point = 0 
) const
inline

Returns true if the two line segments intersect.

Parameters
thatline segment to compare
[out]pointoptional intersection point
Returns
True if lines intersect
template<typename T >
bool Nimble::LineSegment2T< T >::intersectsInfinite ( const LineSegment2T< T > &  that,
Vector2T< T > *  point 
) const
inline

Tests for intersection with a given line.

Parameters
thatline to test against
[out]point(optional) intersection point if found
Returns
True if lines intersect