Created
April 13, 2014 13:14
-
-
Save slikts/10583725 to your computer and use it in GitHub Desktop.
radians to heading vector
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
'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