UNPKG

@jscad/modeling

Version:

Constructive Solid Geometry (CSG) Library for JSCAD

17 lines (15 loc) 404 B
/** * Calculates the squared distance between two vectors. * * @param {vec3} a - first operand * @param {vec3} b - second operand * @returns {Number} squared distance * @alias module:modeling/maths/vec3.squaredDistance */ const squaredDistance = (a, b) => { const x = b[0] - a[0] const y = b[1] - a[1] const z = b[2] - a[2] return x * x + y * y + z * z } module.exports = squaredDistance