Vector2 Rotate( Vector2 &vec,float Angle )
{
/*
cos -sin
sin cos
*/
// When the Angle is PI/2 (90 degrees), it doesn't return 0, we get 4.37114e-008
float Cos = cos(Angle);
float Sin = sin(Angle);
Vector2 rot = Vector2( Cos*vec.x - Sin*vec.y , Sin*vec.x + Cos*vec.y );
return rot;
}
// If i pass this vector
Vector2 vec = Vector2(0,1);
vec = Rotate(vec,PI*.5f);
// The answer should be '(1,0)'
// But i ACTUALLY get '(-1,-4.37114e-008)'....
/* Anyone know what's going on here, is sin and cos incapable of returning 0? */
Edited by Muzzy A, 18 May 2012 - 11:22 PM.
This topic is locked






