@fimbul-works/vec
Version:
A comprehensive TypeScript vector math library providing 2D, 3D, and 4D vector operations with a focus on performance and type safety.
13 lines (12 loc) • 590 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.distanceSq4D = void 0;
/**
* Calculates the squared Euclidean distance between two 4D vectors.
* Faster than distance for comparisons.
* @param {ArrayVector4D} xyzw1 - First vector as `[x, y, z, w]`
* @param {ArrayVector4D} xyzw2 - Second vector as `[x, y, z, w]`
* @returns {number} The squared distance
*/
const distanceSq4D = (xyzw1, xyzw2) => (xyzw1[0] - xyzw2[0]) ** 2 + (xyzw1[1] - xyzw2[1]) ** 2 + (xyzw1[2] - xyzw2[2]) ** 2 + (xyzw1[3] - xyzw2[3]) ** 2;
exports.distanceSq4D = distanceSq4D;