diff --git a/include/math/vector2d.h b/include/math/vector2d.h index 764534add9..b9ca1d22ce 100644 --- a/include/math/vector2d.h +++ b/include/math/vector2d.h @@ -358,6 +358,19 @@ VECTOR2& VECTOR2::operator-=( const T& aScalar ) template VECTOR2 VECTOR2::Rotate( double aAngle ) const { + // fast calculation of some rotations, very frequently found + if( aAngle == 0.0 ) + return VECTOR2 ( T( x ), T( y ) ); + + if( aAngle == 90.0 ) + return VECTOR2 ( T( -y ), T( x ) ); + + if( aAngle == -90.0 ) + return VECTOR2 ( T( y ), T( -x ) ); + + if( aAngle == 180.0 || aAngle == -180.0 ) + return VECTOR2 ( T( -x ), T( -y ) ); + double sa = sin( aAngle ); double ca = cos( aAngle );