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) 218 B
/** * Calculates the magnitude of a 2D vector. * @param {ArrayVector2D} xy - Vector as `[x, y]` * @returns {number} Magnitude of the vector */ export const magnitude2D = (xy) => Math.sqrt(xy[0] ** 2 + xy[1] ** 2);