@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.
18 lines (17 loc) • 588 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize4D = void 0;
const magnitude_4d_js_1 = require("./magnitude-4d.js");
/**
* Normalizes a 4D vector to unit length.
* @param {ArrayVector4D} xyzw - Vector as `[x, y, z, w]`
* @param {number} [m] - Optional current magnitude (default: `magnitude4D(xyzw)`)
* @returns {ArrayVector4D} The normalized vector
*/
const normalize4D = (xyzw, m = (0, magnitude_4d_js_1.magnitude4D)(xyzw)) => [
xyzw[0] / m,
xyzw[1] / m,
xyzw[2] / m,
xyzw[3] / m,
];
exports.normalize4D = normalize4D;