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 , , , , , , , , , , , ,.
6 comments on “”.
Bryon.
Alex.
Tom.
Leave a Reply.
Enter your comment here.
Email                  Name                 Website                                                            You are commenting using your WordPress.com account.
(  /     )                                                            You are commenting using your Google account.
(  /     )                                                            You are commenting using your Twitter account.
(  /     )                                                            You are commenting using your Facebook account.
(  /     )                                                                           on the App Store for relaxing bubble-popping and 50 characters to unlock.

On the App Store for dozens of brain-twisting puzzle challenges

on the App Store for cute, reflex-based fun.
Monthly Archives        Select Month    July 2013  (1)   June 2013  (1)   May 2013  (2)   November 2012  (1)   September 2012  (2)   July 2012  (1)   June 2012  (2)   May 2012  (1)   April 2012  (2)   March 2012  (1)   February 2012  (4)   January 2012  (3)   November 2011  (2)   September 2011  (4)   August 2011  (3)   March 2011  (3).
Post to                                                                                         bloggers like this:.

Offline

Board footer

Powered by FluxBB