7
\$\begingroup\$

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...

\$\endgroup\$
1
  • 2
    \$\begingroup\$ As a side note ... why? Most calculations for a game, including rotations by the same angle, you can do without touching trigonometric functions. \$\endgroup\$ Commented Sep 15, 2011 at 18:14

2 Answers 2

11
\$\begingroup\$

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)

\$\endgroup\$
1
  • \$\begingroup\$ Nothing wrong with the W3Schools page, but just to let you know: W3Fools.com \$\endgroup\$
    – Some Guy
    Commented Nov 23, 2011 at 9:39
0
\$\begingroup\$

angle = tan_inverse(VelocityY/VelocityX)

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.