Skip to content

Instantly share code, notes, and snippets.

@mattbontrager
Forked from evdokimovm/index.js
Created July 5, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbontrager/9d778832c4eefa519665f45f7e43b0cc to your computer and use it in GitHub Desktop.
Save mattbontrager/9d778832c4eefa519665f45f7e43b0cc 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