-
-
Save mattbontrager/9d778832c4eefa519665f45f7e43b0cc 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