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.

8 lines (7 loc) 301 B
/** * Calculates the squared magnitude of a 4D vector. * Faster than magnitude for comparisons. * @param {ArrayVector4D} xyzw - Vector as `[x, y, z, w]` * @returns {number} The squared magnitude */ export const magnitudeSq4D = (xyzw) => xyzw[0] ** 2 + xyzw[1] ** 2 + xyzw[2] ** 2 + xyzw[3] ** 2;