# Bitcoin Values Forum

Bitcoin values .

You are not logged in.

## #1 2020-09-10 07:34:57

NBGMarty91
Member
From: Netherlands, Veenhuizen
Registered: 2020-09-10
Posts: 1

### The only problem: Math.atan2 gives the angle in radians

Search.
Bookmark the.
by                    //calculate these values, which we will use to determine the angle we need to rotate to var yDifference:Number = stageRef.mouseY - y; var xDifference:Number = stageRef.mouseX - x; //this constant will convert our angle from radians to degrees var radiansToDegrees:Number = 180/Math.
PI; //this final line uses trigonometry to calculate the rotation rotation = Math.atan2(yDifference.

##### XDifference) * radiansToDegrees;       rotation = Math.atan2(stageRef.mouseY - y

stageRef.mouseX - x) * 180/Math.

##### PI;         Math.atan2( [ y difference ]

[ x difference ] )   If you know basic trigonometry, you’ll know all about the inverse tangent.
If you’re unfamiliar with it, trigonometry is really useful in programming, so you might want to , but here’s the general idea: we can use the lengths and angles of a right triangle to calculate new, useful information.
Specifically to this tutorial, we can use the lengths of two sides of a right triangle to determine its angles.
Using the yDifference and xDifference as the two lengths, we can find what angle the player should rotate to.
The only problem: Math.atan2 gives the angle in radians, not degrees.
To convert back to degrees, which Flash uses, we need to multiply our value by a constant.
That’s it for today, folks.
You can pickup your source files.
This entry was posted in , , ,  and tagged , , , , , , , , , , , ,.
Bryon.
Alex.
Tom.
Email                  Name                 Website                                                            You are commenting using your WordPress.com account.