Commit 84239542 authored by Maciej Suminski's avatar Maciej Suminski

Fixed code formatting.

parent 6d088b43
...@@ -65,8 +65,8 @@ std::ostream& operator<<( std::ostream& stream, const VECTOR2<T>& vector ); ...@@ -65,8 +65,8 @@ std::ostream& operator<<( std::ostream& stream, const VECTOR2<T>& vector );
* Class VECTOR2 * Class VECTOR2
* defines a general 2D-vector/point. * defines a general 2D-vector/point.
* *
* This class uses templates to be universal. Several operators are provided to help easy implementing * This class uses templates to be universal. Several operators are provided to help
* of linear algebra equations. * easy implementing of linear algebra equations.
* *
*/ */
template <class T = int> template <class T = int>
...@@ -153,7 +153,8 @@ public: ...@@ -153,7 +153,8 @@ public:
* the side of the line at which we are (negative = left) * the side of the line at which we are (negative = left)
* @return the distance * @return the distance
*/ */
T LineDistance( const VECTOR2<T>& aStart, const VECTOR2<T>& aEnd, bool aDetermineSide = false ) const; T LineDistance( const VECTOR2<T>& aStart, const VECTOR2<T>& aEnd,
bool aDetermineSide = false ) const;
/** /**
* Function ClosestSegmentPoint * Function ClosestSegmentPoint
...@@ -368,19 +369,21 @@ VECTOR2<T> VECTOR2<T>::LineProjection( const VECTOR2<T>& aA, const VECTOR2<T>& a ...@@ -368,19 +369,21 @@ VECTOR2<T> VECTOR2<T>::LineProjection( const VECTOR2<T>& aA, const VECTOR2<T>& a
template <class T> template <class T>
T VECTOR2<T>::LineDistance( const VECTOR2<T>& aStart, const VECTOR2<T>& aEnd, bool aDetermineSide ) const T VECTOR2<T>::LineDistance( const VECTOR2<T>& aStart, const VECTOR2<T>& aEnd,
bool aDetermineSide ) const
{ {
extended_type a = aStart.y - aEnd.y; extended_type a = aStart.y - aEnd.y;
extended_type b = aEnd.x - aStart.x; extended_type b = aEnd.x - aStart.x;
extended_type c = -a * aStart.x - b * aStart.y; extended_type c = -a * aStart.x - b * aStart.y;
T dist = ( a * x + b * y + c ) / sqrt( a * a + b * b ); T dist = ( a * x + b * y + c ) / sqrt( a * a + b * b );
return aDetermineSide ? dist : abs(dist); return aDetermineSide ? dist : abs( dist );
} }
template <class T> template <class T>
VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart, const VECTOR2<T>& aEnd ) const VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart,
const VECTOR2<T>& aEnd ) const
{ {
VECTOR2<T> d = (aEnd - aStart); VECTOR2<T> d = (aEnd - aStart);
extended_type l_squared = (extended_type) d.x * d.x + (extended_type) d.y * d.y; extended_type l_squared = (extended_type) d.x * d.x + (extended_type) d.y * d.y;
...@@ -410,7 +413,7 @@ VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart, const VECT ...@@ -410,7 +413,7 @@ VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart, const VECT
/*VECTOR2<T> proj = aStart + VECTOR2<T> ( ( t * (extended_type) d.x / l_squared ), /*VECTOR2<T> proj = aStart + VECTOR2<T> ( ( t * (extended_type) d.x / l_squared ),
( t * ( extended_type) d.y / l_squared ) );*/ ( t * ( extended_type) d.y / l_squared ) );*/
VECTOR2<T> proj = aStart + VECTOR2<T> ( (T)xp, (T) yp ); VECTOR2<T> proj = aStart + VECTOR2<T> ( (T) xp, (T) yp );
return proj; return proj;
} }
...@@ -612,6 +615,7 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector ) ...@@ -612,6 +615,7 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector )
return aStream; return aStream;
} }
/* Default specializations */ /* Default specializations */
typedef VECTOR2<double> VECTOR2D; typedef VECTOR2<double> VECTOR2D;
typedef VECTOR2<int> VECTOR2I; typedef VECTOR2<int> VECTOR2I;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment