@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) • 603 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.limitMin2D = void 0;
const magnitude_2d_js_1 = require("./magnitude-2d.js");
/**
* Limits the maximum magnitude of a 2D vector.
* @param {ArrayVector2D} xy - Vector as `[x, y]`
* @param {number} min - Minimum magnitude
* @param {number} [m] - Optional current magnitude (default: `magnitude2D(xy)`)
* @returns {ArrayVector2D} The limited vector
*/
const limitMin2D = (xy, min, m = (0, magnitude_2d_js_1.magnitude2D)(xy)) => m < min ? [(xy[0] / m) * min, (xy[1] / m) * min] : xy;
exports.limitMin2D = limitMin2D;