VBGamer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RE: Angle problems using radians Rag on a Stick (4 replies, 0 views) (2000-Sep-27) LEARN TRIG =)
In a right angled triangle, Tan(Angle) is equal to the length of the opposite side over (divided by) the adjacent side:
<tt>
<pre>
/| The Player
/ |
/ |
/ O
/ P
/ P
/ |
--ADJ--|
^
The angle (The enemy is here)
</pre>
</tt>
So:
Tan(TheAngleYouWant) = (Y2 - Y1) / (X2 - X1)
Where X1, Y1 is the player and X2, Y2 is the enemy.
so:
Angle = Atn((Y2 - Y1) / (X2 - X1))
Then convert it to radians
Angle = Angle * (Pi / 180)
And you might want to put (Pi / 180) as a constant.
|