UNPKG

@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) 668 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.distanceChebyshev3D = void 0; /** * Calculates the Chebyshev distance between two 3D vectors. * @param {ArrayVector3D} xyz1 - First vector as `[x, y, z]` as * @param {ArrayVector3D} xyz2 - Second vector as `[x, y, z]` as * @returns {number} Chebyshev distance */ const distanceChebyshev3D = (xyz1, xyz2) => { const absX = Math.abs(xyz1[0] - xyz2[0]); const absY = Math.abs(xyz1[1] - xyz2[1]); const absZ = Math.abs(xyz1[2] - xyz2[2]); return absX >= absY && absX >= absZ ? absX : absY >= absZ ? absY : absZ; }; exports.distanceChebyshev3D = distanceChebyshev3D;