Skip to content

Instantly share code, notes, and snippets.

View RomainKurtz's full-sized avatar

Romain Kurtz RomainKurtz

View GitHub Profile
@RomainKurtz
RomainKurtz / centerAB
Last active September 2, 2015 09:16
Compute the center of two points (vector3: x,y,z) in 3D space
//To compute the center of two points (vector3: x,y,z) in 3D space
function centerAB (A,B){
var x = ((A.x+B.x)/2);
var y = ((A.y+B.y)/2);
var z = ((A.z+B.z)/2);
return new THREE.Vector3(x,y,z);
}
@RomainKurtz
RomainKurtz / distanceAB
Last active September 2, 2015 09:16
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);
}