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 );
* Class VECTOR2
* defines a general 2D-vector/point.
*
* This class uses templates to be universal. Several operators are provided to help easy implementing
* of linear algebra equations.
* This class uses templates to be universal. Several operators are provided to help
* easy implementing of linear algebra equations.
*
*/
template <class T = int>
......@@ -153,7 +153,8 @@ public:
* the side of the line at which we are (negative = left)
* @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
......@@ -368,19 +369,21 @@ VECTOR2<T> VECTOR2<T>::LineProjection( const VECTOR2<T>& aA, const VECTOR2<T>& a
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 b = aEnd.x - aStart.x;
extended_type c = -a * aStart.x - b * aStart.y;
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>
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);
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
/*VECTOR2<T> proj = aStart + VECTOR2<T> ( ( t * (extended_type) d.x / 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;
}
......@@ -612,6 +615,7 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector )
return aStream;
}
/* Default specializations */
typedef VECTOR2<double> VECTOR2D;
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