Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to calculate the angular direction of a projectile, knowing it's X and Y velocity I can find the magnitude of its movement, but I'm having a hard time wrapping my mind around getting the angular direction (in radians) that it is moving...

I assume there is a tan or a sin involved, but I'm a bit clueless otherwise...

share|improve this question
2  
As a side note ... why? Most calculations for a game, including rotations by the same angle, you can do without touching trigonometric functions. –  Martin Sojka Sep 15 '11 at 18:14
add comment

2 Answers 2

up vote 8 down vote accepted

read the following page you have to use atan2 : http://www.w3schools.com/jsref/jsref_atan.asp

so angle = atan2 (vy,vx); and speed = sqrt(vy*vy + vx * vx)

share|improve this answer
    
Nothing wrong with the W3Schools page, but just to let you know: W3Fools.com –  Some Guy Nov 23 '11 at 9:39
add comment

angle = tan_inverse(VelocityY/VelocityX)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.