Created
November 20, 2014 14:27
-
-
Save AVGP/466ad5796e9c38795a63 to your computer and use it in GitHub Desktop.
Handy function to get the difference between target heading and current heading
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
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