Created
February 24, 2013 17:41
-
-
Save jarek-foksa/5024758 to your computer and use it in GitHub Desktop.
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
| # The angle can be in range 0 - 360 and is measured clockwise starting from hour 12 | |
| # vector1 is the reference vector | |
| getAngleBetweenTwoVectors: (vector1, vector2) -> | |
| angleRad = atan2(vector2.y, vector2.x) - atan2(vector1.y, vector1.x) | |
| angle = angleRad * (180/pi) | |
| angle = 360 - abs(angle) if angle < 0 | |
| return angle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment