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.

14 lines (13 loc) 468 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.random2D = void 0; /** * Creates a random unit 2D vector. * @param {() => void} random - A function that returns a random number between 0 and 1 (default: `Math.random`) * @returns {ArrayVector2D} Random unit vector */ const random2D = (random = Math.random) => { const phi = random() * Math.PI * 2; return [Math.cos(phi), Math.sin(phi)]; }; exports.random2D = random2D;