Created
December 19, 2012 10:26
-
-
Save bbeaumont/4335783 to your computer and use it in GitHub Desktop.
Get the relative sides of two objects
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 getSide(targetPosition:Point, currentPosition:Point, currentDirection:Point):int | |
{ | |
var positionDelta:Point = new Point( | |
targetPosition.x - currentPosition.x, | |
targetPosition.y - currentPosition.y | |
); | |
var direction:Number = positionDelta.x*-currentDirection.y + positionDelta.y*currentDirection.x; | |
if (direction < 0.0) | |
return 1; | |
else if (direction > 0.0) | |
return -1; | |
else | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment