@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.
16 lines (15 loc) • 873 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.angleBetween4D = void 0;
const dot_4d_js_1 = require("./dot-4d.js");
const magnitude_4d_js_1 = require("./magnitude-4d.js");
/**
* Calculates the angle between two 4D vectors.
* @param {ArrayVector4D} xyzw1 - First vector as `[x, y, z, w]`
* @param {ArrayVector4D} xyzw2 - Second vector as `[x, y, z, w]`
* @param {number} [m1] - Optional magnitude of the first vector (default: `magnitude4D(xyzw1)`)
* @param {number} [m2] - Optional magnitude of the second vector (default: `magnitude4D(xyzw2)`)
* @returns {number} The angle in radians
*/
const angleBetween4D = (xyzw1, xyzw2, m1 = (0, magnitude_4d_js_1.magnitude4D)(xyzw1), m2 = (0, magnitude_4d_js_1.magnitude4D)(xyzw2)) => Math.acos((0, dot_4d_js_1.dot4D)(xyzw1, xyzw2) / (m1 * m2));
exports.angleBetween4D = angleBetween4D;