Jump to content
  • Advertisement
Sign in to follow this  
MrMark

Working out delta theta to obtain a particular angle.

This topic is 2235 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys

I've been spending an embarrassing amount of time on a fairly simple problem. In my 2D world each entity has an orientation (theta) which represents the direction it is facing.

Given its current orientation and a target orientation, I want to find out:

The change in theta required to achieve the target orientation, rotating clockwise.
The change in theta required to acheive the target orientation, rotating counter clockwise.

the closest I got was abs(current - target) for clockwise rotations, and -abs(current - target), for counter clockwise rotations. But that falls apart when you go past 0.

This should be simple, but i can't seem to work it out.


Please help :)

Share this post


Link to post
Share on other sites
Advertisement
If I understand your question, start with delta = target - current. If you want a clockwise rotation, and delta is negative add 360 degrees to delta. If you want a counterclockwise rotation and delta is positive subtract 360 degrees.

Share this post


Link to post
Share on other sites

If I understand your question, start with delta = target - current. If you want a clockwise rotation, and delta is negative add 360 degrees to delta. If you want a counterclockwise rotation and delta is positive subtract 360 degrees.


It works XD,

Thanks for your help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!