Skip to content

Instantly share code, notes, and snippets.

@sydlawrence
Created December 17, 2012 10:37
Show Gist options
  • Save sydlawrence/4317335 to your computer and use it in GitHub Desktop.
Save sydlawrence/4317335 to your computer and use it in GitHub Desktop.
Calculate the distance between two objects
// taken from http://24ways.org/2012/cut-copy-paste/
deltaX = round(p2.x-p1.x);
deltaY = round(p2.y-p1.y);
diff = round(sqrt((deltaX*deltaX)+(deltaY*deltaY)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment