Skip to content

Instantly share code, notes, and snippets.

@slikts
Created April 13, 2014 13:14
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 slikts/10583725 to your computer and use it in GitHub Desktop.
Save slikts/10583725 to your computer and use it in GitHub Desktop.
radians to heading vector
'use strict';
function d2r(d) {
return d * Math.PI / 180;
}
function r2d(r) {
return r * 180 / Math.PI;
}
// radians to heading vector
function r2v(r) {
return {
x: Math.sin(r),
y: Math.cos(r)
};
}
function v2r(v) {
return Math.atan2(v.x, v.y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment