[gameprogrammer] Re: Diff Between 2 Angles

  • From: Stephen <stephen@xxxxxxxxxxxxxxxxxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Wed, 28 Sep 2005 21:01:02 +0100

I've got a really simple problem that I'm almost ashamed to ask about! I've written a 3D pseudo-realtime strategy game called Lazer Squad 3D (www.carlylesmith.karoo.net/lazersquad3d/). One problem I always think I've solved, but then comes back to bite me, is how to get the difference between two angles. This seems easy on the face of it, but then along comes two angles and my formula gets it all wrong. (This is degrees, BTW, not rads).

The main problem is when dealing with negative angles, angles > 360, and also getting the shortest distance (i.e. not the long way round). For example, the difference between -359 and 359 should be 2 degrees. The difference between 90 and -270 should be zero. Etc.. etc.. Can anyone help please?

Thanks in advance,

Steve Smith





---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: