curvy 2.0.0-alpha.2 → 2.0.0-alpha.5

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.
Files changed (98) hide show
  1. package/dist/characteristic/{index.d.mts → characteristic.d.ts} +15 -23
  2. package/dist/characteristic/index.d.ts +1 -0
  3. package/dist/characteristic/index.mjs +1 -1
  4. package/dist/curve/cubic2d.d.ts +219 -0
  5. package/dist/curve/index.d.ts +12 -0
  6. package/dist/curve/index.mjs +1 -1
  7. package/dist/curve/linear2d.d.ts +199 -0
  8. package/dist/curve/quadratic2d.d.ts +227 -0
  9. package/dist/curve/rationalCubic2d.d.ts +200 -0
  10. package/dist/dimensions.d.ts +23 -0
  11. package/dist/interval/index.d.ts +6 -0
  12. package/dist/interval/index.mjs +2 -2
  13. package/dist/interval/interval.d.ts +525 -0
  14. package/dist/interval/interval2d.d.ts +167 -0
  15. package/dist/length.d.ts +32 -0
  16. package/dist/matrix/index.d.ts +9 -0
  17. package/dist/matrix/matrix2x2.d.ts +339 -0
  18. package/dist/matrix/matrix3x3.d.ts +400 -0
  19. package/dist/matrix/matrix4x4.d.ts +443 -0
  20. package/dist/number.d.ts +276 -0
  21. package/dist/path/cubic2d.d.ts +155 -0
  22. package/dist/path/index.d.ts +12 -0
  23. package/dist/path/index.mjs +6 -6
  24. package/dist/path/index.mjs.map +1 -1
  25. package/dist/path/linear2d.d.ts +135 -0
  26. package/dist/path/quadratic2d.d.ts +127 -0
  27. package/dist/path/rationalCubic2d.d.ts +120 -0
  28. package/dist/path/traits.d.ts +31 -0
  29. package/dist/polynomial/cubic.d.ts +381 -0
  30. package/dist/polynomial/index.d.ts +9 -0
  31. package/dist/polynomial/index.mjs +2 -2
  32. package/dist/polynomial/linear.d.ts +321 -0
  33. package/dist/polynomial/monotonicity.d.ts +3 -0
  34. package/dist/polynomial/quadratic.d.ts +375 -0
  35. package/dist/polynomial/traits.d.ts +56 -0
  36. package/dist/shared/{characteristic-B9nCh_cx.mjs → characteristic-DLlhja-I.mjs} +9 -9
  37. package/dist/shared/{characteristic-B9nCh_cx.mjs.map → characteristic-DLlhja-I.mjs.map} +1 -1
  38. package/dist/shared/{cubic-CpHAx8cC.mjs → cubic-CMonq6bg.mjs} +26 -5
  39. package/dist/shared/cubic-CMonq6bg.mjs.map +1 -0
  40. package/dist/shared/{interval-05CR6eBf.mjs → interval-X1EYuf-T.mjs} +2 -2
  41. package/dist/shared/{interval-05CR6eBf.mjs.map → interval-X1EYuf-T.mjs.map} +1 -1
  42. package/dist/shared/{interval2d-8IBZnUOq.mjs → interval2d-ca0J1NMr.mjs} +8 -8
  43. package/dist/shared/{interval2d-8IBZnUOq.mjs.map → interval2d-ca0J1NMr.mjs.map} +1 -1
  44. package/dist/shared/{quadratic-CamozcFc.mjs → quadratic-DyeMtvET.mjs} +20 -2
  45. package/dist/shared/quadratic-DyeMtvET.mjs.map +1 -0
  46. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs → rationalCubic2d-D658ltUM.mjs} +17 -17
  47. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs.map → rationalCubic2d-D658ltUM.mjs.map} +1 -1
  48. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs → rationalCubic2d-Vw4qGPZj.mjs} +9 -9
  49. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs.map → rationalCubic2d-Vw4qGPZj.mjs.map} +1 -1
  50. package/dist/shared/{solution-CrtLfqEq.mjs → solution-3TDATEMn.mjs} +28 -2
  51. package/dist/shared/solution-3TDATEMn.mjs.map +1 -0
  52. package/dist/shared/{vector2-CL1HDdPr.mjs → vector2-CCuJx1rX.mjs} +6 -6
  53. package/dist/shared/{vector2-CL1HDdPr.mjs.map → vector2-CCuJx1rX.mjs.map} +1 -1
  54. package/dist/shared/{vector3-D-tv_aKL.mjs → vector3-C-qgKAjR.mjs} +2 -2
  55. package/dist/shared/{vector3-D-tv_aKL.mjs.map → vector3-C-qgKAjR.mjs.map} +1 -1
  56. package/dist/shared/{vector4-5KbjoHVj.mjs → vector4-BhOKDhD5.mjs} +2 -2
  57. package/dist/shared/{vector4-5KbjoHVj.mjs.map → vector4-BhOKDhD5.mjs.map} +1 -1
  58. package/dist/solution/index.d.ts +3 -0
  59. package/dist/solution/index.mjs +1 -1
  60. package/dist/{shared/solution-sNQ-ZVhN.d.mts → solution/solution.d.ts} +81 -68
  61. package/dist/splines/basis2d.d.ts +122 -0
  62. package/dist/splines/bezier2d.d.ts +202 -0
  63. package/dist/splines/cardinal2d.d.ts +273 -0
  64. package/dist/splines/hermite2d.d.ts +117 -0
  65. package/dist/splines/index.d.ts +15 -0
  66. package/dist/splines/index.mjs +193 -35
  67. package/dist/splines/index.mjs.map +1 -1
  68. package/dist/splines/rationalBezier2d.d.ts +148 -0
  69. package/dist/splines/util.d.ts +5 -0
  70. package/dist/utils.d.ts +73 -0
  71. package/dist/vector/index.d.ts +9 -0
  72. package/dist/vector/index.mjs +3 -3
  73. package/dist/vector/vector2.d.ts +446 -0
  74. package/dist/vector/vector3.d.ts +449 -0
  75. package/dist/vector/vector4.d.ts +253 -0
  76. package/package.json +13 -13
  77. package/dist/curve/index.d.mts +0 -2
  78. package/dist/interval/index.d.mts +0 -3
  79. package/dist/matrix/index.d.mts +0 -2
  80. package/dist/number.d.mts +0 -280
  81. package/dist/path/index.d.mts +0 -261
  82. package/dist/polynomial/index.d.mts +0 -2
  83. package/dist/shared/cubic-BajUY0JT.d.mts +0 -1100
  84. package/dist/shared/cubic-CpHAx8cC.mjs.map +0 -1
  85. package/dist/shared/interval-Dy-RMEE3.d.mts +0 -533
  86. package/dist/shared/interval2d-C2id9u31.d.mts +0 -172
  87. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +0 -1183
  88. package/dist/shared/quadratic-CamozcFc.mjs.map +0 -1
  89. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +0 -308
  90. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +0 -818
  91. package/dist/shared/solution-CrtLfqEq.mjs.map +0 -1
  92. package/dist/shared/utils-MCckigYk.d.mts +0 -76
  93. package/dist/shared/vector2-DPUY3_eA.d.mts +0 -470
  94. package/dist/shared/vector3-DqeOZtOB.d.mts +0 -703
  95. package/dist/solution/index.d.mts +0 -2
  96. package/dist/splines/index.d.mts +0 -701
  97. package/dist/utils.d.mts +0 -2
  98. package/dist/vector/index.d.mts +0 -3
@@ -0,0 +1,443 @@
1
+ import type { FourDimensionalComponent, FourDimensionalIndex } from '../dimensions';
2
+ import type { Pipeable } from '../utils';
3
+ import type { Vector4 } from '../vector/vector4';
4
+ import type { Matrix3x3 } from './matrix3x3';
5
+
6
+ declare const Matrix4x4TypeId: unique symbol;
7
+ type Matrix4x4TypeId = typeof Matrix4x4TypeId;
8
+
9
+
10
+ /**
11
+ * A coordinate in a 4x4 matrix.
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ export type Matrix4x4Coordinate = FourDimensionalIndex | FourDimensionalComponent;
16
+ /**
17
+ * A 4x4 matrix.
18
+ *
19
+ * All fields are readonly and immutable, and all operations create new instances.
20
+ *
21
+ * @since 1.0.0
22
+ */
23
+ export interface Matrix4x4 extends Pipeable {
24
+ readonly [Matrix4x4TypeId]: Matrix4x4TypeId;
25
+ /**
26
+ * The value of the first row and first column.
27
+ */
28
+ readonly m00: number;
29
+ /**
30
+ * The value of the first row and second column.
31
+ */
32
+ readonly m01: number;
33
+ /**
34
+ * The value of the first row and third column.
35
+ */
36
+ readonly m02: number;
37
+ /**
38
+ * The value of the first row and fourth column.
39
+ */
40
+ readonly m03: number;
41
+ /**
42
+ * The value of the second row and first column.
43
+ */
44
+ readonly m10: number;
45
+ /**
46
+ * The value of the second row and second column.
47
+ */
48
+ readonly m11: number;
49
+ /**
50
+ * The value of the second row and third column.
51
+ */
52
+ readonly m12: number;
53
+ /**
54
+ * The value of the second row and fourth column.
55
+ */
56
+ readonly m13: number;
57
+ /**
58
+ * The value of the third row and first column.
59
+ */
60
+ readonly m20: number;
61
+ /**
62
+ * The value of the third row and second column.
63
+ */
64
+ readonly m21: number;
65
+ /**
66
+ * The value of the third row and third column.
67
+ */
68
+ readonly m22: number;
69
+ /**
70
+ * The value of the third row and fourth column.
71
+ */
72
+ readonly m23: number;
73
+ /**
74
+ * The value of the fourth row and first column.
75
+ */
76
+ readonly m30: number;
77
+ /**
78
+ * The value of the fourth row and second column.
79
+ */
80
+ readonly m31: number;
81
+ /**
82
+ * The value of the fourth row and third column.
83
+ */
84
+ readonly m32: number;
85
+ /**
86
+ * The value of the fourth row and fourth column.
87
+ */
88
+ readonly m33: number;
89
+ }
90
+ /**
91
+ * Checks if a value is a `Matrix4x4`.
92
+ *
93
+ * @param m - The value to check.
94
+ * @returns `true` if the value is a `Matrix4x4`, `false` otherwise.
95
+ * @since 1.0.0
96
+ */
97
+ export declare const isMatrix4x4: (m: unknown) => m is Matrix4x4;
98
+ /**
99
+ * The 4x4 identity matrix.
100
+ *
101
+ * @since 1.1.0
102
+ */
103
+ export declare const identity: Matrix4x4;
104
+ export declare const equals: {
105
+ /**
106
+ * Checks if two `Matrix4x4` instances are approximately equal within the
107
+ * default absolute tolerance ({@link EPSILON}).
108
+ *
109
+ * @param a - The first matrix.
110
+ * @param b - The second matrix.
111
+ * @returns `true` when each pair of components is within tolerance.
112
+ * @since 1.1.0
113
+ */
114
+ (a: Matrix4x4, b: Matrix4x4): boolean;
115
+ /**
116
+ * Checks if two `Matrix4x4` instances are approximately equal within the
117
+ * default absolute tolerance ({@link EPSILON}).
118
+ *
119
+ * @param b - The second matrix.
120
+ * @returns A function that takes the first matrix and returns the comparison result.
121
+ * @since 1.1.0
122
+ */
123
+ (b: Matrix4x4): (a: Matrix4x4) => boolean;
124
+ };
125
+ /**
126
+ * Creates a new `Matrix4x4` instance.
127
+ *
128
+ * @param m00 - The value of the first row and first column.
129
+ * @param m01 - The value of the first row and second column.
130
+ * @param m02 - The value of the first row and third column.
131
+ * @param m03 - The value of the first row and fourth column.
132
+ * @param m10 - The value of the second row and first column.
133
+ * @param m11 - The value of the second row and second column.
134
+ * @param m12 - The value of the second row and third column.
135
+ * @param m13 - The value of the second row and fourth column.
136
+ * @param m20 - The value of the third row and first column.
137
+ * @param m21 - The value of the third row and second column.
138
+ * @param m22 - The value of the third row and third column.
139
+ * @param m23 - The value of the third row and fourth column.
140
+ * @param m30 - The value of the fourth row and first column.
141
+ * @param m31 - The value of the fourth row and second column.
142
+ * @param m32 - The value of the fourth row and third column.
143
+ * @param m33 - The value of the fourth row and fourth column.
144
+ * @returns A new `Matrix4x4` instance.
145
+ * @since 1.0.0
146
+ */
147
+ export declare const make: (m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number) => Matrix4x4;
148
+ /**
149
+ * Creates a new `Matrix4x4` instance from four row vectors.
150
+ *
151
+ * @param v0 - The first row vector.
152
+ * @param v1 - The second row vector.
153
+ * @param v2 - The third row vector.
154
+ * @param v3 - The fourth row vector.
155
+ * @returns A new `Matrix4x4` instance.
156
+ * @since 1.0.0
157
+ */
158
+ export declare const fromRows: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4;
159
+ /**
160
+ * Creates a new `Matrix4x4` instance from four column vectors.
161
+ *
162
+ * @param v0 - The first column vector.
163
+ * @param v1 - The second column vector.
164
+ * @param v2 - The third column vector.
165
+ * @param v3 - The fourth column vector.
166
+ */
167
+ export declare const fromColumns: (v0: Vector4, v1: Vector4, v2: Vector4, v3: Vector4) => Matrix4x4;
168
+ export declare const setRow: {
169
+ /**
170
+ * Sets a row of a `Matrix4x4` to a new vector.
171
+ *
172
+ * @param m - The matrix to modify.
173
+ * @param row - The row to set.
174
+ * @param v - The new vector.
175
+ * @returns A new `Matrix4x4` instance with the specified row set to the new vector.
176
+ * @since 1.0.0
177
+ */
178
+ (m: Matrix4x4, row: Matrix4x4Coordinate, v: Vector4): Matrix4x4;
179
+ /**
180
+ * Sets a row of a `Matrix4x4` to a new vector.
181
+ *
182
+ * @param row - The row to set.
183
+ * @param v - The new vector.
184
+ * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified row set to the new vector.
185
+ * @since 1.0.0
186
+ */
187
+ (row: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4;
188
+ };
189
+ export declare const setColumn: {
190
+ /**
191
+ * Sets a column of a `Matrix4x4` to a new vector.
192
+ *
193
+ * @param m - The matrix to modify.
194
+ * @param column - The column to set.
195
+ * @param v - The new vector.
196
+ * @returns A new `Matrix4x4` instance with the specified column set to the new vector.
197
+ * @since 1.0.0
198
+ */
199
+ (m: Matrix4x4, column: Matrix4x4Coordinate, v: Vector4): Matrix4x4;
200
+ /**
201
+ * Sets a column of a `Matrix4x4` to a new vector.
202
+ *
203
+ * @param column - The column to set.
204
+ * @param v - The new vector.
205
+ * @returns A function that takes a matrix and returns a new `Matrix4x4` instance with the specified column set to the new vector.
206
+ * @since 1.0.0
207
+ */
208
+ (column: Matrix4x4Coordinate, v: Vector4): (m: Matrix4x4) => Matrix4x4;
209
+ };
210
+ /**
211
+ * Calculates the determinant of a `Matrix4x4`.
212
+ *
213
+ * @param m - The matrix to calculate the determinant of.
214
+ * @returns The determinant of the matrix.
215
+ * @since 1.0.0
216
+ */
217
+ export declare const determinant: (m: Matrix4x4) => number;
218
+ /**
219
+ * Calculates the minor of a `Matrix4x4` at a given row and column.
220
+ *
221
+ * @param m - The matrix to calculate the minor of.
222
+ * @param row - The row to exclude.
223
+ * @param column - The column to exclude.
224
+ * @returns The minor of the matrix at the given row and column.
225
+ */
226
+ export declare const minor: (m: Matrix4x4, row: Matrix4x4Coordinate, column: Matrix4x4Coordinate) => Matrix3x3;
227
+ export declare const vectorProductLeft: {
228
+ /**
229
+ * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * import * as Matrix4x4 from 'curvy/matrix4x4'
234
+ * import * as Vector4 from 'curvy/vector4'
235
+ *
236
+ * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
237
+ * const v = Vector4.make(17, 18, 19, 20)
238
+ *
239
+ * // Result:
240
+ * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20
241
+ * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20
242
+ * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20
243
+ * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20
244
+ * const result = Matrix4x4.vectorProductLeft(m, v)
245
+ * ```
246
+ * @param m - The matrix to multiply.
247
+ * @param v - The vector to multiply.
248
+ * @returns The resulting vector.
249
+ * @since 1.0.0
250
+ */
251
+ (m: Matrix4x4, v: Vector4): Vector4;
252
+ /**
253
+ * Calculates the left vector product of a `Matrix4x4` and a `Vector4`.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * import * as Matrix4x4 from 'curvy/matrix4x4'
258
+ * import * as Vector4 from 'curvy/vector4'
259
+ *
260
+ * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
261
+ * const v = Vector4.make(17, 18, 19, 20)
262
+ *
263
+ * // Result:
264
+ * // x = 1 * 17 + 2 * 18 + 3 * 19 + 4 * 20
265
+ * // y = 5 * 17 + 6 * 18 + 7 * 19 + 8 * 20
266
+ * // z = 9 * 17 + 10 * 18 + 11 * 19 + 12 * 20
267
+ * // w = 13 * 17 + 14 * 18 + 15 * 19 + 16 * 20
268
+ * const result = Matrix4x4.vectorProductLeft(v)(m)
269
+ * ```
270
+ * @since 1.0.0
271
+ */
272
+ (v: Vector4): (m: Matrix4x4) => Vector4;
273
+ };
274
+ export declare const vectorProductRight: {
275
+ /**
276
+ * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * import * as Matrix4x4 from 'curvy/matrix4x4'
281
+ * import * as Vector4 from 'curvy/vector4'
282
+ *
283
+ * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
284
+ * const v = Vector4.make(17, 18, 19, 20)
285
+ *
286
+ * // Result:
287
+ * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20
288
+ * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20
289
+ * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20
290
+ * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20
291
+ * const result = Matrix4x4.vectorProductRight(m, v)
292
+ * ```
293
+ * @since 1.0.0
294
+ */
295
+ (m: Matrix4x4, v: Vector4): Vector4;
296
+ /**
297
+ * Calculates the right vector product of a `Matrix4x4` and a `Vector4`.
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * import * as Matrix4x4 from 'curvy/matrix4x4'
302
+ * import * as Vector4 from 'curvy/vector4'
303
+ *
304
+ * const m = Matrix4x4.make(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
305
+ * const v = Vector4.make(17, 18, 19, 20)
306
+ *
307
+ * // Result:
308
+ * // x = 1 * 17 + 5 * 18 + 9 * 19 + 13 * 20
309
+ * // y = 2 * 17 + 6 * 18 + 10 * 19 + 14 * 20
310
+ * // z = 3 * 17 + 7 * 18 + 11 * 19 + 15 * 20
311
+ * // w = 4 * 17 + 8 * 18 + 12 * 19 + 16 * 20
312
+ * const result = Matrix4x4.vectorProductRight(v)(m)
313
+ * ```
314
+ * @since 1.0.0
315
+ */
316
+ (v: Vector4): (m: Matrix4x4) => Vector4;
317
+ };
318
+ export declare const multiply: {
319
+ /**
320
+ * Multiplies two `Matrix4x4` instances. Result is `a · b`.
321
+ *
322
+ * @param a - The left-hand matrix.
323
+ * @param b - The right-hand matrix.
324
+ * @returns The product matrix.
325
+ * @since 1.1.0
326
+ */
327
+ (a: Matrix4x4, b: Matrix4x4): Matrix4x4;
328
+ /**
329
+ * Multiplies two `Matrix4x4` instances. Result is `a · b`.
330
+ *
331
+ * @param b - The right-hand matrix.
332
+ * @returns A function that takes the left-hand matrix and returns the product.
333
+ * @since 1.1.0
334
+ */
335
+ (b: Matrix4x4): (a: Matrix4x4) => Matrix4x4;
336
+ };
337
+ /**
338
+ * Returns the inverse of a `Matrix4x4`.
339
+ *
340
+ * Throws when the matrix is singular (determinant is zero).
341
+ *
342
+ * @param m - The matrix to invert.
343
+ * @returns The inverse matrix.
344
+ * @since 1.1.0
345
+ */
346
+ export declare const inverse: (m: Matrix4x4) => Matrix4x4;
347
+ export declare const solveSystem: {
348
+ /**
349
+ * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.
350
+ *
351
+ * @param m - The matrix representing the coefficients of the equations.
352
+ * @param v - The vector representing the constants of the equations.
353
+ * @returns The solution vector.
354
+ * @since 1.0.0
355
+ */
356
+ (m: Matrix4x4, v: Vector4): Vector4;
357
+ /**
358
+ * Solves a system of linear equations represented by a `Matrix4x4` and a `Vector4`.
359
+ *
360
+ * @param v - The vector representing the constants of the equations.
361
+ * @returns A function that takes a matrix and returns the solution vector.
362
+ * @since 1.0.0
363
+ */
364
+ (v: Vector4): (m: Matrix4x4) => Vector4;
365
+ };
366
+ /**
367
+ * Returns the rows of a `Matrix4x4` as an array of vectors.
368
+ *
369
+ * @param m - The matrix to convert.
370
+ * @returns An array of vectors representing the rows of the matrix.
371
+ * @since 1.0.0
372
+ */
373
+ export declare const toRows: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4];
374
+ /**
375
+ * Returns the columns of a `Matrix4x4` as an array of vectors.
376
+ *
377
+ * @param m - The matrix to convert.
378
+ * @returns An array of vectors representing the columns of the matrix.
379
+ * @since 1.0.0
380
+ */
381
+ export declare const toColumns: (m: Matrix4x4) => [Vector4, Vector4, Vector4, Vector4];
382
+ export declare const rowVector: {
383
+ /**
384
+ * Returns a row vector from a `Matrix4x4`.
385
+ *
386
+ * @param m - The matrix to get the row vector from.
387
+ * @param row - The row index.
388
+ * @returns The row vector.
389
+ * @since 1.0.0
390
+ */
391
+ (m: Matrix4x4, row: Matrix4x4Coordinate): Vector4;
392
+ /**
393
+ * Returns a row vector from a `Matrix4x4`.
394
+ *
395
+ * @param row - The row index.
396
+ * @returns A function that takes a matrix and returns the row vector.
397
+ * @since 1.0.0
398
+ */
399
+ (row: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4;
400
+ };
401
+ export declare const columnVector: {
402
+ /**
403
+ * Returns a column vector from a `Matrix4x4`.
404
+ *
405
+ * @param m - The matrix to get the column vector from.
406
+ * @param column - The column index.
407
+ * @returns The column vector.
408
+ * @since 1.0.0
409
+ */
410
+ (m: Matrix4x4, column: Matrix4x4Coordinate): Vector4;
411
+ /**
412
+ * Returns a column vector from a `Matrix4x4`.
413
+ *
414
+ * @param column - The column index.
415
+ * @returns A function that takes a matrix and returns the column vector.
416
+ * @since 1.0.0
417
+ */
418
+ (column: Matrix4x4Coordinate): (m: Matrix4x4) => Vector4;
419
+ };
420
+ /**
421
+ * Transposes a `Matrix4x4`.
422
+ *
423
+ * @param m - The matrix to transpose.
424
+ * @returns The transposed matrix.
425
+ * @since 1.0.0
426
+ */
427
+ export declare const transpose: (m: Matrix4x4) => Matrix4x4;
428
+ /**
429
+ * Reverses the rows of a `Matrix4x4`.
430
+ *
431
+ * @param m - The matrix to reverse the rows of.
432
+ * @returns The matrix with the rows reversed.
433
+ * @since 1.0.0
434
+ */
435
+ export declare const reverseRows: (m: Matrix4x4) => Matrix4x4;
436
+ /**
437
+ * Reverses the columns of a `Matrix4x4`.
438
+ *
439
+ * @param m - The matrix to reverse the columns of.
440
+ * @returns The matrix with the columns reversed.
441
+ * @since 1.0.0
442
+ */
443
+ export declare const reverseColumns: (m: Matrix4x4) => Matrix4x4;
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Default tolerance for approximate equality between floating-point numbers.
3
+ *
4
+ * @since 1.1.0
5
+ */
6
+ export declare const EPSILON = 1e-10;
7
+ /**
8
+ * Approximate equality between two numbers, within an absolute tolerance.
9
+ *
10
+ * @param a - The first value.
11
+ * @param b - The second value.
12
+ * @param eps - The maximum allowed absolute difference. Defaults to {@link EPSILON}.
13
+ * @returns `true` when `|a - b| <= eps`.
14
+ * @since 1.1.0
15
+ */
16
+ export declare function epsEquals(a: number, b: number, eps?: number): boolean;
17
+ /**
18
+ * Snaps near-zero values to exactly zero for stable sign tests.
19
+ *
20
+ * @param value - The value to test.
21
+ * @param eps - The threshold below which `value` is considered zero.
22
+ * @returns `0` when `|value| < eps`, otherwise `value` unchanged.
23
+ * @since 1.1.0
24
+ */
25
+ export declare function clampToZero(value: number, eps: number): number;
26
+ /**
27
+ * Rounding function that rounds a number to a specified precision.
28
+ *
29
+ * @param value - The number to round.
30
+ * @param precision - The number of decimal places to round to (default is 8).
31
+ * @returns The rounded number.
32
+ * @example
33
+ * ```ts
34
+ * import { round } from 'curvy/utils'
35
+ *
36
+ * const roundedValue = round(1.23456789, 4) // 1.2346
37
+ * const roundedValue2 = round(1.23456789) // 1.23456789
38
+ * ```
39
+ * @since 1.0.0
40
+ */
41
+ export declare function round(value: number, precision?: number): number;
42
+ /**
43
+ * Rounding function that rounds a number down to a specified precision.
44
+ *
45
+ * @param value - The number to round down.
46
+ * @param precision - The number of decimal places to round down to (default is 8).
47
+ * @returns The rounded down number.
48
+ * @example
49
+ * ```ts
50
+ * import { roundDown } from 'curvy/utils'
51
+ *
52
+ * const roundedDownValue = roundDown(1.23456789, 4) // 1.2345
53
+ * const roundedDownValue2 = roundDown(1.23456789) // 1.23456789
54
+ * ```
55
+ * @since 1.0.0
56
+ */
57
+ export declare function roundDown(value: number, precision?: number): number;
58
+ /**
59
+ * Rounding function that rounds a number up to a specified precision.
60
+ *
61
+ * @param value - The number to round up.
62
+ * @param precision - The number of decimal places to round up to (default is 8).
63
+ * @returns The rounded up number.
64
+ * @example
65
+ * ```ts
66
+ * import { roundUp } from 'curvy/utils'
67
+ *
68
+ * const roundedUpValue = roundUp(1.23456789, 4) // 1.2346
69
+ * const roundedUpValue2 = roundUp(1.23456789) // 1.23456789
70
+ * ```
71
+ * @since 1.0.0
72
+ */
73
+ export declare function roundUp(value: number, precision?: number): number;
74
+ export declare const lerp: {
75
+ /**
76
+ * Linearly interpolates between two values.
77
+ *
78
+ * @param t - The interpolation factor (between 0 and 1).
79
+ * @param a - The start value.
80
+ * @param b - The end value.
81
+ * @returns The interpolated value.
82
+ * @example
83
+ * ```ts
84
+ * import { lerp } from 'curvy/utils'
85
+ *
86
+ * lerp(0.5, 10, 20) // 15
87
+ * ```
88
+ * @since 1.0.0
89
+ */
90
+ (t: number, a: number, b: number): number;
91
+ /**
92
+ * Linearly interpolates between two values.
93
+ *
94
+ * @param a - The start value.
95
+ * @param b - The end value.
96
+ * @returns A function that takes the interpolation factor and returns the interpolated value.
97
+ * @example
98
+ * ```ts
99
+ * import { lerp } from 'curvy/utils'
100
+ *
101
+ * lerp(10, 20)(0.5) // 15
102
+ * ```
103
+ * @since 1.0.0
104
+ */
105
+ (a: number, b: number): (t: number) => number;
106
+ };
107
+ export declare const normalize: {
108
+ /**
109
+ * Normalizes a value between two bounds to the unit interval.
110
+ *
111
+ * @param x - The value to normalize.
112
+ * @param a - The lower bound.
113
+ * @param b - The upper bound.
114
+ * @returns The normalized value.
115
+ * @example
116
+ * ```ts
117
+ * import { normalize } from 'curvy/utils'
118
+ *
119
+ * normalize(15, 10, 20) // 0.5
120
+ * ```
121
+ * @since 1.0.0
122
+ */
123
+ (x: number, a: number, b: number): number;
124
+ /**
125
+ * Normalizes a value between two bounds to the unit interval.
126
+ *
127
+ * @param a - The lower bound.
128
+ * @param b - The upper bound.
129
+ * @returns A function that takes a value and returns the normalized value.
130
+ * @example
131
+ * ```ts
132
+ * import { normalize } from 'curvy/utils'
133
+ *
134
+ * normalize(10, 20)(15) // 0.5
135
+ * ```
136
+ * @since 1.0.0
137
+ */
138
+ (a: number, b: number): (x: number) => number;
139
+ };
140
+ export declare const remap: {
141
+ /**
142
+ * Remaps a value from one range to another.
143
+ *
144
+ * @param x - The value to remap.
145
+ * @param x1 - The lower bound of the original range.
146
+ * @param x2 - The upper bound of the original range.
147
+ * @param y1 - The lower bound of the new range.
148
+ * @param y2 - The upper bound of the new range.
149
+ * @returns The remapped value.
150
+ * @example
151
+ * ```ts
152
+ * import { remap } from 'curvy/utils'
153
+ *
154
+ * remap(15, 10, 20, 0, 100) // 50
155
+ * ```
156
+ * @since 1.0.0
157
+ */
158
+ (x: number, x1: number, x2: number, y1: number, y2: number): number;
159
+ /**
160
+ * Remaps a value from one range to another.
161
+ *
162
+ * @param x1 - The lower bound of the original range.
163
+ * @param x2 - The upper bound of the original range.
164
+ * @param y1 - The lower bound of the new range.
165
+ * @param y2 - The upper bound of the new range.
166
+ * @returns A function that takes a value and returns the remapped value.
167
+ * @example
168
+ * ```ts
169
+ * import { remap } from 'curvy/utils'
170
+ *
171
+ * remap(10, 20, 0, 100)(15) // 50
172
+ * ```
173
+ * @since 1.0.0
174
+ */
175
+ (x1: number, x2: number, y1: number, y2: number): (x: number) => number;
176
+ };
177
+ export declare const clamp: {
178
+ /**
179
+ * Clamps a value between two bounds.
180
+ *
181
+ * @param value - The value to clamp.
182
+ * @param min - The lower bound.
183
+ * @param max - The upper bound.
184
+ * @returns The clamped value.
185
+ * @example
186
+ * ```ts
187
+ * import { clamp } from 'curvy/utils'
188
+ *
189
+ * clamp(25, 10, 20) // 20
190
+ * ```
191
+ * @since 1.0.0
192
+ */
193
+ (value: number, min: number, max: number): number;
194
+ /**
195
+ * Clamps a value between two bounds.
196
+ *
197
+ * @param min - The lower bound.
198
+ * @param max - The upper bound.
199
+ * @returns A function that takes a value and returns the clamped value.
200
+ * @example
201
+ * ```ts
202
+ * import { clamp } from 'curvy/utils'
203
+ *
204
+ * clamp(10, 20)(25) // 20
205
+ * ```
206
+ * @since 1.0.0
207
+ */
208
+ (min: number, max: number): (value: number) => number;
209
+ };
210
+ export declare const clip: {
211
+ /**
212
+ * Clips a value to a specified range, returning a fallback value if the value is outside the range.
213
+ *
214
+ * @param value - The value to clip.
215
+ * @param min - The lower bound.
216
+ * @param max - The upper bound.
217
+ * @param onClip - The fallback value to return if the value is outside the range.
218
+ * @returns The original value if within range, otherwise the fallback.
219
+ * @example
220
+ * ```ts
221
+ * import { clip } from 'curvy/utils'
222
+ *
223
+ * clip(25, 10, 20, 15) // 15
224
+ * ```
225
+ * @since 1.0.0
226
+ */
227
+ <T>(value: number, min: number, max: number, onClip: T): T | number;
228
+ /**
229
+ * Clips a value to a specified range, returning a fallback value if the value is outside the range.
230
+ *
231
+ * @param min - The lower bound.
232
+ * @param max - The upper bound.
233
+ * @param onClip - The fallback value to return if the value is outside the range.
234
+ * @returns A function that takes a value and returns it if within range, otherwise the fallback.
235
+ * @example
236
+ * ```ts
237
+ * import { clip } from 'curvy/utils'
238
+ *
239
+ * clip(10, 20, 15)(25) // 15
240
+ * ```
241
+ * @since 1.0.0
242
+ */
243
+ <T>(min: number, max: number, onClip: T): (value: number) => T | number;
244
+ };
245
+ /**
246
+ * Returns the minimum and maximum of two numbers.
247
+ *
248
+ * @param a - The first number.
249
+ * @param b - The second number.
250
+ * @returns A tuple containing the minimum and maximum values.
251
+ * @example
252
+ * ```ts
253
+ * import { minMax } from 'curvy/utils'
254
+ *
255
+ * const [minValue, maxValue] = minMax(10, 20) // [10, 20]
256
+ * const [minValue2, maxValue2] = minMax(20, 10) // [10, 20]
257
+ * ```
258
+ * @since 1.0.0
259
+ */
260
+ export declare function minMax(a: number, b: number): [number, number];
261
+ /**
262
+ * Calculates the modulus of a number.
263
+ *
264
+ * @param n - The number to calculate the modulus of.
265
+ * @param m - The modulus.
266
+ * @returns The modulus of the number.
267
+ * @example
268
+ * ```ts
269
+ * import { mod } from 'curvy/utils'
270
+ *
271
+ * const modulus = mod(10, 3) // 1
272
+ * const modulus2 = mod(-10, 3) // 2
273
+ * ```
274
+ * @since 1.0.0
275
+ */
276
+ export declare function mod(n: number, m: number): number;