Sign in to follow this  
freeworld

calculate the angle to face towards a point (2D)

Recommended Posts

How would I calculate the angle one object would have to be at to face annother object, in 2D. everything I've searched suggested that the this would do it.... atan2( y2-y1, x2-x1); but it just keep returning values ranging from -1.3 to 0.01... and so forth wich do seem to be usefull. I thought maybe they were in radians so I converted to degrees but it didn't make any notice difference to put it in the range of 0-360 or even -180 - 180; any help on this would be most appreciated.

Share this post


Link to post
Share on other sites
First things first:
1) What language? C++?
2) What does your radians to degrees conversion look like?
3) Post the surrounding code (in [source] code here [/source] tags, please)

How do you know it isn't right? Have you validated the values by hand, or are you using them to draw something that doesn't look right?



Share this post


Link to post
Share on other sites
[quote]Original post by jouley
First things first:
1) What language? C++?
2) What does your radians to degrees conversion look like?
3) Post the surrounding code (in
 code here 
tags, please)

How do you know it isn't right? Have you validated the values by hand, or are you using them to draw something that doesn't look right?[/quote]

figured it out, I was converting radians to radians making things really really small.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this