-
-
Save vlandham/5060099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Turning an angle into a point on a unit | |
// circle and then back again | |
// convert from degrees to radians | |
D2R = Math.PI / 180; | |
// convert from radians to degrees | |
R2D = 180 / Math.PI; | |
// our angle | |
angle = 30; | |
// this angle in radians | |
radians = angle * D2R; | |
// point on a unit circle | |
point = { | |
x: Math.cos(radians), | |
y: Math.sin(radians) | |
}; | |
// back to the angle in radians | |
back = Math.atan2(point.y, point.x); | |
// back to the angle in degrees | |
back_angle = back * R2D; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment