curvy 1.0.7 → 1.0.9
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/curve/cubic2d.d.mts +80 -2
- package/dist/curve/cubic2d.d.ts +80 -2
- package/dist/curve/cubic2d.mjs +9 -26
- package/dist/curve/cubic2d.mjs.map +1 -0
- package/dist/curve/linear2d.d.mts +68 -2
- package/dist/curve/linear2d.d.ts +68 -2
- package/dist/curve/linear2d.mjs +11 -14
- package/dist/curve/linear2d.mjs.map +1 -0
- package/dist/curve/quadratic2d.d.mts +86 -2
- package/dist/curve/quadratic2d.d.ts +86 -2
- package/dist/curve/quadratic2d.mjs +10 -15
- package/dist/curve/quadratic2d.mjs.map +1 -0
- package/dist/interval.d.mts +195 -2
- package/dist/interval.d.ts +195 -2
- package/dist/interval.mjs +9 -12
- package/dist/interval.mjs.map +1 -0
- package/dist/matrix/matrix2x2.d.mts +273 -2
- package/dist/matrix/matrix2x2.d.ts +273 -2
- package/dist/matrix/matrix2x2.mjs +5 -4
- package/dist/matrix/matrix2x2.mjs.map +1 -0
- package/dist/matrix/matrix3x3.d.mts +308 -1
- package/dist/matrix/matrix3x3.d.ts +308 -1
- package/dist/matrix/matrix3x3.mjs +5 -4
- package/dist/matrix/matrix3x3.mjs.map +1 -0
- package/dist/matrix/matrix4x4.d.mts +310 -1
- package/dist/matrix/matrix4x4.d.ts +310 -1
- package/dist/matrix/matrix4x4.mjs +24 -61
- package/dist/matrix/matrix4x4.mjs.map +1 -0
- package/dist/path/cubic2d.d.mts +68 -2
- package/dist/path/cubic2d.d.ts +68 -2
- package/dist/path/cubic2d.mjs +10 -12
- package/dist/path/cubic2d.mjs.map +1 -0
- package/dist/path/linear2d.d.mts +68 -2
- package/dist/path/linear2d.d.ts +68 -2
- package/dist/path/linear2d.mjs +7 -9
- package/dist/path/linear2d.mjs.map +1 -0
- package/dist/path/quadratic2d.d.mts +67 -2
- package/dist/path/quadratic2d.d.ts +67 -2
- package/dist/path/quadratic2d.mjs +9 -13
- package/dist/path/quadratic2d.mjs.map +1 -0
- package/dist/pipe.mjs +1 -0
- package/dist/pipe.mjs.map +1 -0
- package/dist/polynomial/cubic.d.mts +1 -1
- package/dist/polynomial/cubic.d.ts +1 -1
- package/dist/polynomial/cubic.mjs +13 -28
- package/dist/polynomial/cubic.mjs.map +1 -0
- package/dist/polynomial/linear.d.mts +1 -1
- package/dist/polynomial/linear.d.ts +1 -1
- package/dist/polynomial/linear.mjs +2 -1
- package/dist/polynomial/linear.mjs.map +1 -0
- package/dist/polynomial/quadratic.d.mts +2 -2
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/polynomial/quadratic.mjs +5 -2
- package/dist/polynomial/quadratic.mjs.map +1 -0
- package/dist/shared/{curvy.Cps2R_RU.mjs → curvy.BkkW8Tx9.mjs} +11 -29
- package/dist/shared/curvy.BkkW8Tx9.mjs.map +1 -0
- package/dist/shared/{curvy.BzVmUIKm.mjs → curvy.BxdGW9he.mjs} +17 -32
- package/dist/shared/curvy.BxdGW9he.mjs.map +1 -0
- package/dist/shared/{curvy.C2XGH0R0.mjs → curvy.C_sCeg9J.mjs} +15 -24
- package/dist/shared/curvy.C_sCeg9J.mjs.map +1 -0
- package/dist/shared/curvy.Cg8lZVUz.d.ts +688 -0
- package/dist/shared/{curvy.CE4X6_Is.mjs → curvy.DCt1gGII.mjs} +11 -45
- package/dist/shared/curvy.DCt1gGII.mjs.map +1 -0
- package/dist/shared/{curvy.BZ_mTkJe.mjs → curvy.DJ4xO0al.mjs} +9 -6
- package/dist/shared/curvy.DJ4xO0al.mjs.map +1 -0
- package/dist/shared/curvy.DmVFTi0N.mjs +1 -0
- package/dist/shared/curvy.DmVFTi0N.mjs.map +1 -0
- package/dist/shared/curvy.FDaj5rlj.d.mts +688 -0
- package/dist/shared/{curvy.NLeFCr-9.mjs → curvy.lktriTpx.mjs} +19 -42
- package/dist/shared/curvy.lktriTpx.mjs.map +1 -0
- package/dist/shared/{curvy.Ck0of1PI.mjs → curvy.mLFprrGm.mjs} +26 -22
- package/dist/shared/curvy.mLFprrGm.mjs.map +1 -0
- package/dist/shared/{curvy.BDhiZ7He.mjs → curvy.r6f1j287.mjs} +8 -12
- package/dist/shared/curvy.r6f1j287.mjs.map +1 -0
- package/dist/splines/basis2d.d.mts +94 -2
- package/dist/splines/basis2d.d.ts +94 -2
- package/dist/splines/basis2d.mjs +13 -12
- package/dist/splines/basis2d.mjs.map +1 -0
- package/dist/splines/bezier2d.d.mts +136 -2
- package/dist/splines/bezier2d.d.ts +136 -2
- package/dist/splines/bezier2d.mjs +10 -9
- package/dist/splines/bezier2d.mjs.map +1 -0
- package/dist/splines/cardinal2d.d.mts +131 -2
- package/dist/splines/cardinal2d.d.ts +131 -2
- package/dist/splines/cardinal2d.mjs +15 -24
- package/dist/splines/cardinal2d.mjs.map +1 -0
- package/dist/splines/hermite2d.d.mts +94 -3
- package/dist/splines/hermite2d.d.ts +94 -3
- package/dist/splines/hermite2d.mjs +22 -36
- package/dist/splines/hermite2d.mjs.map +1 -0
- package/dist/utils.d.mts +179 -1
- package/dist/utils.d.ts +179 -1
- package/dist/utils.mjs +16 -7
- package/dist/utils.mjs.map +1 -0
- package/dist/vector/vector2.d.mts +259 -1
- package/dist/vector/vector2.d.ts +259 -1
- package/dist/vector/vector2.mjs +4 -2
- package/dist/vector/vector2.mjs.map +1 -0
- package/dist/vector/vector3.d.mts +345 -1
- package/dist/vector/vector3.d.ts +345 -1
- package/dist/vector/vector3.mjs +9 -2
- package/dist/vector/vector3.mjs.map +1 -0
- package/dist/vector/vector4.d.mts +163 -1
- package/dist/vector/vector4.d.ts +163 -1
- package/dist/vector/vector4.mjs +4 -2
- package/dist/vector/vector4.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/shared/curvy.BsHoYJNv.d.ts +0 -155
- package/dist/shared/curvy.NsmY7zcr.d.mts +0 -155
|
@@ -5,45 +5,316 @@ import { Vector2 } from '../vector/vector2.js';
|
|
|
5
5
|
declare const Matrix2x2TypeId: unique symbol;
|
|
6
6
|
type Matrix2x2TypeId = typeof Matrix2x2TypeId;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* A type representing the coordinate of a 2D matrix.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
8
13
|
type Matrix2x2Coordinate = TwoDimensionalIndex | TwoDimensionalComponent;
|
|
14
|
+
/**
|
|
15
|
+
* A 2D matrix with 2 rows and 2 columns.
|
|
16
|
+
*
|
|
17
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
18
|
+
*
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
9
21
|
interface Matrix2x2 extends Pipeable {
|
|
10
22
|
readonly [Matrix2x2TypeId]: Matrix2x2TypeId;
|
|
23
|
+
/**
|
|
24
|
+
* The value in the first row and first column.
|
|
25
|
+
*/
|
|
11
26
|
readonly m00: number;
|
|
27
|
+
/**
|
|
28
|
+
* The value in the first row and second column.
|
|
29
|
+
*/
|
|
12
30
|
readonly m01: number;
|
|
31
|
+
/**
|
|
32
|
+
* The value in the second row and first column.
|
|
33
|
+
*/
|
|
13
34
|
readonly m10: number;
|
|
35
|
+
/**
|
|
36
|
+
* The value in the second row and second column.
|
|
37
|
+
*/
|
|
14
38
|
readonly m11: number;
|
|
15
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a value is a `Matrix2x2`.
|
|
42
|
+
*
|
|
43
|
+
* @param m - The value to check.
|
|
44
|
+
* @returns `true` if the value is a `Matrix2x2`, `false` otherwise.
|
|
45
|
+
* @since 1.0.0
|
|
46
|
+
*/
|
|
16
47
|
declare const isMatrix2x2: (m: unknown) => m is Matrix2x2;
|
|
17
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new `Matrix2x2` instance.
|
|
50
|
+
*
|
|
51
|
+
* @param m00 - The value in the first row and first column. Defaults to 0.
|
|
52
|
+
* @param m01 - The value in the first row and second column. Defaults to 0.
|
|
53
|
+
* @param m10 - The value in the second row and first column. Defaults to 0.
|
|
54
|
+
* @param m11 - The value in the second row and second column. Defaults to 0.
|
|
55
|
+
*/
|
|
56
|
+
declare const make: (m00?: number, m01?: number, m10?: number, m11?: number) => Matrix2x2;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new `Matrix2x2` instance from two vectors representing rows.
|
|
59
|
+
*
|
|
60
|
+
* @param v0 - The first row vector.
|
|
61
|
+
* @param v1 - The second row vector.
|
|
62
|
+
* @returns A new `Matrix2x2` instance.
|
|
63
|
+
* @since 1.0.0
|
|
64
|
+
*/
|
|
18
65
|
declare const fromRows: (v0: Vector2, v1: Vector2) => Matrix2x2;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new `Matrix2x2` instance from two vectors representing columns.
|
|
68
|
+
*
|
|
69
|
+
* @param v0 - The first column vector.
|
|
70
|
+
* @param v1 - The second column vector.
|
|
71
|
+
* @returns A new `Matrix2x2` instance.
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
*/
|
|
19
74
|
declare const fromColumns: (v0: Vector2, v1: Vector2) => Matrix2x2;
|
|
20
75
|
declare const setRow: {
|
|
76
|
+
/**
|
|
77
|
+
* Sets the specified row of the matrix to the given vector.
|
|
78
|
+
*
|
|
79
|
+
* @param m - The matrix to modify.
|
|
80
|
+
* @param row - The row index (0 or 1).
|
|
81
|
+
* @param v - The vector to set the row to.
|
|
82
|
+
* @returns A new `Matrix2x2` instance with the specified row set to the given vector.
|
|
83
|
+
* @since 1.0.0
|
|
84
|
+
*/
|
|
21
85
|
(m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2): Matrix2x2;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the specified row of the matrix to the given vector.
|
|
88
|
+
*
|
|
89
|
+
* @param row - The row index (0 or 1).
|
|
90
|
+
* @param v - The vector to set the row to.
|
|
91
|
+
* @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified row set to the given vector.
|
|
92
|
+
* @since 1.0.0
|
|
93
|
+
*/
|
|
22
94
|
(row: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2;
|
|
23
95
|
};
|
|
24
96
|
declare const setColumn: {
|
|
97
|
+
/**
|
|
98
|
+
* Sets the specified column of the matrix to the given vector.
|
|
99
|
+
*
|
|
100
|
+
* @param m - The matrix to modify.
|
|
101
|
+
* @param column - The column index (0 or 1).
|
|
102
|
+
* @param v - The vector to set the column to.
|
|
103
|
+
* @returns A new `Matrix2x2` instance with the specified column set to the given vector.
|
|
104
|
+
* @since 1.0.0
|
|
105
|
+
*/
|
|
25
106
|
(m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2): Matrix2x2;
|
|
107
|
+
/**
|
|
108
|
+
* Sets the specified column of the matrix to the given vector.
|
|
109
|
+
*
|
|
110
|
+
* @param column - The column index (0 or 1).
|
|
111
|
+
* @param v - The vector to set the column to.
|
|
112
|
+
* @returns A function that takes a matrix and returns a new `Matrix2x2` instance with the specified column set to the given vector.
|
|
113
|
+
* @since 1.0.0
|
|
114
|
+
*/
|
|
26
115
|
(column: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2;
|
|
27
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Calculates the determinant of a 2D matrix.
|
|
119
|
+
*
|
|
120
|
+
* @param m - The matrix to calculate the determinant for.
|
|
121
|
+
* @returns The determinant of the matrix.
|
|
122
|
+
* @since 1.0.0
|
|
123
|
+
*/
|
|
28
124
|
declare const determinant: (m: Matrix2x2) => number;
|
|
29
125
|
declare const vectorProductLeft: {
|
|
126
|
+
/**
|
|
127
|
+
* Calculates the left vector product of a matrix and a vector.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
132
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
133
|
+
*
|
|
134
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
135
|
+
* const vector = Vector2.make(5, 6)
|
|
136
|
+
*
|
|
137
|
+
* // Performs:
|
|
138
|
+
* // x = 1 * 5 + 2 * 6 = 17
|
|
139
|
+
* // y = 3 * 5 + 4 * 6 = 39
|
|
140
|
+
* const result = Matrix2x2.vectorProductLeft(matrix, vector)
|
|
141
|
+
* ```
|
|
142
|
+
* @param m - The matrix to multiply.
|
|
143
|
+
* @param v - The vector to multiply.
|
|
144
|
+
* @returns The resulting vector after the left vector product.
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
*/
|
|
30
147
|
(m: Matrix2x2, v: Vector2): Vector2;
|
|
148
|
+
/**
|
|
149
|
+
* Calculates the left vector product of a matrix and a vector.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
154
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
155
|
+
*
|
|
156
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
157
|
+
* const vector = Vector2.make(5, 6)
|
|
158
|
+
*
|
|
159
|
+
* // Performs:
|
|
160
|
+
* // x = 1 * 5 + 2 * 6 = 17
|
|
161
|
+
* // y = 3 * 5 + 4 * 6 = 39
|
|
162
|
+
* const result = Matrix2x2.vectorProductLeft(vector)(matrix)
|
|
163
|
+
* ```
|
|
164
|
+
* @param v - The vector to multiply.
|
|
165
|
+
* @returns A function that takes a matrix and returns the resulting vector after the left vector product.
|
|
166
|
+
* @since 1.0.0
|
|
167
|
+
*/
|
|
31
168
|
(v: Vector2): (m: Matrix2x2) => Vector2;
|
|
32
169
|
};
|
|
33
170
|
declare const vectorProductRight: {
|
|
171
|
+
/**
|
|
172
|
+
* Calculates the right vector product of a matrix and a vector.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
177
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
178
|
+
*
|
|
179
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
180
|
+
* const vector = Vector2.make(5, 6)
|
|
181
|
+
*
|
|
182
|
+
* // Performs:
|
|
183
|
+
* // x = 1 * 5 + 3 * 6 = 33
|
|
184
|
+
* // y = 2 * 5 + 4 * 6 = 62
|
|
185
|
+
* const result = Matrix2x2.vectorProductRight(matrix, vector)
|
|
186
|
+
* ```
|
|
187
|
+
* @param m - The matrix to multiply.
|
|
188
|
+
* @param v - The vector to multiply.
|
|
189
|
+
* @returns The resulting vector after the right vector product.
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
*/
|
|
34
192
|
(m: Matrix2x2, v: Vector2): Vector2;
|
|
193
|
+
/**
|
|
194
|
+
* Calculates the right vector product of a matrix and a vector.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
199
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
200
|
+
*
|
|
201
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
202
|
+
* const vector = Vector2.make(5, 6)
|
|
203
|
+
*
|
|
204
|
+
* // Performs:
|
|
205
|
+
* // x = 1 * 5 + 3 * 6 = 33
|
|
206
|
+
* // y = 2 * 5 + 4 * 6 = 62
|
|
207
|
+
* const result = Matrix2x2.vectorProductRight(vector)(matrix)
|
|
208
|
+
* ```
|
|
209
|
+
* @param v - The vector to multiply.
|
|
210
|
+
* @returns A function that takes a matrix and returns the resulting vector after the right vector product.
|
|
211
|
+
* @since 1.0.0
|
|
212
|
+
*/
|
|
35
213
|
(v: Vector2): (m: Matrix2x2) => Vector2;
|
|
36
214
|
};
|
|
37
215
|
declare const solveSystem: {
|
|
216
|
+
/**
|
|
217
|
+
* Solves a system of linear equations represented by a matrix and a vector.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
222
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
223
|
+
*
|
|
224
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
225
|
+
* const vector = Vector2.make(5, 6)
|
|
226
|
+
*
|
|
227
|
+
* // Solves the system of equations:
|
|
228
|
+
* // 1x + 2y = 5
|
|
229
|
+
* // 3x + 4y = 6
|
|
230
|
+
* const result = Matrix2x2.solveSystem(matrix, vector)
|
|
231
|
+
* ```
|
|
232
|
+
* @param m - The matrix representing the coefficients of the system.
|
|
233
|
+
* @param v - The vector representing the constants of the system.
|
|
234
|
+
* @returns The solution vector.
|
|
235
|
+
* @since 1.0.0
|
|
236
|
+
*/
|
|
38
237
|
(m: Matrix2x2, v: Vector2): Vector2;
|
|
238
|
+
/**
|
|
239
|
+
* Solves a system of linear equations represented by a matrix and a vector.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* import * as Matrix2x2 from 'curvy/matrix2x2'
|
|
244
|
+
* import * as Vector2 from 'curvy/vector2'
|
|
245
|
+
*
|
|
246
|
+
* const matrix = Matrix2x2.make(1, 2, 3, 4)
|
|
247
|
+
* const vector = Vector2.make(5, 6)
|
|
248
|
+
*
|
|
249
|
+
* // Solves the system of equations:
|
|
250
|
+
* // 1x + 2y = 5
|
|
251
|
+
* // 3x + 4y = 6
|
|
252
|
+
* const result = Matrix2x2.solveSystem(vector)(matrix)
|
|
253
|
+
* ```
|
|
254
|
+
* @param v - The vector representing the constants of the system.
|
|
255
|
+
* @returns A function that takes a matrix and returns the solution vector.
|
|
256
|
+
* @since 1.0.0
|
|
257
|
+
*/
|
|
39
258
|
(v: Vector2): (m: Matrix2x2) => Vector2;
|
|
40
259
|
};
|
|
260
|
+
/**
|
|
261
|
+
* Returns the rows of a matrix as an array of vectors.
|
|
262
|
+
*
|
|
263
|
+
* @param m - The matrix to convert.
|
|
264
|
+
* @returns An array of vectors representing the rows of the matrix.
|
|
265
|
+
* @since 1.0.0
|
|
266
|
+
*/
|
|
41
267
|
declare const toRows: (m: Matrix2x2) => [Vector2, Vector2];
|
|
268
|
+
/**
|
|
269
|
+
* Returns the columns of a matrix as an array of vectors.
|
|
270
|
+
*
|
|
271
|
+
* @param m - The matrix to convert.
|
|
272
|
+
* @returns An array of vectors representing the columns of the matrix.
|
|
273
|
+
* @since 1.0.0
|
|
274
|
+
*/
|
|
42
275
|
declare const toColumns: (m: Matrix2x2) => [Vector2, Vector2];
|
|
276
|
+
/**
|
|
277
|
+
* Returns the specified row of a matrix as a vector.
|
|
278
|
+
*
|
|
279
|
+
* @param m - The matrix to get the row from.
|
|
280
|
+
* @param row - The row index (0 or 1).
|
|
281
|
+
* @returns A vector representing the specified row of the matrix.
|
|
282
|
+
* @since 1.0.0
|
|
283
|
+
*/
|
|
43
284
|
declare const rowVector: (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2;
|
|
285
|
+
/**
|
|
286
|
+
* Returns the specified column of a matrix as a vector.
|
|
287
|
+
*
|
|
288
|
+
* @param m - The matrix to get the column from.
|
|
289
|
+
* @param column - The column index (0 or 1).
|
|
290
|
+
* @returns A vector representing the specified column of the matrix.
|
|
291
|
+
* @since 1.0.0
|
|
292
|
+
*/
|
|
44
293
|
declare const columnVector: (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2;
|
|
294
|
+
/**
|
|
295
|
+
* Transposes a matrix.
|
|
296
|
+
*
|
|
297
|
+
* @param m - The matrix to transpose.
|
|
298
|
+
* @returns A new `Matrix2x2` instance representing the transposed matrix.
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
*/
|
|
45
301
|
declare const transpose: (m: Matrix2x2) => Matrix2x2;
|
|
302
|
+
/**
|
|
303
|
+
* Reverses the rows of a matrix.
|
|
304
|
+
*
|
|
305
|
+
* @param m - The matrix to reverse the rows of.
|
|
306
|
+
* @returns A new `Matrix2x2` instance with the rows reversed.
|
|
307
|
+
* @since 1.0.0
|
|
308
|
+
*/
|
|
46
309
|
declare const reverseRows: (m: Matrix2x2) => Matrix2x2;
|
|
310
|
+
/**
|
|
311
|
+
* Reverses the columns of a matrix.
|
|
312
|
+
*
|
|
313
|
+
* @param m - The matrix to reverse the columns of.
|
|
314
|
+
* @returns A new `Matrix2x2` instance with the columns reversed.
|
|
315
|
+
* @since 1.0.0
|
|
316
|
+
*/
|
|
47
317
|
declare const reverseColumns: (m: Matrix2x2) => Matrix2x2;
|
|
48
318
|
|
|
49
|
-
export {
|
|
319
|
+
export { columnVector, determinant, fromColumns, fromRows, isMatrix2x2, make, reverseColumns, reverseRows, rowVector, setColumn, setRow, solveSystem, toColumns, toRows, transpose, vectorProductLeft, vectorProductRight };
|
|
320
|
+
export type { Matrix2x2, Matrix2x2Coordinate };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as isMatrix2x2$1, m as make, f as fromRows$1, a as fromColumns$1, s as setRow$1, b as setColumn$1, d as determinant$1, v as vectorProductLeft$1, c as vectorProductRight$1, e as solveSystem$1, t as toRows$1, g as toColumns$1, r as rowVector$1, h as columnVector$1, j as transpose$1, k as reverseRows$1, l as reverseColumns$1 } from '../shared/curvy.
|
|
1
|
+
import { i as isMatrix2x2$1, m as make$1, f as fromRows$1, a as fromColumns$1, s as setRow$1, b as setColumn$1, d as determinant$1, v as vectorProductLeft$1, c as vectorProductRight$1, e as solveSystem$1, t as toRows$1, g as toColumns$1, r as rowVector$1, h as columnVector$1, j as transpose$1, k as reverseRows$1, l as reverseColumns$1 } from '../shared/curvy.BkkW8Tx9.mjs';
|
|
2
2
|
import '../utils.mjs';
|
|
3
3
|
import '../pipe.mjs';
|
|
4
|
-
import '../shared/curvy.
|
|
4
|
+
import '../shared/curvy.DJ4xO0al.mjs';
|
|
5
5
|
|
|
6
6
|
const isMatrix2x2 = isMatrix2x2$1;
|
|
7
|
-
const
|
|
7
|
+
const make = make$1;
|
|
8
8
|
const fromRows = fromRows$1;
|
|
9
9
|
const fromColumns = fromColumns$1;
|
|
10
10
|
const setRow = setRow$1;
|
|
@@ -21,4 +21,5 @@ const transpose = transpose$1;
|
|
|
21
21
|
const reverseRows = reverseRows$1;
|
|
22
22
|
const reverseColumns = reverseColumns$1;
|
|
23
23
|
|
|
24
|
-
export { columnVector, determinant, fromColumns, fromRows, isMatrix2x2,
|
|
24
|
+
export { columnVector, determinant, fromColumns, fromRows, isMatrix2x2, make, reverseColumns, reverseRows, rowVector, setColumn, setRow, solveSystem, toColumns, toRows, transpose, vectorProductLeft, vectorProductRight };
|
|
25
|
+
//# sourceMappingURL=matrix2x2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix2x2.mjs","sources":["../../src/matrix/matrix2x2.ts"],"sourcesContent":["import type { TwoDimensionalComponent, TwoDimensionalIndex } from '../dimensions'\nimport type { Pipeable } from '../pipe'\nimport type { Vector2 } from '../vector/vector2'\nimport * as internal from './matrix2x2.internal'\nimport type { Matrix2x2TypeId } from './matrix2x2.internal'\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\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"],"names":["internal.isMatrix2x2","internal.make","internal.fromRows","internal.fromColumns","internal.setRow","internal.setColumn","internal.determinant","internal.vectorProductLeft","internal.vectorProductRight","internal.solveSystem","internal.toRows","internal.toColumns","internal.rowVector","internal.columnVector","internal.transpose","internal.reverseRows","internal.reverseColumns"],"mappings":";;;;;AAgDO,MAAM,cAA8CA;AAUpD,MAAM,OACXC;AAUK,MAAM,WAAoDC;AAU1D,MAAM,cAAuDC;AAE7D,MAAM,SAoBTC;AAEG,MAAM,YAoBTC;AASG,MAAM,cAAwCC;AAE9C,MAAM,oBA4CTC;AAEG,MAAM,qBA4CTC;AAEG,MAAM,cA4CTC;AASG,MAAM,SAA+CC;AASrD,MAAM,YAAkDC;AAUxD,MAAM,YAAiEC;AAUvE,MAAM,eACXC;AASK,MAAM,YAAyCC;AAS/C,MAAM,cAA2CC;AASjD,MAAM,iBAA8CC;;;;"}
|