@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.
12 lines (11 loc) • 576 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.random3D = void 0;
const from_spherical_coords_3d_js_1 = require("./from-spherical-coords-3d.js");
/**
* Creates a random unit 3D vector.
* @param {() => number} random - A function that returns a random number between 0 and 1 (default: `Math.random`)
* @returns {ArrayVector3D} Random unit vector
*/
const random3D = (random = Math.random) => (0, from_spherical_coords_3d_js_1.fromSphericalCoords3D)(Math.acos(2 * random() - 1), random() * Math.PI * 2, 1);
exports.random3D = random3D;