@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.
17 lines (16 loc) • 694 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.distanceMinkowski4D = void 0;
/**
* Calculates the Minkowski distance between two 4D vectors.
* @param {ArrayVector4D} xyzw1 - First vector as `[x, y, z, w]`
* @param {ArrayVector4D} xyzw2 - Second vector as `[x, y, z, w]`
* @param {number} p - The order of the Minkowski distance
* @returns {number} The Minkowski distance
*/
const distanceMinkowski4D = (xyzw1, xyzw2, p) => (Math.abs(xyzw1[0] - xyzw2[0]) ** p +
Math.abs(xyzw1[1] - xyzw2[1]) ** p +
Math.abs(xyzw1[2] - xyzw2[2]) ** p +
Math.abs(xyzw1[3] - xyzw2[3]) ** p) **
(1 / p);
exports.distanceMinkowski4D = distanceMinkowski4D;