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.

7 lines (6 loc) 239 B
/** * Calculates the magnitude of a 3D vector. * @param {ArrayVector3D} xyz - Vector as `[x, y, z]` * @returns {number} Magnitude of the vector */ export const magnitude3D = (xyz) => Math.sqrt(xyz[0] ** 2 + xyz[1] ** 2 + xyz[2] ** 2);