Problem with small angles?

Topics: User Forum
Aug 13, 2011 at 1:28 AM

Hello all. I'm trying to get movement just right for an asteroids-type ship(overhead, no gravity), but I've noticed that angles near multiples of 90 degrees don't quite work the way I'd like them to.

Specifically, this means that if I rotate the ship 10 degrees(past zero) and then move it 'forward', it will travel horizontally instead of at the proper angle.

Any ideas on how I could fix this?

This is how I'm moving the ship:

                float dx = 0.2f * (float)Math.Cos(((float)ship.rotation) * Math.PI / 180.0);
                float dy = 0.2f * (float)Math.Sin(((float)ship.rotation) * Math.PI / 180.0);
                Microsoft.Xna.Framework.Vector2 vec = ship.body.LinearVelocity + new Vector2(dx,dy).xna;
                ship.body.LinearVelocity = vec;

Thank you.