curvy 2.0.0-alpha.13 → 2.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/cubic2d.d.ts +92 -3
- package/dist/curve/curve2d.d.ts +81 -0
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +113 -3
- package/dist/curve/quadratic2d.d.ts +92 -3
- package/dist/curve/rationalCubic2d.d.ts +100 -38
- package/dist/interval/index.mjs +2 -2
- package/dist/matrix/index.mjs +47 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix3x3.d.ts +87 -1
- package/dist/matrix/matrix4x4.d.ts +57 -6
- package/dist/matrix/traits.d.ts +34 -0
- package/dist/monotonicity/index.mjs +1 -1
- package/dist/monotonicity/monotonicity.d.ts +25 -0
- package/dist/number.d.ts +53 -0
- package/dist/number.mjs +56 -1
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +22 -0
- package/dist/path/index.mjs +25 -149
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +24 -0
- package/dist/path/path2d.d.ts +54 -0
- package/dist/path/quadratic2d.d.ts +22 -0
- package/dist/path/rationalCubic2d.d.ts +21 -0
- package/dist/polynomial/index.mjs +2 -2
- package/dist/shared/affine2d-Dvna84gc.mjs +332 -0
- package/dist/shared/affine2d-Dvna84gc.mjs.map +1 -0
- package/dist/shared/{characteristic-BkEr-rr8.mjs → characteristic--7nC4Q_a.mjs} +4 -5
- package/dist/shared/characteristic--7nC4Q_a.mjs.map +1 -0
- package/dist/shared/{cubic-BL6dpuHh.mjs → cubic-BiGuAnZ0.mjs} +56 -27
- package/dist/shared/cubic-BiGuAnZ0.mjs.map +1 -0
- package/dist/shared/{interval-Dm35Xhy4.mjs → interval-Dcqpo73t.mjs} +5 -5
- package/dist/shared/interval-Dcqpo73t.mjs.map +1 -0
- package/dist/shared/{interval2d-AtneyI45.mjs → interval2d-C2Pk66-2.mjs} +3 -3
- package/dist/shared/{interval2d-AtneyI45.mjs.map → interval2d-C2Pk66-2.mjs.map} +1 -1
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs +233 -0
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs.map +1 -0
- package/dist/shared/{matrix4x4-BWmf4lZM.mjs → matrix4x4-BrqgYZCD.mjs} +72 -223
- package/dist/shared/matrix4x4-BrqgYZCD.mjs.map +1 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs +64 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs.map +1 -0
- package/dist/shared/{quadratic-DPrUsFCp.mjs → quadratic-BmMqkvxx.mjs} +2 -2
- package/dist/shared/{quadratic-DPrUsFCp.mjs.map → quadratic-BmMqkvxx.mjs.map} +1 -1
- package/dist/shared/{rationalCubic2d-H1J2Fjyy.mjs → rationalCubic2d-CZiP8nIq.mjs} +282 -326
- package/dist/shared/rationalCubic2d-CZiP8nIq.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-CeHgpNht.mjs → rationalCubic2d-gM7VeiiT.mjs} +585 -125
- package/dist/shared/rationalCubic2d-gM7VeiiT.mjs.map +1 -0
- package/dist/shared/{solution-B2JdOZpe.mjs → solution-BW0BBMXI.mjs} +22 -6
- package/dist/shared/solution-BW0BBMXI.mjs.map +1 -0
- package/dist/shared/{vector2-CSkaMXvp.mjs → vector2-DuA3EmfL.mjs} +5 -3
- package/dist/shared/vector2-DuA3EmfL.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DP1nTBdS.mjs → vector2.internal-rPnW0RCx.mjs} +10 -5
- package/dist/shared/vector2.internal-rPnW0RCx.mjs.map +1 -0
- package/dist/shared/{vector3-CR2LPV03.mjs → vector3-oxtggkDp.mjs} +2 -2
- package/dist/shared/{vector3-CR2LPV03.mjs.map → vector3-oxtggkDp.mjs.map} +1 -1
- package/dist/shared/vector3.internal-CfWHl9SG.mjs +135 -0
- package/dist/shared/vector3.internal-CfWHl9SG.mjs.map +1 -0
- package/dist/shared/{vector4-PO_7EYd-.mjs → vector4-DGHuCvTV.mjs} +2 -2
- package/dist/shared/{vector4-PO_7EYd-.mjs.map → vector4-DGHuCvTV.mjs.map} +1 -1
- package/dist/shared/vector4.internal-DH5DzNYO.mjs +116 -0
- package/dist/shared/vector4.internal-DH5DzNYO.mjs.map +1 -0
- package/dist/solution/index.mjs +1 -1
- package/dist/solution/solution.d.ts +16 -0
- package/dist/splines/basis2d.d.ts +64 -0
- package/dist/splines/bezier2d.d.ts +72 -0
- package/dist/splines/cardinal2d.d.ts +78 -0
- package/dist/splines/hermite2d.d.ts +76 -0
- package/dist/splines/index.mjs +109 -15
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +65 -0
- package/dist/splines/rationalBezier2d.d.ts +76 -0
- package/dist/transform/affine2d.d.ts +339 -0
- package/dist/transform/affine2d.internal.d.ts +2 -0
- package/dist/transform/index.d.ts +3 -0
- package/dist/transform/index.mjs +2 -0
- package/dist/transform/traits.d.ts +19 -0
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +49 -0
- package/package.json +5 -1
- package/dist/shared/characteristic-BkEr-rr8.mjs.map +0 -1
- package/dist/shared/cubic-BL6dpuHh.mjs.map +0 -1
- package/dist/shared/interval-Dm35Xhy4.mjs.map +0 -1
- package/dist/shared/matrix4x4-BWmf4lZM.mjs.map +0 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +0 -34
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +0 -1
- package/dist/shared/solution-B2JdOZpe.mjs.map +0 -1
- package/dist/shared/vector2-CSkaMXvp.mjs.map +0 -1
- package/dist/shared/vector2.internal-DP1nTBdS.mjs.map +0 -1
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs +0 -246
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs.map +0 -1
package/dist/matrix/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as fromRows$2, B as toRows$2, C as transpose$3, D as determinant$2, E as columnVector$2, F as rowVector$2, H as vectorProductLeft$2, I as setColumn$2, L as setRow$2, M as make$2, N as reverseColumns$2, O as equals$2, P as reverseRows$2, R as solveSystem$2, S as toRows$3, T as vectorProductRight$3, U as vectorProductRight$2, V as transpose$2, _ as rowVector$3, a as fromColumns$3, b as solveSystem$3, c as inverse$1, d as isMatrix3x3$1, f as make$3, g as reverseRows$3, h as reverseColumns$3, i as equals$3, j as isMatrix2x2$1, k as fromColumns$2, l as inverseUnsafe$1, m as multiply$1, n as columnVector$3, o as fromRows$3, p as minor$1, r as determinant$3, s as identity$1, t as asInvertible$1, u as isInvertible$1, v as setColumn$3, w as vectorProductLeft$3, x as toColumns$3, y as setRow$3, z as toColumns$2 } from "../shared/matrix3x3.internal-Cod-r7H3.mjs";
|
|
3
|
+
import { r as matrix4x4_exports } from "../shared/matrix4x4-BrqgYZCD.mjs";
|
|
3
4
|
//#region src/matrix/matrix2x2.ts
|
|
4
5
|
var matrix2x2_exports = /* @__PURE__ */ __exportAll({
|
|
5
6
|
columnVector: () => columnVector$1,
|
|
@@ -131,14 +132,20 @@ const reverseColumns$1 = reverseColumns$2;
|
|
|
131
132
|
//#endregion
|
|
132
133
|
//#region src/matrix/matrix3x3.ts
|
|
133
134
|
var matrix3x3_exports = /* @__PURE__ */ __exportAll({
|
|
135
|
+
asInvertible: () => asInvertible,
|
|
134
136
|
columnVector: () => columnVector,
|
|
135
137
|
determinant: () => determinant,
|
|
136
138
|
equals: () => equals,
|
|
137
139
|
fromColumns: () => fromColumns,
|
|
138
140
|
fromRows: () => fromRows,
|
|
141
|
+
identity: () => identity,
|
|
142
|
+
inverse: () => inverse,
|
|
143
|
+
inverseUnsafe: () => inverseUnsafe,
|
|
144
|
+
isInvertible: () => isInvertible,
|
|
139
145
|
isMatrix3x3: () => isMatrix3x3,
|
|
140
146
|
make: () => make,
|
|
141
147
|
minor: () => minor,
|
|
148
|
+
multiply: () => multiply,
|
|
142
149
|
reverseColumns: () => reverseColumns,
|
|
143
150
|
reverseRows: () => reverseRows,
|
|
144
151
|
rowVector: () => rowVector,
|
|
@@ -261,6 +268,45 @@ const reverseRows = reverseRows$3;
|
|
|
261
268
|
* @since 1.0.0
|
|
262
269
|
*/
|
|
263
270
|
const reverseColumns = reverseColumns$3;
|
|
271
|
+
/**
|
|
272
|
+
* The 3x3 identity matrix.
|
|
273
|
+
*
|
|
274
|
+
* @since 2.0.0
|
|
275
|
+
*/
|
|
276
|
+
const identity = identity$1;
|
|
277
|
+
const multiply = multiply$1;
|
|
278
|
+
const inverse = inverse$1;
|
|
279
|
+
/**
|
|
280
|
+
* Returns the inverse of a `Matrix3x3`. Throws when the matrix is singular
|
|
281
|
+
* (determinant approximately zero). Useful when you've already validated
|
|
282
|
+
* invertibility out-of-band and want the unwrapped matrix directly; otherwise
|
|
283
|
+
* prefer {@link inverse}.
|
|
284
|
+
*
|
|
285
|
+
* @param m - The matrix to invert.
|
|
286
|
+
* @returns The inverse matrix.
|
|
287
|
+
* @throws If `m` is singular.
|
|
288
|
+
* @since 2.0.0
|
|
289
|
+
*/
|
|
290
|
+
const inverseUnsafe = inverseUnsafe$1;
|
|
291
|
+
/**
|
|
292
|
+
* Type-narrowing predicate: refines a `Matrix3x3<T>` to
|
|
293
|
+
* `Matrix3x3<T & Invertible>` when the matrix's determinant is non-zero
|
|
294
|
+
* (within the default absolute tolerance).
|
|
295
|
+
*
|
|
296
|
+
* @param m - The matrix to check.
|
|
297
|
+
* @returns `true` when `m` is invertible.
|
|
298
|
+
* @since 2.0.0
|
|
299
|
+
*/
|
|
300
|
+
const isInvertible = isInvertible$1;
|
|
301
|
+
/**
|
|
302
|
+
* Asserts that the matrix is invertible, throwing on a singular matrix.
|
|
303
|
+
*
|
|
304
|
+
* @param m - The matrix to assert against.
|
|
305
|
+
* @returns The same matrix, typed with the `Invertible` brand.
|
|
306
|
+
* @throws When `m` is singular.
|
|
307
|
+
* @since 2.0.0
|
|
308
|
+
*/
|
|
309
|
+
const asInvertible = asInvertible$1;
|
|
264
310
|
//#endregion
|
|
265
311
|
export { matrix2x2_exports as Matrix2x2, matrix3x3_exports as Matrix3x3, matrix4x4_exports as Matrix4x4 };
|
|
266
312
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["internal.isMatrix2x2","equals","internal.equals","make","internal.make","fromRows","internal.fromRows","fromColumns","internal.fromColumns","setRow","internal.setRow","setColumn","internal.setColumn","determinant","internal.determinant","vectorProductLeft","internal.vectorProductLeft","vectorProductRight","internal.vectorProductRight","solveSystem","internal.solveSystem","toRows","internal.toRows","toColumns","internal.toColumns","rowVector","internal.rowVector","columnVector","internal.columnVector","transpose","internal.transpose","reverseRows","internal.reverseRows","reverseColumns","internal.reverseColumns","internal.isMatrix3x3","internal.equals","internal.make","internal.fromRows","internal.fromColumns","internal.setRow","internal.setColumn","internal.determinant","internal.minor","internal.vectorProductLeft","internal.vectorProductRight","internal.solveSystem","internal.toRows","internal.toColumns","internal.rowVector","internal.columnVector","internal.transpose","internal.reverseRows","internal.reverseColumns"],"sources":["../../src/matrix/matrix2x2.ts","../../src/matrix/matrix3x3.ts"],"sourcesContent":["import type { TwoDimensionalComponent, TwoDimensionalIndex } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Matrix2x2TypeId } from './matrix2x2.internal.ts'\nimport * as internal from './matrix2x2.internal.ts'\n\n/**\n * A type representing the coordinate of a 2D matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix2x2Coordinate = TwoDimensionalIndex | TwoDimensionalComponent\n\n/**\n * A 2D matrix with 2 rows and 2 columns.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Matrix2x2 extends Pipeable {\n readonly [Matrix2x2TypeId]: Matrix2x2TypeId\n\n /**\n * The value in the first row and first column.\n */\n readonly m00: number\n /**\n * The value in the first row and second column.\n */\n readonly m01: number\n /**\n * The value in the second row and first column.\n */\n readonly m10: number\n /**\n * The value in the second row and second column.\n */\n readonly m11: number\n}\n\n/**\n * Checks if a value is a `Matrix2x2`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix2x2`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix2x2: (m: unknown) => m is Matrix2x2 = internal.isMatrix2x2\n\nexport const equals: {\n /**\n * Checks if two `Matrix2x2` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix2x2, b: Matrix2x2): boolean\n /**\n * Checks if two `Matrix2x2` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix2x2): (a: Matrix2x2) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix2x2` instance.\n *\n * @param m00 - The value in the first row and first column. Defaults to 0.\n * @param m01 - The value in the first row and second column. Defaults to 0.\n * @param m10 - The value in the second row and first column. Defaults to 0.\n * @param m11 - The value in the second row and second column. Defaults to 0.\n */\nexport const make: (m00?: number, m01?: number, m10?: number, m11?: number) => Matrix2x2 =\n internal.make\n\n/**\n * Creates a new `Matrix2x2` instance from two vectors representing rows.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @returns A new `Matrix2x2` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector2, v1: Vector2) => Matrix2x2 = internal.fromRows\n\n/**\n * Creates a new `Matrix2x2` instance from two vectors representing columns.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @returns A new `Matrix2x2` instance.\n * @since 1.0.0\n */\nexport const fromColumns: (v0: Vector2, v1: Vector2) => Matrix2x2 = internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets the specified row of the matrix to the given vector.\n *\n * @param m - The matrix to modify.\n * @param row - The row index (0 or 1).\n * @param v - The vector to set the row to.\n * @returns A new `Matrix2x2` instance with the specified row set to the given vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2): Matrix2x2\n /**\n * Sets the specified row of the matrix to the given vector.\n *\n * @param row - The row index (0 or 1).\n * @param v - The vector to set the row to.\n * @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified row set to the given vector.\n * @since 1.0.0\n */\n (row: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets the specified column of the matrix to the given vector.\n *\n * @param m - The matrix to modify.\n * @param column - The column index (0 or 1).\n * @param v - The vector to set the column to.\n * @returns A new `Matrix2x2` instance with the specified column set to the given vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2): Matrix2x2\n /**\n * Sets the specified column of the matrix to the given vector.\n *\n * @param column - The column index (0 or 1).\n * @param v - The vector to set the column to.\n * @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified column set to the given vector.\n * @since 1.0.0\n */\n (column: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a 2D matrix.\n *\n * @param m - The matrix to calculate the determinant for.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix2x2) => number = internal.determinant\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 2 * 6 = 17\n * // y = 3 * 5 + 4 * 6 = 39\n * const result = Matrix2x2.vectorProductLeft(matrix, vector)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector after the left vector product.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 2 * 6 = 17\n * // y = 3 * 5 + 4 * 6 = 39\n * const result = Matrix2x2.vectorProductLeft(vector)(matrix)\n * ```\n * @param v - The vector to multiply.\n * @returns A function that takes a matrix and returns the resulting vector after the left vector product.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 3 * 6 = 33\n * // y = 2 * 5 + 4 * 6 = 62\n * const result = Matrix2x2.vectorProductRight(matrix, vector)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector after the right vector product.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 3 * 6 = 33\n * // y = 2 * 5 + 4 * 6 = 62\n * const result = Matrix2x2.vectorProductRight(vector)(matrix)\n * ```\n * @param v - The vector to multiply.\n * @returns A function that takes a matrix and returns the resulting vector after the right vector product.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.vectorProductRight\n\nexport const solveSystem: {\n /**\n * Solves a system of linear equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Solves the system of equations:\n * // 1x + 2y = 5\n * // 3x + 4y = 6\n * const result = Matrix2x2.solveSystem(matrix, vector)\n * ```\n * @param m - The matrix representing the coefficients of the system.\n * @param v - The vector representing the constants of the system.\n * @returns The solution vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Solves a system of linear equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Solves the system of equations:\n * // 1x + 2y = 5\n * // 3x + 4y = 6\n * const result = Matrix2x2.solveSystem(vector)(matrix)\n * ```\n * @param v - The vector representing the constants of the system.\n * @returns A function that takes a matrix and returns the solution vector.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.solveSystem\n\n/**\n * Returns the rows of a matrix as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix2x2) => [Vector2, Vector2] = internal.toRows\n\n/**\n * Returns the columns of a matrix as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix2x2) => [Vector2, Vector2] = internal.toColumns\n\n/**\n * Returns the specified row of a matrix as a vector.\n *\n * @param m - The matrix to get the row from.\n * @param row - The row index (0 or 1).\n * @returns A vector representing the specified row of the matrix.\n * @since 1.0.0\n */\nexport const rowVector: (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2 = internal.rowVector\n\n/**\n * Returns the specified column of a matrix as a vector.\n *\n * @param m - The matrix to get the column from.\n * @param column - The column index (0 or 1).\n * @returns A vector representing the specified column of the matrix.\n * @since 1.0.0\n */\nexport const columnVector: (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2 =\n internal.columnVector\n\n/**\n * Transposes a matrix.\n *\n * @param m - The matrix to transpose.\n * @returns A new `Matrix2x2` instance representing the transposed matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix2x2) => Matrix2x2 = internal.transpose\n\n/**\n * Reverses the rows of a matrix.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns A new `Matrix2x2` instance with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix2x2) => Matrix2x2 = internal.reverseRows\n\n/**\n * Reverses the columns of a matrix.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns A new `Matrix2x2` instance with the columns reversed.\n * @since 1.0.0\n */\nexport const reverseColumns: (m: Matrix2x2) => Matrix2x2 = internal.reverseColumns\n","import type { ThreeDimensionalComponent, ThreeDimensionalIndex } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { Matrix2x2 } from './matrix2x2.ts'\nimport type { Matrix3x3TypeId } from './matrix3x3.internal.ts'\nimport * as internal from './matrix3x3.internal.ts'\n\n/**\n * A coordinate in a 3x3 matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix3x3Coordinate = ThreeDimensionalIndex | ThreeDimensionalComponent\n\n/**\n * A 3x3 matrix.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Matrix3x3 extends Pipeable {\n readonly [Matrix3x3TypeId]: Matrix3x3TypeId\n /**\n * The value of the first row and first column.\n */\n readonly m00: number\n /**\n * The value of the first row and second column.\n */\n readonly m01: number\n /**\n * The value of the first row and third column.\n */\n readonly m02: number\n /**\n * The value of the second row and first column.\n */\n readonly m10: number\n /**\n * The value of the second row and second column.\n */\n readonly m11: number\n /**\n * The value of the second row and third column.\n */\n readonly m12: number\n /**\n * The value of the third row and first column.\n */\n readonly m20: number\n /**\n * The value of the third row and second column.\n */\n readonly m21: number\n /**\n * The value of the third row and third column.\n */\n readonly m22: number\n}\n\n/**\n * Checks if a value is a `Matrix3x3`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix3x3`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix3x3: (m: unknown) => m is Matrix3x3 = internal.isMatrix3x3\n\nexport const equals: {\n /**\n * Checks if two `Matrix3x3` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix3x3, b: Matrix3x3): boolean\n /**\n * Checks if two `Matrix3x3` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix3x3): (a: Matrix3x3) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix3x3` instance.\n *\n * @param m00 - The value of the first row and first column.\n * @param m01 - The value of the first row and second column.\n * @param m02 - The value of the first row and third column.\n * @param m10 - The value of the second row and first column.\n * @param m11 - The value of the second row and second column.\n * @param m12 - The value of the second row and third column.\n * @param m20 - The value of the third row and first column.\n * @param m21 - The value of the third row and second column.\n * @param m22 - The value of the third row and third column.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const make: (\n m00?: number,\n m01?: number,\n m02?: number,\n m10?: number,\n m11?: number,\n m12?: number,\n m20?: number,\n m21?: number,\n m22?: number,\n) => Matrix3x3 = internal.make\n\n/**\n * Creates a new `Matrix3x3` instance from three row vectors.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @param v2 - The third row vector.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector3, v1: Vector3, v2: Vector3) => Matrix3x3 = internal.fromRows\n\n/**\n * Creates a new `Matrix3x3` instance from three column vectors.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @param v2 - The third column vector.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const fromColumns: (v0: Vector3, v1: Vector3, v2: Vector3) => Matrix3x3 =\n internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets a row of the matrix to a new vector.\n *\n * @param m - The matrix to set the row of.\n * @param row - The row index to set.\n * @param v - The new vector for the row.\n * @returns A new matrix with the specified row set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3): Matrix3x3\n /**\n * Sets a row of the matrix to a new vector.\n *\n * @param row - The row index to set.\n * @param v - The new vector for the row.\n * @returns A function that takes a matrix and returns a new matrix with the specified row set to the new vector.\n * @since 1.0.0\n */\n (row: Matrix3x3Coordinate, v: Vector3): (m: Matrix3x3) => Matrix3x3\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets a column of the matrix to a new vector.\n *\n * @param m - The matrix to set the column of.\n * @param column - The column index to set.\n * @param v - The new vector for the column.\n * @returns A new matrix with the specified column set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3): Matrix3x3\n /**\n * Sets a column of the matrix to a new vector.\n *\n * @param column - The column index to set.\n * @param v - The new vector for the column.\n * @returns A function that takes a matrix and returns a new matrix with the specified column set to the new vector.\n * @since 1.0.0\n */\n (column: Matrix3x3Coordinate, v: Vector3): (m: Matrix3x3) => Matrix3x3\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a 3x3 matrix.\n *\n * @param m - The matrix to calculate the determinant of.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix3x3) => number = internal.determinant\n\n/**\n * Calculates the minor of a 3x3 matrix.\n *\n * @param m - The matrix to calculate the minor of.\n * @param row - The row index of the element to calculate the minor for.\n * @param column - The column index of the element to calculate the minor for.\n * @returns The minor of the matrix at the specified row and column.\n * @since 1.0.0\n */\nexport const minor: (\n m: Matrix3x3,\n row: Matrix3x3Coordinate,\n column: Matrix3x3Coordinate,\n) => Matrix2x2 = internal.minor\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 2 * 11 + 3 * 12\n * // y = 4 * 10 + 5 * 11 + 6 * 12\n * // z = 7 * 10 + 8 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductLeft(m, v)\n * ```\n * @param m - The matrix to calculate the left vector product with.\n * @param v - The vector to calculate the left vector product with.\n * @returns The resulting vector from the left vector product.\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 2 * 11 + 3 * 12\n * // y = 4 * 10 + 5 * 11 + 6 * 12\n * // z = 7 * 10 + 8 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductLeft(v)(m)\n * ```\n * @param v - The vector to calculate the left vector product with.\n * @returns A function that takes a matrix and returns the resulting vector from the left vector product.\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 4 * 11 + 7 * 12\n * // y = 2 * 10 + 5 * 11 + 8 * 12\n * // z = 3 * 10 + 6 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductRight(m, v)\n * ```\n * @param m - The matrix to calculate the right vector product with.\n * @param v - The vector to calculate the right vector product with.\n * @returns The resulting vector from the right vector product.\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 4 * 11 + 7 * 12\n * // y = 2 * 10 + 5 * 11 + 8 * 12\n * // z = 3 * 10 + 6 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductRight(v)(m)\n * ```\n * @param v - The vector to calculate the right vector product with.\n * @returns A function that takes a matrix and returns the resulting vector from the right vector product.\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.vectorProductRight\n\nexport const solveSystem: {\n /**\n * Solves a system of equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = m00 * x + m01 * y + m02 * z\n * // y = m10 * x + m11 * y + m12 * z\n * // z = m20 * x + m21 * y + m22 * z\n * const result = Matrix3x3.solveSystem(m, v)\n * ```\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Solves a system of equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = m00 * x + m01 * y + m02 * z\n * // y = m10 * x + m11 * y + m12 * z\n * // z = m20 * x + m21 * y + m22 * z\n * const result = Matrix3x3.solveSystem(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.solveSystem\n\n/**\n * Returns the rows of a `Matrix3x3` as an array of vectors.\n *\n * @param m - The matrix to get the rows from.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix3x3) => [Vector3, Vector3, Vector3] = internal.toRows as (\n m: Matrix3x3,\n) => [Vector3, Vector3, Vector3]\n\n/**\n * Returns the columns of a `Matrix3x3` as an array of vectors.\n *\n * @param m - The matrix to get the columns from.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix3x3) => [Vector3, Vector3, Vector3] = internal.toColumns as (\n m: Matrix3x3,\n) => [Vector3, Vector3, Vector3]\n\nexport const rowVector: {\n /**\n * Gets a row vector from the matrix.\n *\n * @param m - The matrix to get the row vector from.\n * @param row - The row index to get the vector from.\n * @returns The row vector at the specified index.\n * @since 1.0.0\n */\n (m: Matrix3x3, row: Matrix3x3Coordinate): Vector3\n /**\n * Gets a row vector from the matrix.\n *\n * @param row - The row index to get the vector from.\n * @returns A function that takes a matrix and returns the row vector at the specified index.\n * @since 1.0.0\n */\n (row: Matrix3x3Coordinate): (m: Matrix3x3) => Vector3\n} = internal.rowVector\n\nexport const columnVector: {\n /**\n * Gets a column vector from the matrix.\n *\n * @param m - The matrix to get the column vector from.\n * @param column - The column index to get the vector from.\n * @returns The column vector at the specified index.\n * @since 1.0.0\n */\n (m: Matrix3x3, column: Matrix3x3Coordinate): Vector3\n /**\n * Gets a column vector from the matrix.\n *\n * @param column - The column index to get the vector from.\n * @returns A function that takes a matrix and returns the column vector at the specified index.\n * @since 1.0.0\n */\n (column: Matrix3x3Coordinate): (m: Matrix3x3) => Vector3\n} = internal.columnVector\n\n/**\n * Transposes a `Matrix3x3`.\n *\n * @param m - The matrix to transpose.\n * @returns A new `Matrix3x3` instance that is the transpose of the input matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix3x3) => Matrix3x3 = internal.transpose\n\n/**\n * Reverses the rows of a `Matrix3x3`.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns A new `Matrix3x3` instance with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix3x3) => Matrix3x3 = internal.reverseRows\n\n/**\n * Reverses the columns of a `Matrix3x3`.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns A new `Matrix3x3` instance with the columns reversed.\n * @since 1.0.0\n */\nexport const reverseColumns: (m: Matrix3x3) => Matrix3x3 = internal.reverseColumns\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,cAA8CA;AAE3D,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SACXC;;;;;;;;;AAUF,MAAaC,aAAoDC;;;;;;;;;AAUjE,MAAaC,gBAAuDC;AAEpE,MAAaC,WAoBTC;AAEJ,MAAaC,cAoBTC;;;;;;;;AASJ,MAAaC,gBAAwCC;AAErD,MAAaC,sBA4CTC;AAEJ,MAAaC,uBA4CTC;AAEJ,MAAaC,gBA4CTC;;;;;;;;AASJ,MAAaC,WAA+CC;;;;;;;;AAS5D,MAAaC,cAAkDC;;;;;;;;;AAU/D,MAAaC,cAAiEC;;;;;;;;;AAU9E,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,cAAyCC;;;;;;;;AAStD,MAAaC,gBAA2CC;;;;;;;;AASxD,MAAaC,mBAA8CC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClS3D,MAAa,cAA8CC;AAE3D,MAAa,SAoBTC;;;;;;;;;;;;;;;;AAiBJ,MAAa,OAUIC;;;;;;;;;;AAWjB,MAAa,WAAiEC;;;;;;;;;;AAW9E,MAAa,cACXC;AAEF,MAAa,SAoBTC;AAEJ,MAAa,YAoBTC;;;;;;;;AASJ,MAAa,cAAwCC;;;;;;;;;;AAWrD,MAAa,QAIIC;AAEjB,MAAa,oBA8CTC;AAEJ,MAAa,qBA8CTC;AAEJ,MAAa,cAyCTC;;;;;;;;AASJ,MAAa,SAAwDC;;;;;;;;AAWrE,MAAa,YAA2DC;AAIxE,MAAa,YAkBTC;AAEJ,MAAa,eAkBTC;;;;;;;;AASJ,MAAa,YAAyCC;;;;;;;;AAStD,MAAa,cAA2CC;;;;;;;;AASxD,MAAa,iBAA8CC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["internal.isMatrix2x2","equals","internal.equals","make","internal.make","fromRows","internal.fromRows","fromColumns","internal.fromColumns","setRow","internal.setRow","setColumn","internal.setColumn","determinant","internal.determinant","vectorProductLeft","internal.vectorProductLeft","vectorProductRight","internal.vectorProductRight","solveSystem","internal.solveSystem","toRows","internal.toRows","toColumns","internal.toColumns","rowVector","internal.rowVector","columnVector","internal.columnVector","transpose","internal.transpose","reverseRows","internal.reverseRows","reverseColumns","internal.reverseColumns","internal.isMatrix3x3","internal.equals","internal.make","internal.fromRows","internal.fromColumns","internal.setRow","internal.setColumn","internal.determinant","internal.minor","internal.vectorProductLeft","internal.vectorProductRight","internal.solveSystem","internal.toRows","internal.toColumns","internal.rowVector","internal.columnVector","internal.transpose","internal.reverseRows","internal.reverseColumns","internal.identity","internal.multiply","internal.inverse","internal.inverseUnsafe","internal.isInvertible","internal.asInvertible"],"sources":["../../src/matrix/matrix2x2.ts","../../src/matrix/matrix3x3.ts"],"sourcesContent":["import type { TwoDimensionalComponent, TwoDimensionalIndex } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Matrix2x2TypeId } from './matrix2x2.internal.ts'\nimport * as internal from './matrix2x2.internal.ts'\n\n/**\n * A type representing the coordinate of a 2D matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix2x2Coordinate = TwoDimensionalIndex | TwoDimensionalComponent\n\n/**\n * A 2D matrix with 2 rows and 2 columns.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Matrix2x2 extends Pipeable {\n readonly [Matrix2x2TypeId]: Matrix2x2TypeId\n\n /**\n * The value in the first row and first column.\n */\n readonly m00: number\n /**\n * The value in the first row and second column.\n */\n readonly m01: number\n /**\n * The value in the second row and first column.\n */\n readonly m10: number\n /**\n * The value in the second row and second column.\n */\n readonly m11: number\n}\n\n/**\n * Checks if a value is a `Matrix2x2`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix2x2`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix2x2: (m: unknown) => m is Matrix2x2 = internal.isMatrix2x2\n\nexport const equals: {\n /**\n * Checks if two `Matrix2x2` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix2x2, b: Matrix2x2): boolean\n /**\n * Checks if two `Matrix2x2` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix2x2): (a: Matrix2x2) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix2x2` instance.\n *\n * @param m00 - The value in the first row and first column. Defaults to 0.\n * @param m01 - The value in the first row and second column. Defaults to 0.\n * @param m10 - The value in the second row and first column. Defaults to 0.\n * @param m11 - The value in the second row and second column. Defaults to 0.\n */\nexport const make: (m00?: number, m01?: number, m10?: number, m11?: number) => Matrix2x2 =\n internal.make\n\n/**\n * Creates a new `Matrix2x2` instance from two vectors representing rows.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @returns A new `Matrix2x2` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector2, v1: Vector2) => Matrix2x2 = internal.fromRows\n\n/**\n * Creates a new `Matrix2x2` instance from two vectors representing columns.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @returns A new `Matrix2x2` instance.\n * @since 1.0.0\n */\nexport const fromColumns: (v0: Vector2, v1: Vector2) => Matrix2x2 = internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets the specified row of the matrix to the given vector.\n *\n * @param m - The matrix to modify.\n * @param row - The row index (0 or 1).\n * @param v - The vector to set the row to.\n * @returns A new `Matrix2x2` instance with the specified row set to the given vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2): Matrix2x2\n /**\n * Sets the specified row of the matrix to the given vector.\n *\n * @param row - The row index (0 or 1).\n * @param v - The vector to set the row to.\n * @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified row set to the given vector.\n * @since 1.0.0\n */\n (row: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets the specified column of the matrix to the given vector.\n *\n * @param m - The matrix to modify.\n * @param column - The column index (0 or 1).\n * @param v - The vector to set the column to.\n * @returns A new `Matrix2x2` instance with the specified column set to the given vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2): Matrix2x2\n /**\n * Sets the specified column of the matrix to the given vector.\n *\n * @param column - The column index (0 or 1).\n * @param v - The vector to set the column to.\n * @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified column set to the given vector.\n * @since 1.0.0\n */\n (column: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a 2D matrix.\n *\n * @param m - The matrix to calculate the determinant for.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix2x2) => number = internal.determinant\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 2 * 6 = 17\n * // y = 3 * 5 + 4 * 6 = 39\n * const result = Matrix2x2.vectorProductLeft(matrix, vector)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector after the left vector product.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 2 * 6 = 17\n * // y = 3 * 5 + 4 * 6 = 39\n * const result = Matrix2x2.vectorProductLeft(vector)(matrix)\n * ```\n * @param v - The vector to multiply.\n * @returns A function that takes a matrix and returns the resulting vector after the left vector product.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 3 * 6 = 33\n * // y = 2 * 5 + 4 * 6 = 62\n * const result = Matrix2x2.vectorProductRight(matrix, vector)\n * ```\n * @param m - The matrix to multiply.\n * @param v - The vector to multiply.\n * @returns The resulting vector after the right vector product.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Performs:\n * // x = 1 * 5 + 3 * 6 = 33\n * // y = 2 * 5 + 4 * 6 = 62\n * const result = Matrix2x2.vectorProductRight(vector)(matrix)\n * ```\n * @param v - The vector to multiply.\n * @returns A function that takes a matrix and returns the resulting vector after the right vector product.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.vectorProductRight\n\nexport const solveSystem: {\n /**\n * Solves a system of linear equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Solves the system of equations:\n * // 1x + 2y = 5\n * // 3x + 4y = 6\n * const result = Matrix2x2.solveSystem(matrix, vector)\n * ```\n * @param m - The matrix representing the coefficients of the system.\n * @param v - The vector representing the constants of the system.\n * @returns The solution vector.\n * @since 1.0.0\n */\n (m: Matrix2x2, v: Vector2): Vector2\n /**\n * Solves a system of linear equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix2x2 from 'curvy/matrix2x2'\n * import * as Vector2 from 'curvy/vector2'\n *\n * const matrix = Matrix2x2.make(1, 2, 3, 4)\n * const vector = Vector2.make(5, 6)\n *\n * // Solves the system of equations:\n * // 1x + 2y = 5\n * // 3x + 4y = 6\n * const result = Matrix2x2.solveSystem(vector)(matrix)\n * ```\n * @param v - The vector representing the constants of the system.\n * @returns A function that takes a matrix and returns the solution vector.\n * @since 1.0.0\n */\n (v: Vector2): (m: Matrix2x2) => Vector2\n} = internal.solveSystem\n\n/**\n * Returns the rows of a matrix as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix2x2) => [Vector2, Vector2] = internal.toRows\n\n/**\n * Returns the columns of a matrix as an array of vectors.\n *\n * @param m - The matrix to convert.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix2x2) => [Vector2, Vector2] = internal.toColumns\n\n/**\n * Returns the specified row of a matrix as a vector.\n *\n * @param m - The matrix to get the row from.\n * @param row - The row index (0 or 1).\n * @returns A vector representing the specified row of the matrix.\n * @since 1.0.0\n */\nexport const rowVector: (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2 = internal.rowVector\n\n/**\n * Returns the specified column of a matrix as a vector.\n *\n * @param m - The matrix to get the column from.\n * @param column - The column index (0 or 1).\n * @returns A vector representing the specified column of the matrix.\n * @since 1.0.0\n */\nexport const columnVector: (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2 =\n internal.columnVector\n\n/**\n * Transposes a matrix.\n *\n * @param m - The matrix to transpose.\n * @returns A new `Matrix2x2` instance representing the transposed matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix2x2) => Matrix2x2 = internal.transpose\n\n/**\n * Reverses the rows of a matrix.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns A new `Matrix2x2` instance with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix2x2) => Matrix2x2 = internal.reverseRows\n\n/**\n * Reverses the columns of a matrix.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns A new `Matrix2x2` instance with the columns reversed.\n * @since 1.0.0\n */\nexport const reverseColumns: (m: Matrix2x2) => Matrix2x2 = internal.reverseColumns\n","import type { ThreeDimensionalComponent, ThreeDimensionalIndex } from '../dimensions.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { Matrix2x2 } from './matrix2x2.ts'\nimport type { Matrix3x3TypeId } from './matrix3x3.internal.ts'\nimport * as internal from './matrix3x3.internal.ts'\nimport type { Invertible, MatrixTraits } from './traits.ts'\n\nexport type { Invertible } from './traits.ts'\n\n/**\n * A coordinate in a 3x3 matrix.\n *\n * @since 1.0.0\n */\nexport type Matrix3x3Coordinate = ThreeDimensionalIndex | ThreeDimensionalComponent\n\n/**\n * A 3x3 matrix.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the matrix is refined via `isInvertible` / `asInvertible`. The\n * runtime value carries no trait data — `Traits` only flows through the type\n * system to enable tighter return types on operations like {@link inverse}.\n *\n * @since 1.0.0\n */\nexport interface Matrix3x3<out Traits = unknown> extends Pipeable {\n readonly [Matrix3x3TypeId]: Matrix3x3TypeId\n readonly [MatrixTraits]: Traits\n /**\n * The value of the first row and first column.\n */\n readonly m00: number\n /**\n * The value of the first row and second column.\n */\n readonly m01: number\n /**\n * The value of the first row and third column.\n */\n readonly m02: number\n /**\n * The value of the second row and first column.\n */\n readonly m10: number\n /**\n * The value of the second row and second column.\n */\n readonly m11: number\n /**\n * The value of the second row and third column.\n */\n readonly m12: number\n /**\n * The value of the third row and first column.\n */\n readonly m20: number\n /**\n * The value of the third row and second column.\n */\n readonly m21: number\n /**\n * The value of the third row and third column.\n */\n readonly m22: number\n}\n\n/**\n * Checks if a value is a `Matrix3x3`.\n *\n * @param m - The value to check.\n * @returns `true` if the value is a `Matrix3x3`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isMatrix3x3: (m: unknown) => m is Matrix3x3 = internal.isMatrix3x3\n\nexport const equals: {\n /**\n * Checks if two `Matrix3x3` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first matrix.\n * @param b - The second matrix.\n * @returns `true` when each pair of components is within tolerance.\n * @since 1.1.0\n */\n (a: Matrix3x3, b: Matrix3x3): boolean\n /**\n * Checks if two `Matrix3x3` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second matrix.\n * @returns A function that takes the first matrix and returns the comparison result.\n * @since 1.1.0\n */\n (b: Matrix3x3): (a: Matrix3x3) => boolean\n} = internal.equals\n\n/**\n * Creates a new `Matrix3x3` instance.\n *\n * @param m00 - The value of the first row and first column.\n * @param m01 - The value of the first row and second column.\n * @param m02 - The value of the first row and third column.\n * @param m10 - The value of the second row and first column.\n * @param m11 - The value of the second row and second column.\n * @param m12 - The value of the second row and third column.\n * @param m20 - The value of the third row and first column.\n * @param m21 - The value of the third row and second column.\n * @param m22 - The value of the third row and third column.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const make: (\n m00?: number,\n m01?: number,\n m02?: number,\n m10?: number,\n m11?: number,\n m12?: number,\n m20?: number,\n m21?: number,\n m22?: number,\n) => Matrix3x3 = internal.make\n\n/**\n * Creates a new `Matrix3x3` instance from three row vectors.\n *\n * @param v0 - The first row vector.\n * @param v1 - The second row vector.\n * @param v2 - The third row vector.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const fromRows: (v0: Vector3, v1: Vector3, v2: Vector3) => Matrix3x3 = internal.fromRows\n\n/**\n * Creates a new `Matrix3x3` instance from three column vectors.\n *\n * @param v0 - The first column vector.\n * @param v1 - The second column vector.\n * @param v2 - The third column vector.\n * @returns A new `Matrix3x3` instance.\n * @since 1.0.0\n */\nexport const fromColumns: (v0: Vector3, v1: Vector3, v2: Vector3) => Matrix3x3 =\n internal.fromColumns\n\nexport const setRow: {\n /**\n * Sets a row of the matrix to a new vector.\n *\n * @param m - The matrix to set the row of.\n * @param row - The row index to set.\n * @param v - The new vector for the row.\n * @returns A new matrix with the specified row set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix3x3, row: Matrix3x3Coordinate, v: Vector3): Matrix3x3\n /**\n * Sets a row of the matrix to a new vector.\n *\n * @param row - The row index to set.\n * @param v - The new vector for the row.\n * @returns A function that takes a matrix and returns a new matrix with the specified row set to the new vector.\n * @since 1.0.0\n */\n (row: Matrix3x3Coordinate, v: Vector3): (m: Matrix3x3) => Matrix3x3\n} = internal.setRow\n\nexport const setColumn: {\n /**\n * Sets a column of the matrix to a new vector.\n *\n * @param m - The matrix to set the column of.\n * @param column - The column index to set.\n * @param v - The new vector for the column.\n * @returns A new matrix with the specified column set to the new vector.\n * @since 1.0.0\n */\n (m: Matrix3x3, column: Matrix3x3Coordinate, v: Vector3): Matrix3x3\n /**\n * Sets a column of the matrix to a new vector.\n *\n * @param column - The column index to set.\n * @param v - The new vector for the column.\n * @returns A function that takes a matrix and returns a new matrix with the specified column set to the new vector.\n * @since 1.0.0\n */\n (column: Matrix3x3Coordinate, v: Vector3): (m: Matrix3x3) => Matrix3x3\n} = internal.setColumn\n\n/**\n * Calculates the determinant of a 3x3 matrix.\n *\n * @param m - The matrix to calculate the determinant of.\n * @returns The determinant of the matrix.\n * @since 1.0.0\n */\nexport const determinant: (m: Matrix3x3) => number = internal.determinant\n\n/**\n * Calculates the minor of a 3x3 matrix.\n *\n * @param m - The matrix to calculate the minor of.\n * @param row - The row index of the element to calculate the minor for.\n * @param column - The column index of the element to calculate the minor for.\n * @returns The minor of the matrix at the specified row and column.\n * @since 1.0.0\n */\nexport const minor: (\n m: Matrix3x3,\n row: Matrix3x3Coordinate,\n column: Matrix3x3Coordinate,\n) => Matrix2x2 = internal.minor\n\nexport const vectorProductLeft: {\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 2 * 11 + 3 * 12\n * // y = 4 * 10 + 5 * 11 + 6 * 12\n * // z = 7 * 10 + 8 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductLeft(m, v)\n * ```\n * @param m - The matrix to calculate the left vector product with.\n * @param v - The vector to calculate the left vector product with.\n * @returns The resulting vector from the left vector product.\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Calculates the left vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 2 * 11 + 3 * 12\n * // y = 4 * 10 + 5 * 11 + 6 * 12\n * // z = 7 * 10 + 8 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductLeft(v)(m)\n * ```\n * @param v - The vector to calculate the left vector product with.\n * @returns A function that takes a matrix and returns the resulting vector from the left vector product.\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.vectorProductLeft\n\nexport const vectorProductRight: {\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 4 * 11 + 7 * 12\n * // y = 2 * 10 + 5 * 11 + 8 * 12\n * // z = 3 * 10 + 6 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductRight(m, v)\n * ```\n * @param m - The matrix to calculate the right vector product with.\n * @param v - The vector to calculate the right vector product with.\n * @returns The resulting vector from the right vector product.\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Calculates the right vector product of a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = 1 * 10 + 4 * 11 + 7 * 12\n * // y = 2 * 10 + 5 * 11 + 8 * 12\n * // z = 3 * 10 + 6 * 11 + 9 * 12\n * const result = Matrix3x3.vectorProductRight(v)(m)\n * ```\n * @param v - The vector to calculate the right vector product with.\n * @returns A function that takes a matrix and returns the resulting vector from the right vector product.\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.vectorProductRight\n\nexport const solveSystem: {\n /**\n * Solves a system of equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = m00 * x + m01 * y + m02 * z\n * // y = m10 * x + m11 * y + m12 * z\n * // z = m20 * x + m21 * y + m22 * z\n * const result = Matrix3x3.solveSystem(m, v)\n * ```\n * @since 1.0.0\n */\n (m: Matrix3x3, v: Vector3): Vector3\n /**\n * Solves a system of equations represented by a matrix and a vector.\n *\n * @example\n * ```ts\n * import * as Matrix3x3 from 'curvy/matrix3x3'\n * import * as Vector3 from 'curvy/vector3'\n *\n * const m = Matrix3x3.make(1, 2, 3, 4, 5, 6, 7, 8, 9)\n * const v = Vector3.vector3(10, 11, 12)\n *\n * // Performs:\n * // x = m00 * x + m01 * y + m02 * z\n * // y = m10 * x + m11 * y + m12 * z\n * // z = m20 * x + m21 * y + m22 * z\n * const result = Matrix3x3.solveSystem(v)(m)\n * ```\n * @since 1.0.0\n */\n (v: Vector3): (m: Matrix3x3) => Vector3\n} = internal.solveSystem\n\n/**\n * Returns the rows of a `Matrix3x3` as an array of vectors.\n *\n * @param m - The matrix to get the rows from.\n * @returns An array of vectors representing the rows of the matrix.\n * @since 1.0.0\n */\nexport const toRows: (m: Matrix3x3) => [Vector3, Vector3, Vector3] = internal.toRows as (\n m: Matrix3x3,\n) => [Vector3, Vector3, Vector3]\n\n/**\n * Returns the columns of a `Matrix3x3` as an array of vectors.\n *\n * @param m - The matrix to get the columns from.\n * @returns An array of vectors representing the columns of the matrix.\n * @since 1.0.0\n */\nexport const toColumns: (m: Matrix3x3) => [Vector3, Vector3, Vector3] = internal.toColumns as (\n m: Matrix3x3,\n) => [Vector3, Vector3, Vector3]\n\nexport const rowVector: {\n /**\n * Gets a row vector from the matrix.\n *\n * @param m - The matrix to get the row vector from.\n * @param row - The row index to get the vector from.\n * @returns The row vector at the specified index.\n * @since 1.0.0\n */\n (m: Matrix3x3, row: Matrix3x3Coordinate): Vector3\n /**\n * Gets a row vector from the matrix.\n *\n * @param row - The row index to get the vector from.\n * @returns A function that takes a matrix and returns the row vector at the specified index.\n * @since 1.0.0\n */\n (row: Matrix3x3Coordinate): (m: Matrix3x3) => Vector3\n} = internal.rowVector\n\nexport const columnVector: {\n /**\n * Gets a column vector from the matrix.\n *\n * @param m - The matrix to get the column vector from.\n * @param column - The column index to get the vector from.\n * @returns The column vector at the specified index.\n * @since 1.0.0\n */\n (m: Matrix3x3, column: Matrix3x3Coordinate): Vector3\n /**\n * Gets a column vector from the matrix.\n *\n * @param column - The column index to get the vector from.\n * @returns A function that takes a matrix and returns the column vector at the specified index.\n * @since 1.0.0\n */\n (column: Matrix3x3Coordinate): (m: Matrix3x3) => Vector3\n} = internal.columnVector\n\n/**\n * Transposes a `Matrix3x3`.\n *\n * @param m - The matrix to transpose.\n * @returns A new `Matrix3x3` instance that is the transpose of the input matrix.\n * @since 1.0.0\n */\nexport const transpose: (m: Matrix3x3) => Matrix3x3 = internal.transpose\n\n/**\n * Reverses the rows of a `Matrix3x3`.\n *\n * @param m - The matrix to reverse the rows of.\n * @returns A new `Matrix3x3` instance with the rows reversed.\n * @since 1.0.0\n */\nexport const reverseRows: (m: Matrix3x3) => Matrix3x3 = internal.reverseRows\n\n/**\n * Reverses the columns of a `Matrix3x3`.\n *\n * @param m - The matrix to reverse the columns of.\n * @returns A new `Matrix3x3` instance with the columns reversed.\n * @since 1.0.0\n */\nexport const reverseColumns: (m: Matrix3x3) => Matrix3x3 = internal.reverseColumns\n\n/**\n * The 3x3 identity matrix.\n *\n * @since 2.0.0\n */\nexport const identity: Matrix3x3 = internal.identity\n\nexport const multiply: {\n /**\n * Multiplies two `Matrix3x3` instances. Result is `a · b`.\n *\n * @param a - The left-hand matrix.\n * @param b - The right-hand matrix.\n * @returns The product matrix.\n * @since 2.0.0\n */\n (a: Matrix3x3, b: Matrix3x3): Matrix3x3\n /**\n * Multiplies two `Matrix3x3` instances. Result is `a · b`.\n *\n * @param b - The right-hand matrix.\n * @returns A function that takes the left-hand matrix and returns the product.\n * @since 2.0.0\n */\n (b: Matrix3x3): (a: Matrix3x3) => Matrix3x3\n} = internal.multiply\n\n// The implementation always runs the same det/threshold branch. For\n// `Invertible`-branded matrices the empty branch is provably unreachable,\n// but TS can't see that — the cast pairs the type-level promise with the\n// runtime brand check.\nexport const inverse: {\n /**\n * Returns the inverse of an `Invertible`-branded `Matrix3x3`. Because the\n * brand guarantees non-singularity, the result is always a single matrix —\n * wrapped in `Solution.One`.\n *\n * @param m - The matrix to invert.\n * @since 2.0.0\n */\n <T extends Invertible>(m: Matrix3x3<T>): Solution.One<Matrix3x3<T>>\n /**\n * Returns the inverse of a `Matrix3x3`. Returns `Solution.none` if the\n * matrix is singular (determinant approximately zero). Use {@link asInvertible}\n * or {@link isInvertible} to refine the type and tighten the return to\n * `Solution.One`, or use {@link inverseUnsafe} if you want the throwing form.\n *\n * @param m - The matrix to invert.\n * @since 2.0.0\n */\n <T>(m: Matrix3x3<T>): Solution.AtMostOne<Matrix3x3<T>>\n} = internal.inverse as never\n\n/**\n * Returns the inverse of a `Matrix3x3`. Throws when the matrix is singular\n * (determinant approximately zero). Useful when you've already validated\n * invertibility out-of-band and want the unwrapped matrix directly; otherwise\n * prefer {@link inverse}.\n *\n * @param m - The matrix to invert.\n * @returns The inverse matrix.\n * @throws If `m` is singular.\n * @since 2.0.0\n */\nexport const inverseUnsafe: (m: Matrix3x3) => Matrix3x3 = internal.inverseUnsafe\n\n/**\n * Type-narrowing predicate: refines a `Matrix3x3<T>` to\n * `Matrix3x3<T & Invertible>` when the matrix's determinant is non-zero\n * (within the default absolute tolerance).\n *\n * @param m - The matrix to check.\n * @returns `true` when `m` is invertible.\n * @since 2.0.0\n */\nexport const isInvertible: <T>(m: Matrix3x3<T>) => m is Matrix3x3<T & Invertible> =\n internal.isInvertible\n\n/**\n * Asserts that the matrix is invertible, throwing on a singular matrix.\n *\n * @param m - The matrix to assert against.\n * @returns The same matrix, typed with the `Invertible` brand.\n * @throws When `m` is singular.\n * @since 2.0.0\n */\nexport const asInvertible: <T>(m: Matrix3x3<T>) => Matrix3x3<T & Invertible> = internal.asInvertible\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,cAA8CA;AAE3D,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SACXC;;;;;;;;;AAUF,MAAaC,aAAoDC;;;;;;;;;AAUjE,MAAaC,gBAAuDC;AAEpE,MAAaC,WAoBTC;AAEJ,MAAaC,cAoBTC;;;;;;;;AASJ,MAAaC,gBAAwCC;AAErD,MAAaC,sBA4CTC;AAEJ,MAAaC,uBA4CTC;AAEJ,MAAaC,gBA4CTC;;;;;;;;AASJ,MAAaC,WAA+CC;;;;;;;;AAS5D,MAAaC,cAAkDC;;;;;;;;;AAU/D,MAAaC,cAAiEC;;;;;;;;;AAU9E,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,cAAyCC;;;;;;;;AAStD,MAAaC,gBAA2CC;;;;;;;;AASxD,MAAaC,mBAA8CC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxR3D,MAAa,cAA8CC;AAE3D,MAAa,SAoBTC;;;;;;;;;;;;;;;;AAiBJ,MAAa,OAUIC;;;;;;;;;;AAWjB,MAAa,WAAiEC;;;;;;;;;;AAW9E,MAAa,cACXC;AAEF,MAAa,SAoBTC;AAEJ,MAAa,YAoBTC;;;;;;;;AASJ,MAAa,cAAwCC;;;;;;;;;;AAWrD,MAAa,QAIIC;AAEjB,MAAa,oBA8CTC;AAEJ,MAAa,qBA8CTC;AAEJ,MAAa,cAyCTC;;;;;;;;AASJ,MAAa,SAAwDC;;;;;;;;AAWrE,MAAa,YAA2DC;AAIxE,MAAa,YAkBTC;AAEJ,MAAa,eAkBTC;;;;;;;;AASJ,MAAa,YAAyCC;;;;;;;;AAStD,MAAa,cAA2CC;;;;;;;;AASxD,MAAa,iBAA8CC;;;;;;AAO3D,MAAa,WAAsBC;AAEnC,MAAa,WAkBTC;AAMJ,MAAa,UAoBTC;;;;;;;;;;;;AAaJ,MAAa,gBAA6CC;;;;;;;;;;AAW1D,MAAa,eACXC;;;;;;;;;AAUF,MAAa,eAAkEC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ThreeDimensionalComponent, ThreeDimensionalIndex } from '../dimensions.ts';
|
|
2
|
+
import type * as Solution from '../solution/solution.ts';
|
|
2
3
|
import type { Pipeable } from '../utils.ts';
|
|
3
4
|
import type { Vector3 } from '../vector/vector3.ts';
|
|
4
5
|
import type { Matrix2x2 } from './matrix2x2.ts';
|
|
5
6
|
import type { Matrix3x3TypeId } from './matrix3x3.internal.ts';
|
|
7
|
+
import type { Invertible, MatrixTraits } from './traits.ts';
|
|
8
|
+
export type { Invertible } from './traits.ts';
|
|
6
9
|
/**
|
|
7
10
|
* A coordinate in a 3x3 matrix.
|
|
8
11
|
*
|
|
@@ -14,10 +17,16 @@ export type Matrix3x3Coordinate = ThreeDimensionalIndex | ThreeDimensionalCompon
|
|
|
14
17
|
*
|
|
15
18
|
* All fields are readonly and immutable, and all operations create new instances.
|
|
16
19
|
*
|
|
20
|
+
* The `Traits` type parameter is a phantom marker that accumulates trait
|
|
21
|
+
* brands as the matrix is refined via `isInvertible` / `asInvertible`. The
|
|
22
|
+
* runtime value carries no trait data — `Traits` only flows through the type
|
|
23
|
+
* system to enable tighter return types on operations like {@link inverse}.
|
|
24
|
+
*
|
|
17
25
|
* @since 1.0.0
|
|
18
26
|
*/
|
|
19
|
-
export interface Matrix3x3 extends Pipeable {
|
|
27
|
+
export interface Matrix3x3<out Traits = unknown> extends Pipeable {
|
|
20
28
|
readonly [Matrix3x3TypeId]: Matrix3x3TypeId;
|
|
29
|
+
readonly [MatrixTraits]: Traits;
|
|
21
30
|
/**
|
|
22
31
|
* The value of the first row and first column.
|
|
23
32
|
*/
|
|
@@ -394,3 +403,80 @@ export declare const reverseRows: (m: Matrix3x3) => Matrix3x3;
|
|
|
394
403
|
* @since 1.0.0
|
|
395
404
|
*/
|
|
396
405
|
export declare const reverseColumns: (m: Matrix3x3) => Matrix3x3;
|
|
406
|
+
/**
|
|
407
|
+
* The 3x3 identity matrix.
|
|
408
|
+
*
|
|
409
|
+
* @since 2.0.0
|
|
410
|
+
*/
|
|
411
|
+
export declare const identity: Matrix3x3;
|
|
412
|
+
export declare const multiply: {
|
|
413
|
+
/**
|
|
414
|
+
* Multiplies two `Matrix3x3` instances. Result is `a · b`.
|
|
415
|
+
*
|
|
416
|
+
* @param a - The left-hand matrix.
|
|
417
|
+
* @param b - The right-hand matrix.
|
|
418
|
+
* @returns The product matrix.
|
|
419
|
+
* @since 2.0.0
|
|
420
|
+
*/
|
|
421
|
+
(a: Matrix3x3, b: Matrix3x3): Matrix3x3;
|
|
422
|
+
/**
|
|
423
|
+
* Multiplies two `Matrix3x3` instances. Result is `a · b`.
|
|
424
|
+
*
|
|
425
|
+
* @param b - The right-hand matrix.
|
|
426
|
+
* @returns A function that takes the left-hand matrix and returns the product.
|
|
427
|
+
* @since 2.0.0
|
|
428
|
+
*/
|
|
429
|
+
(b: Matrix3x3): (a: Matrix3x3) => Matrix3x3;
|
|
430
|
+
};
|
|
431
|
+
export declare const inverse: {
|
|
432
|
+
/**
|
|
433
|
+
* Returns the inverse of an `Invertible`-branded `Matrix3x3`. Because the
|
|
434
|
+
* brand guarantees non-singularity, the result is always a single matrix —
|
|
435
|
+
* wrapped in `Solution.One`.
|
|
436
|
+
*
|
|
437
|
+
* @param m - The matrix to invert.
|
|
438
|
+
* @since 2.0.0
|
|
439
|
+
*/
|
|
440
|
+
<T extends Invertible>(m: Matrix3x3<T>): Solution.One<Matrix3x3<T>>;
|
|
441
|
+
/**
|
|
442
|
+
* Returns the inverse of a `Matrix3x3`. Returns `Solution.none` if the
|
|
443
|
+
* matrix is singular (determinant approximately zero). Use {@link asInvertible}
|
|
444
|
+
* or {@link isInvertible} to refine the type and tighten the return to
|
|
445
|
+
* `Solution.One`, or use {@link inverseUnsafe} if you want the throwing form.
|
|
446
|
+
*
|
|
447
|
+
* @param m - The matrix to invert.
|
|
448
|
+
* @since 2.0.0
|
|
449
|
+
*/
|
|
450
|
+
<T>(m: Matrix3x3<T>): Solution.AtMostOne<Matrix3x3<T>>;
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Returns the inverse of a `Matrix3x3`. Throws when the matrix is singular
|
|
454
|
+
* (determinant approximately zero). Useful when you've already validated
|
|
455
|
+
* invertibility out-of-band and want the unwrapped matrix directly; otherwise
|
|
456
|
+
* prefer {@link inverse}.
|
|
457
|
+
*
|
|
458
|
+
* @param m - The matrix to invert.
|
|
459
|
+
* @returns The inverse matrix.
|
|
460
|
+
* @throws If `m` is singular.
|
|
461
|
+
* @since 2.0.0
|
|
462
|
+
*/
|
|
463
|
+
export declare const inverseUnsafe: (m: Matrix3x3) => Matrix3x3;
|
|
464
|
+
/**
|
|
465
|
+
* Type-narrowing predicate: refines a `Matrix3x3<T>` to
|
|
466
|
+
* `Matrix3x3<T & Invertible>` when the matrix's determinant is non-zero
|
|
467
|
+
* (within the default absolute tolerance).
|
|
468
|
+
*
|
|
469
|
+
* @param m - The matrix to check.
|
|
470
|
+
* @returns `true` when `m` is invertible.
|
|
471
|
+
* @since 2.0.0
|
|
472
|
+
*/
|
|
473
|
+
export declare const isInvertible: <T>(m: Matrix3x3<T>) => m is Matrix3x3<T & Invertible>;
|
|
474
|
+
/**
|
|
475
|
+
* Asserts that the matrix is invertible, throwing on a singular matrix.
|
|
476
|
+
*
|
|
477
|
+
* @param m - The matrix to assert against.
|
|
478
|
+
* @returns The same matrix, typed with the `Invertible` brand.
|
|
479
|
+
* @throws When `m` is singular.
|
|
480
|
+
* @since 2.0.0
|
|
481
|
+
*/
|
|
482
|
+
export declare const asInvertible: <T>(m: Matrix3x3<T>) => Matrix3x3<T & Invertible>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { FourDimensionalComponent, FourDimensionalIndex } from '../dimensions.ts';
|
|
2
|
+
import type * as Solution from '../solution/solution.ts';
|
|
2
3
|
import type { Pipeable } from '../utils.ts';
|
|
3
4
|
import type { Vector4 } from '../vector/vector4.ts';
|
|
4
5
|
import type { Matrix3x3 } from './matrix3x3.ts';
|
|
5
6
|
import type { Matrix4x4TypeId } from './matrix4x4.internal.ts';
|
|
7
|
+
import type { Invertible, MatrixTraits } from './traits.ts';
|
|
8
|
+
export type { Invertible } from './traits.ts';
|
|
6
9
|
/**
|
|
7
10
|
* A coordinate in a 4x4 matrix.
|
|
8
11
|
*
|
|
@@ -14,10 +17,16 @@ export type Matrix4x4Coordinate = FourDimensionalIndex | FourDimensionalComponen
|
|
|
14
17
|
*
|
|
15
18
|
* All fields are readonly and immutable, and all operations create new instances.
|
|
16
19
|
*
|
|
20
|
+
* The `Traits` type parameter is a phantom marker that accumulates trait
|
|
21
|
+
* brands as the matrix is refined via `isInvertible` / `asInvertible`. The
|
|
22
|
+
* runtime value carries no trait data — `Traits` only flows through the type
|
|
23
|
+
* system to enable tighter return types on operations like {@link inverse}.
|
|
24
|
+
*
|
|
17
25
|
* @since 1.0.0
|
|
18
26
|
*/
|
|
19
|
-
export interface Matrix4x4 extends Pipeable {
|
|
27
|
+
export interface Matrix4x4<out Traits = unknown> extends Pipeable {
|
|
20
28
|
readonly [Matrix4x4TypeId]: Matrix4x4TypeId;
|
|
29
|
+
readonly [MatrixTraits]: Traits;
|
|
21
30
|
/**
|
|
22
31
|
* The value of the first row and first column.
|
|
23
32
|
*/
|
|
@@ -330,16 +339,58 @@ export declare const multiply: {
|
|
|
330
339
|
*/
|
|
331
340
|
(b: Matrix4x4): (a: Matrix4x4) => Matrix4x4;
|
|
332
341
|
};
|
|
342
|
+
export declare const inverse: {
|
|
343
|
+
/**
|
|
344
|
+
* Returns the inverse of an `Invertible`-branded `Matrix4x4`. Because the
|
|
345
|
+
* brand guarantees non-singularity, the result is always a single matrix —
|
|
346
|
+
* wrapped in `Solution.One`.
|
|
347
|
+
*
|
|
348
|
+
* @param m - The matrix to invert.
|
|
349
|
+
* @since 2.0.0
|
|
350
|
+
*/
|
|
351
|
+
<T extends Invertible>(m: Matrix4x4<T>): Solution.One<Matrix4x4<T>>;
|
|
352
|
+
/**
|
|
353
|
+
* Returns the inverse of a `Matrix4x4`. Returns `Solution.none` if the
|
|
354
|
+
* matrix is singular (determinant approximately zero). Use {@link asInvertible}
|
|
355
|
+
* or {@link isInvertible} to refine the type and tighten the return to
|
|
356
|
+
* `Solution.One`, or use {@link inverseUnsafe} if you want the throwing form.
|
|
357
|
+
*
|
|
358
|
+
* @param m - The matrix to invert.
|
|
359
|
+
* @since 2.0.0
|
|
360
|
+
*/
|
|
361
|
+
<T>(m: Matrix4x4<T>): Solution.AtMostOne<Matrix4x4<T>>;
|
|
362
|
+
};
|
|
333
363
|
/**
|
|
334
|
-
* Returns the inverse of a `Matrix4x4`.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
364
|
+
* Returns the inverse of a `Matrix4x4`. Throws when the matrix is singular
|
|
365
|
+
* (determinant approximately zero). Useful when you've already validated
|
|
366
|
+
* invertibility out-of-band and want the unwrapped matrix directly; otherwise
|
|
367
|
+
* prefer {@link inverse}.
|
|
337
368
|
*
|
|
338
369
|
* @param m - The matrix to invert.
|
|
339
370
|
* @returns The inverse matrix.
|
|
340
|
-
* @
|
|
371
|
+
* @throws If `m` is singular.
|
|
372
|
+
* @since 2.0.0
|
|
373
|
+
*/
|
|
374
|
+
export declare const inverseUnsafe: (m: Matrix4x4) => Matrix4x4;
|
|
375
|
+
/**
|
|
376
|
+
* Type-narrowing predicate: refines a `Matrix4x4<T>` to
|
|
377
|
+
* `Matrix4x4<T & Invertible>` when the matrix's determinant is non-zero
|
|
378
|
+
* (within the default absolute tolerance).
|
|
379
|
+
*
|
|
380
|
+
* @param m - The matrix to check.
|
|
381
|
+
* @returns `true` when `m` is invertible.
|
|
382
|
+
* @since 2.0.0
|
|
383
|
+
*/
|
|
384
|
+
export declare const isInvertible: <T>(m: Matrix4x4<T>) => m is Matrix4x4<T & Invertible>;
|
|
385
|
+
/**
|
|
386
|
+
* Asserts that the matrix is invertible, throwing on a singular matrix.
|
|
387
|
+
*
|
|
388
|
+
* @param m - The matrix to assert against.
|
|
389
|
+
* @returns The same matrix, typed with the `Invertible` brand.
|
|
390
|
+
* @throws When `m` is singular.
|
|
391
|
+
* @since 2.0.0
|
|
341
392
|
*/
|
|
342
|
-
export declare const
|
|
393
|
+
export declare const asInvertible: <T>(m: Matrix4x4<T>) => Matrix4x4<T & Invertible>;
|
|
343
394
|
export declare const solveSystem: {
|
|
344
395
|
/**
|
|
345
396
|
* Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trait brands for matrices.
|
|
3
|
+
*
|
|
4
|
+
* Brands are phantom types — they exist only at the type level and carry no
|
|
5
|
+
* runtime data. A matrix value at runtime is identical regardless of the
|
|
6
|
+
* traits attached to its type. Refiners (`isInvertible`) and assertions
|
|
7
|
+
* (`asInvertible`) on each matrix module attach these brands to the matrix's
|
|
8
|
+
* `Traits` parameter at the type level.
|
|
9
|
+
*
|
|
10
|
+
* @since 2.0.0
|
|
11
|
+
*/
|
|
12
|
+
declare const InvertibleId: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Brand for invertible matrices — matrices whose determinant is non-zero
|
|
15
|
+
* (within the default absolute tolerance). An `Invertible`-branded matrix
|
|
16
|
+
* narrows {@link inverse} from `Solution.AtMostOne` to `Solution.One`.
|
|
17
|
+
*
|
|
18
|
+
* @since 2.0.0
|
|
19
|
+
*/
|
|
20
|
+
export type Invertible = {
|
|
21
|
+
readonly [InvertibleId]: 'invertible';
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Phantom property key used by matrix interfaces to hold their `Traits` type
|
|
25
|
+
* parameter. The runtime object never has a value at this key — the `declare`
|
|
26
|
+
* modifier on the impl class makes the property type-visible only. The symbol
|
|
27
|
+
* itself is exported as a real value so that bundlers can resolve the
|
|
28
|
+
* computed key reference even though the property is never assigned.
|
|
29
|
+
*
|
|
30
|
+
* @since 2.0.0
|
|
31
|
+
*/
|
|
32
|
+
export declare const MatrixTraits: unique symbol;
|
|
33
|
+
export type MatrixTraits = typeof MatrixTraits;
|
|
34
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as monotonicity_exports } from "../shared/monotonicity-
|
|
1
|
+
import { r as monotonicity_exports } from "../shared/monotonicity-DNxBoC7F.mjs";
|
|
2
2
|
export { monotonicity_exports as Monotonicity };
|
|
@@ -78,3 +78,28 @@ export declare const isStrict: (m: Monotonicity) => m is 1 | 2;
|
|
|
78
78
|
* @since 2.0.0
|
|
79
79
|
*/
|
|
80
80
|
export declare const fromComparison: (s0: number, s1: number) => GuaranteedMonotonicity;
|
|
81
|
+
/**
|
|
82
|
+
* Classifies monotonicity from the extreme values of a function's derivative
|
|
83
|
+
* over an interval, tolerating rounding noise in the derivative.
|
|
84
|
+
*
|
|
85
|
+
* `min` and `max` must be the true range extremes of the derivative on the
|
|
86
|
+
* interval (for a polynomial derivative: its values at the interval endpoints
|
|
87
|
+
* and at any interior stationary point). Each bound sets its sign-coverage
|
|
88
|
+
* bit only when it exceeds the tolerance, so a derivative that merely grazes
|
|
89
|
+
* zero — or dips past it by an ulp-scale amount that construction arithmetic
|
|
90
|
+
* cannot distinguish from zero — does not register as a crossing.
|
|
91
|
+
*
|
|
92
|
+
* The default tolerance is {@link RELATIVE_TOLERANCE} scaled by the larger
|
|
93
|
+
* bound magnitude, making the classification invariant under scaling of the
|
|
94
|
+
* input data. Derivative values are used rather than derivative *root
|
|
95
|
+
* locations* because values are well-conditioned where roots are not: a root
|
|
96
|
+
* computed from rounded coefficients can land on either side of an interval
|
|
97
|
+
* boundary, while the value it corresponds to stays pinned near zero.
|
|
98
|
+
*
|
|
99
|
+
* @param min - The smallest derivative value attained on the interval.
|
|
100
|
+
* @param max - The largest derivative value attained on the interval.
|
|
101
|
+
* @param tolerance - Absolute threshold below which a derivative value is treated as zero. Defaults to `RELATIVE_TOLERANCE * max(|min|, |max|)`.
|
|
102
|
+
* @returns The sign-coverage classification.
|
|
103
|
+
* @since 2.0.0
|
|
104
|
+
*/
|
|
105
|
+
export declare const fromDerivativeRange: (min: number, max: number, tolerance?: number) => Monotonicity;
|
package/dist/number.d.ts
CHANGED
|
@@ -4,9 +4,32 @@
|
|
|
4
4
|
* @since 1.1.0
|
|
5
5
|
*/
|
|
6
6
|
export declare const EPSILON = 1e-10;
|
|
7
|
+
/**
|
|
8
|
+
* Default relative tolerance for sign and degeneracy decisions about
|
|
9
|
+
* *computed* quantities — derivative values, determinants, discriminants.
|
|
10
|
+
*
|
|
11
|
+
* Scale-free: multiply by the natural magnitude of the quantity under test
|
|
12
|
+
* (e.g. the largest derivative value over the interval) to get an absolute
|
|
13
|
+
* threshold. Values inside the resulting band are indistinguishable from
|
|
14
|
+
* accumulated rounding noise and must not decide a sign question.
|
|
15
|
+
*
|
|
16
|
+
* The value sits ~4,500× above IEEE double rounding noise (2⁻⁵² ≈ 2.2e-16
|
|
17
|
+
* relative per operation) — generous headroom for noise accumulated across a
|
|
18
|
+
* construction pipeline — and far below any geometrically meaningful feature.
|
|
19
|
+
*
|
|
20
|
+
* @since 2.0.0
|
|
21
|
+
*/
|
|
22
|
+
export declare const RELATIVE_TOLERANCE = 1e-12;
|
|
7
23
|
/**
|
|
8
24
|
* Approximate equality between two numbers, within an absolute tolerance.
|
|
9
25
|
*
|
|
26
|
+
* This is the raw absolute comparison — the right tool when the domain is
|
|
27
|
+
* normalized by construction (curve parameter space, where `[0, 1]` makes an
|
|
28
|
+
* absolute band meaningful) or when a caller-chosen absolute band is the
|
|
29
|
+
* actual question. For identity questions about computed values of arbitrary
|
|
30
|
+
* magnitude ("is this the same point / value?"), use {@link coincident},
|
|
31
|
+
* which adds a magnitude-relative term.
|
|
32
|
+
*
|
|
10
33
|
* @param a - The first value.
|
|
11
34
|
* @param b - The second value.
|
|
12
35
|
* @param eps - The maximum allowed absolute difference. Defaults to {@link EPSILON}.
|
|
@@ -14,6 +37,36 @@ export declare const EPSILON = 1e-10;
|
|
|
14
37
|
* @since 1.1.0
|
|
15
38
|
*/
|
|
16
39
|
export declare function epsEquals(a: number, b: number, eps?: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Library-policy approximate equality: `true` when
|
|
42
|
+
* `|a - b| <= absolute + relative * max(|a|, |b|)`.
|
|
43
|
+
*
|
|
44
|
+
* The relative term covers rounding noise accumulated by arithmetic, which
|
|
45
|
+
* grows with the magnitude of the values; the absolute term covers the
|
|
46
|
+
* neighborhood of zero, where relative comparison degenerates (no nonzero
|
|
47
|
+
* value is relatively close to `0`). The band is strictly wider than the
|
|
48
|
+
* plain absolute comparison, never narrower.
|
|
49
|
+
*
|
|
50
|
+
* Defaults: `absolute = ` {@link EPSILON} — a modeling floor that assumes
|
|
51
|
+
* coordinates of order ~1; pass an explicit value when your data has a
|
|
52
|
+
* different natural resolution — and `relative = ` {@link RELATIVE_TOLERANCE}.
|
|
53
|
+
*
|
|
54
|
+
* Not transitive: `coincident(a, b)` and `coincident(b, c)` do not imply
|
|
55
|
+
* `coincident(a, c)` — chains of pairwise-coincident values can drift beyond
|
|
56
|
+
* the band. Pairwise semantics are intentional (e.g. path continuity checks
|
|
57
|
+
* each junction locally).
|
|
58
|
+
*
|
|
59
|
+
* The tolerance parameters are positional, mirroring {@link epsEquals}: the
|
|
60
|
+
* common override is `absolute` alone, for a domain with a known resolution.
|
|
61
|
+
*
|
|
62
|
+
* @param a - The first value.
|
|
63
|
+
* @param b - The second value.
|
|
64
|
+
* @param absolute - Absolute floor of the band. Defaults to {@link EPSILON}.
|
|
65
|
+
* @param relative - Magnitude-proportional term of the band. Defaults to {@link RELATIVE_TOLERANCE}.
|
|
66
|
+
* @returns `true` when the values are equal to within the combined band.
|
|
67
|
+
* @since 2.0.0
|
|
68
|
+
*/
|
|
69
|
+
export declare function coincident(a: number, b: number, absolute?: number, relative?: number): boolean;
|
|
17
70
|
/**
|
|
18
71
|
* Snaps near-zero values to exactly zero for stable sign tests.
|
|
19
72
|
*
|
package/dist/number.mjs
CHANGED
|
@@ -8,8 +8,31 @@ const PRECISION = 8;
|
|
|
8
8
|
*/
|
|
9
9
|
const EPSILON = 1e-10;
|
|
10
10
|
/**
|
|
11
|
+
* Default relative tolerance for sign and degeneracy decisions about
|
|
12
|
+
* *computed* quantities — derivative values, determinants, discriminants.
|
|
13
|
+
*
|
|
14
|
+
* Scale-free: multiply by the natural magnitude of the quantity under test
|
|
15
|
+
* (e.g. the largest derivative value over the interval) to get an absolute
|
|
16
|
+
* threshold. Values inside the resulting band are indistinguishable from
|
|
17
|
+
* accumulated rounding noise and must not decide a sign question.
|
|
18
|
+
*
|
|
19
|
+
* The value sits ~4,500× above IEEE double rounding noise (2⁻⁵² ≈ 2.2e-16
|
|
20
|
+
* relative per operation) — generous headroom for noise accumulated across a
|
|
21
|
+
* construction pipeline — and far below any geometrically meaningful feature.
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
*/
|
|
25
|
+
const RELATIVE_TOLERANCE = 1e-12;
|
|
26
|
+
/**
|
|
11
27
|
* Approximate equality between two numbers, within an absolute tolerance.
|
|
12
28
|
*
|
|
29
|
+
* This is the raw absolute comparison — the right tool when the domain is
|
|
30
|
+
* normalized by construction (curve parameter space, where `[0, 1]` makes an
|
|
31
|
+
* absolute band meaningful) or when a caller-chosen absolute band is the
|
|
32
|
+
* actual question. For identity questions about computed values of arbitrary
|
|
33
|
+
* magnitude ("is this the same point / value?"), use {@link coincident},
|
|
34
|
+
* which adds a magnitude-relative term.
|
|
35
|
+
*
|
|
13
36
|
* @param a - The first value.
|
|
14
37
|
* @param b - The second value.
|
|
15
38
|
* @param eps - The maximum allowed absolute difference. Defaults to {@link EPSILON}.
|
|
@@ -20,6 +43,38 @@ function epsEquals(a, b, eps = EPSILON) {
|
|
|
20
43
|
return Math.abs(a - b) <= eps;
|
|
21
44
|
}
|
|
22
45
|
/**
|
|
46
|
+
* Library-policy approximate equality: `true` when
|
|
47
|
+
* `|a - b| <= absolute + relative * max(|a|, |b|)`.
|
|
48
|
+
*
|
|
49
|
+
* The relative term covers rounding noise accumulated by arithmetic, which
|
|
50
|
+
* grows with the magnitude of the values; the absolute term covers the
|
|
51
|
+
* neighborhood of zero, where relative comparison degenerates (no nonzero
|
|
52
|
+
* value is relatively close to `0`). The band is strictly wider than the
|
|
53
|
+
* plain absolute comparison, never narrower.
|
|
54
|
+
*
|
|
55
|
+
* Defaults: `absolute = ` {@link EPSILON} — a modeling floor that assumes
|
|
56
|
+
* coordinates of order ~1; pass an explicit value when your data has a
|
|
57
|
+
* different natural resolution — and `relative = ` {@link RELATIVE_TOLERANCE}.
|
|
58
|
+
*
|
|
59
|
+
* Not transitive: `coincident(a, b)` and `coincident(b, c)` do not imply
|
|
60
|
+
* `coincident(a, c)` — chains of pairwise-coincident values can drift beyond
|
|
61
|
+
* the band. Pairwise semantics are intentional (e.g. path continuity checks
|
|
62
|
+
* each junction locally).
|
|
63
|
+
*
|
|
64
|
+
* The tolerance parameters are positional, mirroring {@link epsEquals}: the
|
|
65
|
+
* common override is `absolute` alone, for a domain with a known resolution.
|
|
66
|
+
*
|
|
67
|
+
* @param a - The first value.
|
|
68
|
+
* @param b - The second value.
|
|
69
|
+
* @param absolute - Absolute floor of the band. Defaults to {@link EPSILON}.
|
|
70
|
+
* @param relative - Magnitude-proportional term of the band. Defaults to {@link RELATIVE_TOLERANCE}.
|
|
71
|
+
* @returns `true` when the values are equal to within the combined band.
|
|
72
|
+
* @since 2.0.0
|
|
73
|
+
*/
|
|
74
|
+
function coincident(a, b, absolute = EPSILON, relative = RELATIVE_TOLERANCE) {
|
|
75
|
+
return Math.abs(a - b) <= absolute + relative * Math.max(Math.abs(a), Math.abs(b));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
23
78
|
* Snaps near-zero values to exactly zero for stable sign tests.
|
|
24
79
|
*
|
|
25
80
|
* @param value - The value to test.
|
|
@@ -135,6 +190,6 @@ function mod(n, m) {
|
|
|
135
190
|
return (n % m + m) % m;
|
|
136
191
|
}
|
|
137
192
|
//#endregion
|
|
138
|
-
export { EPSILON, clamp, clampToZero, clip, epsEquals, lerp, minMax, mod, normalize, remap, round, roundDown, roundUp };
|
|
193
|
+
export { EPSILON, RELATIVE_TOLERANCE, clamp, clampToZero, clip, coincident, epsEquals, lerp, minMax, mod, normalize, remap, round, roundDown, roundUp };
|
|
139
194
|
|
|
140
195
|
//# sourceMappingURL=number.mjs.map
|