Skip to content

Instantly share code, notes, and snippets.

@codearachnid
Last active August 29, 2015 14:05
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 codearachnid/c3aa8c06d7aa0119329e to your computer and use it in GitHub Desktop.
Save codearachnid/c3aa8c06d7aa0119329e to your computer and use it in GitHub Desktop.
Convert degrees to radians
/**
* Convert degrees to radians
* @author Timothy Wood @codearachnid
* @link http://www.movable-type.co.uk/scripts/latlong.html
* @example
var latitude = 38.68551;
var longitude = -96.503906;
var latitude_radian = latitude.toRadians();
var longitude_radian = longitude.toRadians();
*/
if ( typeof( Number.prototype.toRadians ) === "undefined" || !Number.prototype.toRad ) {
Number.prototype.toRadians = function() {
// todo better int handling for the calculation to ensure is truly a number
return this * Math.PI / 180;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment