modeling/src/maths/vec3/squaredDistance.js

  1. /**
  2. * Calculates the squared distance between two vectors.
  3. *
  4. * @param {vec3} a - first operand
  5. * @param {vec3} b - second operand
  6. * @returns {Number} squared distance
  7. * @alias module:modeling/maths/vec3.squaredDistance
  8. */
  9. const squaredDistance = (a, b) => {
  10. const x = b[0] - a[0]
  11. const y = b[1] - a[1]
  12. const z = b[2] - a[2]
  13. return x * x + y * y + z * z
  14. }
  15. module.exports = squaredDistance