Skip to content

Instantly share code, notes, and snippets.

@RomainKurtz
Last active September 2, 2015 09:16
Show Gist options
  • Save RomainKurtz/ca1758b3bdd9474f00c2 to your computer and use it in GitHub Desktop.
Save RomainKurtz/ca1758b3bdd9474f00c2 to your computer and use it in GitHub Desktop.
Compute the distance between 2 points (Vector3 : x,y,z) in 3D space
//For compute the distance between 2 points (Vector3 : x,y,z) in 3D space
function distanceAB(v1, v2) {
var dx = v1.x - v2.x;
var dy = v1.y - v2.y;
var dz = v1.z - v2.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment