Created
June 19, 2016 14:10
-
-
Save evdokimovm/0e7163faf7c8fe24e41e6b68461e4feb to your computer and use it in GitHub Desktop.
JavaScript Convert Radians to Degrees and Degrees to Radians
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
// Convert from degrees to radians. | |
Math.radians = function(degrees) { | |
return degrees * Math.PI / 180; | |
} | |
Math.radians(90); // 1.5707963267948966 | |
// Convert from radians to degrees. | |
Math.degrees = function(radians) { | |
return radians * 180 / Math.PI; | |
} | |
Math.degrees(3.141592653589793); // 180 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment