Skip to content

Instantly share code, notes, and snippets.

@JudeOsborn
Created September 16, 2012 23:40
Show Gist options
  • Save JudeOsborn/3734838 to your computer and use it in GitHub Desktop.
Save JudeOsborn/3734838 to your computer and use it in GitHub Desktop.
Calculate the distance between two coordinates
function lineDistance(p1, p2) {
var xs = 0;
var ys = 0;
xs = p2.x - p1.x;
xs = xs * xs;
ys = p2.y - p1.y;
ys = ys * ys;
return Math.sqrt(xs + ys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment