Created
February 14, 2015 21:03
-
-
Save TimSC/33e9b43a8e976564fb3c to your computer and use it in GitHub Desktop.
Difference between two angles
This file contains hidden or 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 relativeBearing(b1Rad, b2Rad) | |
| { | |
| b1y = Math.cos(b1Rad); | |
| b1x = Math.sin(b1Rad); | |
| b2y = Math.cos(b2Rad); | |
| b2x = Math.sin(b2Rad); | |
| crossp = b1y * b2x - b2y * b1x; | |
| dotp = b1x * b2x + b1y * b2y; | |
| if(crossp > 0.) | |
| return Math.acos(dotp); | |
| return -Math.acos(dotp); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment