18 #ifndef __H__OCULAR_MATH_LINE_SEGMENT_2D__H__
19 #define __H__OCULAR_MATH_LINE_SEGMENT_2D__H__
21 #include "Math/MathCommon.hpp"
22 #include "Math/Equality.hpp"
23 #include "Math/Vector2.hpp"
72 m_Length =
static_cast<T
>(0);
73 m_LengthSquared =
static_cast<T
>(0);
81 Vector2<T>
const& getA()
const
86 Vector2<T>
const& getB()
const
91 void setA(Vector2<T>
const& a)
97 void setB(Vector2<T>
const& b)
116 return m_LengthSquared;
133 LineSegmentSide result;
134 const T value = ((m_B.x - m_A.x) * (point.y - m_A.y)) - ((m_B.y - m_A.y) * (point.x - m_A.x));
142 result = (value < static_cast<T>(0)) ? RightOfSegment : LeftOfSegment;
160 if(IsZero<T>(m_LengthSquared))
171 const T t = pointToA.
dot(bToA) / m_LengthSquared;
173 if(t < static_cast<T>(0))
177 else if(t > static_cast<T>(1))
183 const Vector2<T> projection = m_A + ((m_B - m_A) * t);
200 m_LengthSquared = m_Length * m_Length;
215 typedef LineSegment2D<float> LineSegment2Df;
216 typedef LineSegment2D<double> LineSegment2Dd;
T getLength() const
Definition: Vector2.hpp:199
T const & getLengthSquared() const
Definition: LineSegment2D.hpp:114
Definition: LineSegment2D.hpp:52
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
LineSegmentSide whichSide(Vector2< T > const &point) const
Definition: LineSegment2D.hpp:131
T const & getLength() const
Definition: LineSegment2D.hpp:106
LineSegment2D(Vector2< T > const &a, Vector2< T > const &b)
Definition: LineSegment2D.hpp:62
Definition: Vector2.hpp:44
T dot(Vector2< T > const &rhs) const
Definition: Vector2.hpp:254
T distanceTo(Vector2< T > const &point) const
Definition: LineSegment2D.hpp:156