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.

22 lines (21 loc) 741 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reflect4D = void 0; const dot_4d_js_1 = require("./dot-4d.js"); /** * Reflects a 4D vector across a normal vector. * The normal vector should be normalized (unit length). * @param {ArrayVector4D} xyzw - Vector as `[x, y, z, w]` * @param {ArrayVector4D} normal - Normal vector (must be normalized) * @returns {ArrayVector4D} The reflected vector */ const reflect4D = (xyzw, normal) => { const dot = (0, dot_4d_js_1.dot4D)(xyzw, normal); return [ xyzw[0] - 2 * dot * normal[0], xyzw[1] - 2 * dot * normal[1], xyzw[2] - 2 * dot * normal[2], xyzw[3] - 2 * dot * normal[3], ]; }; exports.reflect4D = reflect4D;