Last active
August 29, 2015 14:19
-
-
Save zouloux/c02777e5fdbb002cbce3 to your computer and use it in GitHub Desktop.
Compute angle between 3 points
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
protected static function angleBetweenPoints (p0:Point, p1:Point, p2:Point):Number | |
{ | |
var a:Number = Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2); | |
var b:Number = Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2); | |
var c:Number = Math.pow(p2.x - p0.x, 2) + Math.pow(p2.y - p0.y, 2); | |
return Math.acos((a + b - c) / Math.sqrt(4 * a * b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment