Skip to content

Instantly share code, notes, and snippets.

@evdokimovm
Created June 19, 2016 14:10
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save evdokimovm/0e7163faf7c8fe24e41e6b68461e4feb to your computer and use it in GitHub Desktop.
Save evdokimovm/0e7163faf7c8fe24e41e6b68461e4feb to your computer and use it in GitHub Desktop.
JavaScript Convert Radians to Degrees and Degrees to Radians
// 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