15 lines
355 B
JavaScript
15 lines
355 B
JavaScript
module.exports = distance;
|
|
|
|
/**
|
|
* Calculates the euclidian distance between two vec3's
|
|
*
|
|
* @param {vec3} a the first operand
|
|
* @param {vec3} b the second operand
|
|
* @returns {Number} distance between a and b
|
|
*/
|
|
function distance(a, b) {
|
|
var x = b[0] - a[0],
|
|
y = b[1] - a[1],
|
|
z = b[2] - a[2]
|
|
return Math.sqrt(x*x + y*y + z*z)
|
|
} |