@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.
13 lines (12 loc) • 708 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEqualApprox2D = void 0;
/**
* Compares a 2D vector with another vector using an epsilon value for floating-point comparison.
* @param {ArrayVector2D} xy1 - First vector as `[x, y]`
* @param {ArrayVector2D} xy2 - Second vector as `[x, y]`
* @param {number} epsilon - Maximum difference between components to consider them equal (default: `Number.EPSILON`)
* @returns {boolean} `true` if the vectors are equal, `false` otherwise
*/
const isEqualApprox2D = (xy1, xy2, epsilon = Number.EPSILON) => Math.abs(xy1[0] - xy2[0]) <= epsilon && Math.abs(xy1[1] - xy2[1]) <= epsilon;
exports.isEqualApprox2D = isEqualApprox2D;