Ocular Engine
Ocular::Math::LineSegment2D< T > Class Template Reference

#include <LineSegment2D.hpp>

Public Member Functions

 LineSegment2D (Vector2< T > const &a, Vector2< T > const &b)
 
Vector2< T > const & getA () const
 
Vector2< T > const & getB () const
 
void setA (Vector2< T > const &a)
 
void setB (Vector2< T > const &b)
 
T const & getLength () const
 
T const & getLengthSquared () const
 
LineSegmentSide whichSide (Vector2< T > const &point) const
 
distanceTo (Vector2< T > const &point) const
 

Protected Member Functions

void updateLength ()
 

Detailed Description

template<typename T>
class Ocular::Math::LineSegment2D< T >

A 2D line segment composed of two endpoints: A and B.

Constructor & Destructor Documentation

template<typename T >
Ocular::Math::LineSegment2D< T >::LineSegment2D ( Vector2< T > const &  a,
Vector2< T > const &  b 
)
inline

Creates a new line segment with the given end points.

Parameters
[in]a
[in]b

Member Function Documentation

template<typename T >
T Ocular::Math::LineSegment2D< T >::distanceTo ( Vector2< T > const &  point) const
inline

Calculates the minimum distance from the point to the line segment. This distance is in relation whichever point on the segment is closest to the point.

Parameters
[in]point
Returns
Minimum distance to the point from the line segment.
template<typename T >
T const& Ocular::Math::LineSegment2D< T >::getLength ( ) const
inline

Returns the length of the line segment.

template<typename T >
T const& Ocular::Math::LineSegment2D< T >::getLengthSquared ( ) const
inline

Returns the squared length of the line segment.

template<typename T >
LineSegmentSide Ocular::Math::LineSegment2D< T >::whichSide ( Vector2< T > const &  point) const
inline

Calculates which side of the line segment the point lies.

This can be visualized as standing on A and looking torwards B.

If the return value is -1, then the point is to the right of the line. If the return value is +1, then the point is to the left of the line. If the reutrn value is 0, then the point is on the line.

Parameters
[in]point
Returns
Which side the point is on: left (+1), right (-1), on the line (0).

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