Skip to content

Instantly share code, notes, and snippets.

@bbeaumont
Created December 19, 2012 10:26
Show Gist options
  • Save bbeaumont/4335783 to your computer and use it in GitHub Desktop.
Save bbeaumont/4335783 to your computer and use it in GitHub Desktop.
Get the relative sides of two objects
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