Skip to content

Instantly share code, notes, and snippets.

@kinsteronline
Created August 26, 2010 17:07
Show Gist options
  • Save kinsteronline/551785 to your computer and use it in GitHub Desktop.
Save kinsteronline/551785 to your computer and use it in GitHub Desktop.
Distance w/Pythagorean
// I should have studied harder!
// http://en.wikipedia.org/wiki/Pythagorean_theorem
function distanceBetween(begin, end) {
var xs = end.x - begin.x, ys = end.y - begin.y;
return Math.sqrt(xs * xs + ys * ys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment