Circular movement - eliminating speed ups near Y = 0

Posted by Fibericon on Game Development See other posts from Game Development or by Fibericon
Published on 2012-09-21T13:08:13Z Indexed on 2012/09/21 15:54 UTC
Read the original article Hit count: 190

Filed under:
|
|

I have a basic algorithm to rotate an enemy around a 200 unit radius circle with center 0. This is how I'm achieving that:

if (position.Y <= 0 && position.X > -200)
{
   position.X -= 2;
   position.Y = 0 - (float)Math.Sqrt((200 * 200) - (position.X * position.X));
}
else
{
   position.X += 2;
   position.Y = (float)Math.Sqrt((200 * 200) - (position.X * position.X));
}

It does work, and I've ensured that at no point does either X or Y equal NaN. However, when Y approaches 0, it seems to go significantly faster. This surprises me, because the Y values are locked to the X, which is being incremented by a steady amount. What can I do to smooth the speed?

© Game Development or respective owner

Related posts about XNA

Related posts about movement