Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411613 Posts in 69390 Topics- by 58447 Members - Latest Member: sinsofsven

May 09, 2024, 03:35:07 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Working out the angle of rotation
Pages: [1]
Print
Author Topic: Working out the angle of rotation  (Read 1276 times)
desdinova
Level 0
***



View Profile
« on: December 01, 2009, 02:48:35 AM »

Im trying to make a basic top-Down game where the player rotates to face the direction that it is moving, like you would expect to see in asteroids or GTA 1.  Pretty easy stuff hey...
Regardless, I am getting really stuck with what I need to do to get the angle that I need to rotate my character.  I've been digging through all my old maths books and the internet but just can't seem to get a clear answer on what exactly I need to do and my experimentation are going quite badly.  I would like to give you more specifics on where I get stuck but unfortunately it seems to be "all of it"  Cry
Logged
Alex May
...is probably drunk right now.
Level 10
*


hen hao wan


View Profile WWW
« Reply #1 on: December 01, 2009, 03:01:30 AM »

the direction you want is given by trigonometry. use atan2, which is usually present in whatever maths library you're using.

http://en.wikipedia.org/wiki/Atan2
Logged

desdinova
Level 0
***



View Profile
« Reply #2 on: December 01, 2009, 04:57:35 AM »

That is sweet! I had so many variations on atan2(dx,dy)*(180/pi) at the beginning of the evening without quite getting it, and slowly worked further and further away from the solution  Facepalm  Oh well at least I learned (and relearned) some stuff about triangles.  Thanks
Logged
Sos
Level 8
***


I make bad games


View Profile WWW
« Reply #3 on: December 01, 2009, 11:47:25 AM »

yeah, atan2 is a good thing to have. Anyways, please remember that you should store the angle in radians as long as you are not displaying it. This willmake your life a hell lot easier
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic