Skip to content

Instantly share code, notes, and snippets.

@AVGP
Created November 20, 2014 14:27
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 AVGP/466ad5796e9c38795a63 to your computer and use it in GitHub Desktop.
Save AVGP/466ad5796e9c38795a63 to your computer and use it in GitHub Desktop.
Handy function to get the difference between target heading and current heading
function getAngle(currentHeading, target) {
if(currentHeading > 180) {
target += 360;
}
return Math.abs(currentHeading - target);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment