Size: XS


UX & Product Designer - Chi Wai Li

My Blog



Blog

Calculating tangent angle in AS3



Tangent
To work out the angle of arrows, I have to use good old trigonometry. Something I have actually enjoyed back in high school. The problem solving was a good challenge for me.
When I use to work as a volunteer in London, I also helped tutor kids with their home work and this was one of my favorite subject. Sad I know
Now, to work out the angle in actionscript 3:
trace(“In Degrees: ” + ( Math.atan2(dot.y,dot.x))*180/Math.PI);
The first half of the code: Math.atan2(dot.y,dot.x) works out the Tangent using Y and X (Careful not to mix the order around) Tan-1 (dot.y/dot.x), The result is worked out in radians therefore will need to be converted back in the degrees for my use. Hence *180/Math.PI
Solution found in Kirupa.com
Since I couldn’t find my calculator form our house move I used http://web2.0calc.com/