@lakuna/umath 3.0.0 → 3.0.1
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +46 -46
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix.d.ts +7 -7
- package/dist/linalg/Matrix.d.ts.map +1 -1
- package/dist/linalg/Matrix2.d.ts +25 -25
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +35 -35
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +56 -56
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +44 -43
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +8 -8
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +15 -15
- package/dist/linalg/SlowVector.d.ts.map +1 -1
- package/dist/linalg/SlowVector.js.map +1 -1
- package/dist/linalg/Vector.d.ts +14 -14
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +51 -51
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +60 -60
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +45 -45
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +10 -0
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +5 -5
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +13 -6
- package/dist/utility/BigNumber.js.map +1 -1
- package/package.json +4 -5
- package/src/index.ts +4 -1
- package/src/linalg/DualQuaternion.ts +69 -58
- package/src/linalg/Matrix.ts +10 -7
- package/src/linalg/Matrix2.ts +43 -32
- package/src/linalg/Matrix3.ts +53 -41
- package/src/linalg/Matrix4.ts +98 -84
- package/src/linalg/Quaternion.ts +75 -60
- package/src/linalg/SlowMatrix.ts +12 -9
- package/src/linalg/SlowSquareMatrix.ts +1 -1
- package/src/linalg/SlowVector.ts +16 -16
- package/src/linalg/Vector.ts +14 -14
- package/src/linalg/Vector2.ts +104 -76
- package/src/linalg/Vector3.ts +125 -92
- package/src/linalg/Vector4.ts +93 -62
- package/src/types/AxisAngle.ts +12 -0
- package/src/utility/BigNumber.ts +22 -11
package/src/linalg/Matrix2.ts
CHANGED
|
@@ -89,7 +89,7 @@ export const fromRotation = <T extends Matrix2Like>(r: number, out: T): T => {
|
|
|
89
89
|
* @public
|
|
90
90
|
*/
|
|
91
91
|
export const fromScaling = <T extends Matrix2Like>(
|
|
92
|
-
vector: Vector2Like
|
|
92
|
+
vector: Readonly<Vector2Like>,
|
|
93
93
|
out: T
|
|
94
94
|
): T => fromValues(vector[0], 0, 0, vector[1], out);
|
|
95
95
|
|
|
@@ -100,7 +100,10 @@ export const fromScaling = <T extends Matrix2Like>(
|
|
|
100
100
|
* @returns Whether or not the matrices are equivalent.
|
|
101
101
|
* @public
|
|
102
102
|
*/
|
|
103
|
-
export const equals = (
|
|
103
|
+
export const equals = (
|
|
104
|
+
a: Readonly<Matrix2Like>,
|
|
105
|
+
b: Readonly<Matrix2Like>
|
|
106
|
+
): boolean =>
|
|
104
107
|
approxRelative(a[0], b[0]) &&
|
|
105
108
|
approxRelative(a[1], b[1]) &&
|
|
106
109
|
approxRelative(a[2], b[2]) &&
|
|
@@ -113,8 +116,10 @@ export const equals = (a: Matrix2Like, b: Matrix2Like): boolean =>
|
|
|
113
116
|
* @returns Whether the matrices are equivalent.
|
|
114
117
|
* @public
|
|
115
118
|
*/
|
|
116
|
-
export const exactEquals: (
|
|
117
|
-
|
|
119
|
+
export const exactEquals: (
|
|
120
|
+
a: Readonly<Matrix2Like>,
|
|
121
|
+
b: Readonly<Matrix2Like>
|
|
122
|
+
) => boolean = vector4ExactEquals;
|
|
118
123
|
|
|
119
124
|
/**
|
|
120
125
|
* Add two matrices.
|
|
@@ -126,8 +131,8 @@ export const exactEquals: (a: Matrix2Like, b: Matrix2Like) => boolean =
|
|
|
126
131
|
* @public
|
|
127
132
|
*/
|
|
128
133
|
export const add: <T extends Matrix2Like>(
|
|
129
|
-
a: Matrix2Like
|
|
130
|
-
b: Matrix2Like
|
|
134
|
+
a: Readonly<Matrix2Like>,
|
|
135
|
+
b: Readonly<Matrix2Like>,
|
|
131
136
|
out: T
|
|
132
137
|
) => T = vector4Add;
|
|
133
138
|
|
|
@@ -140,7 +145,7 @@ export const add: <T extends Matrix2Like>(
|
|
|
140
145
|
* @public
|
|
141
146
|
*/
|
|
142
147
|
export const adjoint = <T extends Matrix2Like>(
|
|
143
|
-
matrix: Matrix2Like
|
|
148
|
+
matrix: Readonly<Matrix2Like>,
|
|
144
149
|
out: T
|
|
145
150
|
): T => fromValues(matrix[3], -matrix[1], -matrix[2], matrix[0], out);
|
|
146
151
|
|
|
@@ -151,8 +156,10 @@ export const adjoint = <T extends Matrix2Like>(
|
|
|
151
156
|
* @returns The copy matrix.
|
|
152
157
|
* @public
|
|
153
158
|
*/
|
|
154
|
-
export const copy: <T extends Matrix2Like>(
|
|
155
|
-
|
|
159
|
+
export const copy: <T extends Matrix2Like>(
|
|
160
|
+
matrix: Readonly<Matrix2Like>,
|
|
161
|
+
out: T
|
|
162
|
+
) => T = vector4Copy;
|
|
156
163
|
|
|
157
164
|
/**
|
|
158
165
|
* Calculate the Frobenius norm of a matrix.
|
|
@@ -161,7 +168,8 @@ export const copy: <T extends Matrix2Like>(matrix: Matrix2Like, out: T) => T =
|
|
|
161
168
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
162
169
|
* @public
|
|
163
170
|
*/
|
|
164
|
-
export const frob: (matrix: Matrix2Like) => number =
|
|
171
|
+
export const frob: (matrix: Readonly<Matrix2Like>) => number =
|
|
172
|
+
vector4GetMagnitude;
|
|
165
173
|
|
|
166
174
|
/**
|
|
167
175
|
* Multiply one matrix by another.
|
|
@@ -173,8 +181,8 @@ export const frob: (matrix: Matrix2Like) => number = vector4GetMagnitude;
|
|
|
173
181
|
* @public
|
|
174
182
|
*/
|
|
175
183
|
export const multiply = <T extends Matrix2Like>(
|
|
176
|
-
a: Matrix2Like
|
|
177
|
-
b: Matrix2Like
|
|
184
|
+
a: Readonly<Matrix2Like>,
|
|
185
|
+
b: Readonly<Matrix2Like>,
|
|
178
186
|
out: T
|
|
179
187
|
): T => {
|
|
180
188
|
const a0 = a[0];
|
|
@@ -206,7 +214,7 @@ export const multiply = <T extends Matrix2Like>(
|
|
|
206
214
|
* @public
|
|
207
215
|
*/
|
|
208
216
|
export const multiplyScalar: <T extends Matrix2Like>(
|
|
209
|
-
matrix: Matrix2Like
|
|
217
|
+
matrix: Readonly<Matrix2Like>,
|
|
210
218
|
scalar: number,
|
|
211
219
|
out: T
|
|
212
220
|
) => T = vector4Scale;
|
|
@@ -223,8 +231,8 @@ export const multiplyScalar: <T extends Matrix2Like>(
|
|
|
223
231
|
* @public
|
|
224
232
|
*/
|
|
225
233
|
export const multiplyScalarAndAdd: <T extends Matrix2Like>(
|
|
226
|
-
a: Matrix2Like
|
|
227
|
-
b: Matrix2Like
|
|
234
|
+
a: Readonly<Matrix2Like>,
|
|
235
|
+
b: Readonly<Matrix2Like>,
|
|
228
236
|
scalar: number,
|
|
229
237
|
out: T
|
|
230
238
|
) => T = vector4ScaleAndAdd;
|
|
@@ -239,8 +247,8 @@ export const multiplyScalarAndAdd: <T extends Matrix2Like>(
|
|
|
239
247
|
* @public
|
|
240
248
|
*/
|
|
241
249
|
export const subtract: <T extends Matrix2Like>(
|
|
242
|
-
a: Matrix2Like
|
|
243
|
-
b: Matrix2Like
|
|
250
|
+
a: Readonly<Matrix2Like>,
|
|
251
|
+
b: Readonly<Matrix2Like>,
|
|
244
252
|
out: T
|
|
245
253
|
) => T = vector4Subtract;
|
|
246
254
|
|
|
@@ -253,7 +261,7 @@ export const subtract: <T extends Matrix2Like>(
|
|
|
253
261
|
* @public
|
|
254
262
|
*/
|
|
255
263
|
export const transpose = <T extends Matrix2Like>(
|
|
256
|
-
matrix: Matrix2Like
|
|
264
|
+
matrix: Readonly<Matrix2Like>,
|
|
257
265
|
out: T
|
|
258
266
|
): T => {
|
|
259
267
|
if (out === matrix) {
|
|
@@ -273,7 +281,7 @@ export const transpose = <T extends Matrix2Like>(
|
|
|
273
281
|
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
274
282
|
* @public
|
|
275
283
|
*/
|
|
276
|
-
export const determinant = (matrix: Matrix2Like): number =>
|
|
284
|
+
export const determinant = (matrix: Readonly<Matrix2Like>): number =>
|
|
277
285
|
matrix[0] * matrix[3] - matrix[2] * matrix[1];
|
|
278
286
|
|
|
279
287
|
/**
|
|
@@ -295,7 +303,7 @@ export const identity = <T extends Matrix2Like>(out: T): T =>
|
|
|
295
303
|
* @public
|
|
296
304
|
*/
|
|
297
305
|
export const invert = <T extends Matrix2Like>(
|
|
298
|
-
matrix: Matrix2Like
|
|
306
|
+
matrix: Readonly<Matrix2Like>,
|
|
299
307
|
out: T
|
|
300
308
|
): T => {
|
|
301
309
|
const a0 = matrix[0];
|
|
@@ -322,7 +330,7 @@ export const invert = <T extends Matrix2Like>(
|
|
|
322
330
|
* @public
|
|
323
331
|
*/
|
|
324
332
|
export const rotate = <T extends Matrix2Like>(
|
|
325
|
-
matrix: Matrix2Like
|
|
333
|
+
matrix: Readonly<Matrix2Like>,
|
|
326
334
|
r: number,
|
|
327
335
|
out: T
|
|
328
336
|
): T => {
|
|
@@ -353,8 +361,8 @@ export const rotate = <T extends Matrix2Like>(
|
|
|
353
361
|
* @public
|
|
354
362
|
*/
|
|
355
363
|
export const scale = <T extends Matrix2Like>(
|
|
356
|
-
matrix: Matrix2Like
|
|
357
|
-
vector: Vector2Like
|
|
364
|
+
matrix: Readonly<Matrix2Like>,
|
|
365
|
+
vector: Readonly<Vector2Like>,
|
|
358
366
|
out: T
|
|
359
367
|
): T => {
|
|
360
368
|
const v0 = vector[0];
|
|
@@ -446,7 +454,7 @@ export default class Matrix2
|
|
|
446
454
|
* @returns The transformation matrix.
|
|
447
455
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
448
456
|
*/
|
|
449
|
-
public static fromScaling(vector: Vector2Like): Matrix2 {
|
|
457
|
+
public static fromScaling(vector: Readonly<Vector2Like>): Matrix2 {
|
|
450
458
|
return fromScaling(vector, new Matrix2());
|
|
451
459
|
}
|
|
452
460
|
|
|
@@ -473,7 +481,7 @@ export default class Matrix2
|
|
|
473
481
|
* @returns The sum of the matrices.
|
|
474
482
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
475
483
|
*/
|
|
476
|
-
public add(matrix: Matrix2Like): Matrix2 {
|
|
484
|
+
public add(matrix: Readonly<Matrix2Like>): Matrix2 {
|
|
477
485
|
return add(this, matrix, new Matrix2());
|
|
478
486
|
}
|
|
479
487
|
|
|
@@ -499,7 +507,7 @@ export default class Matrix2
|
|
|
499
507
|
* @param matrix - The matrix to copy.
|
|
500
508
|
* @returns This matrix.
|
|
501
509
|
*/
|
|
502
|
-
public copy(matrix: Matrix2Like): this {
|
|
510
|
+
public copy(matrix: Readonly<Matrix2Like>): this {
|
|
503
511
|
return copy(matrix, this);
|
|
504
512
|
}
|
|
505
513
|
|
|
@@ -508,7 +516,7 @@ export default class Matrix2
|
|
|
508
516
|
* @param matrix - The other matrix.
|
|
509
517
|
* @returns Whether the matrices are equivalent.
|
|
510
518
|
*/
|
|
511
|
-
public equals(matrix: Matrix2Like): boolean {
|
|
519
|
+
public equals(matrix: Readonly<Matrix2Like>): boolean {
|
|
512
520
|
return equals(this, matrix);
|
|
513
521
|
}
|
|
514
522
|
|
|
@@ -517,7 +525,7 @@ export default class Matrix2
|
|
|
517
525
|
* @param matrix - The other matrix.
|
|
518
526
|
* @returns Whether the matrices are equivalent.
|
|
519
527
|
*/
|
|
520
|
-
public exactEquals(matrix: Matrix2Like): boolean {
|
|
528
|
+
public exactEquals(matrix: Readonly<Matrix2Like>): boolean {
|
|
521
529
|
return exactEquals(this, matrix);
|
|
522
530
|
}
|
|
523
531
|
|
|
@@ -546,7 +554,7 @@ export default class Matrix2
|
|
|
546
554
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
547
555
|
* @public
|
|
548
556
|
*/
|
|
549
|
-
public multiply(matrix: Matrix2Like): Matrix2 {
|
|
557
|
+
public multiply(matrix: Readonly<Matrix2Like>): Matrix2 {
|
|
550
558
|
return multiply(this, matrix, new Matrix2());
|
|
551
559
|
}
|
|
552
560
|
|
|
@@ -568,7 +576,10 @@ export default class Matrix2
|
|
|
568
576
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
569
577
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
570
578
|
*/
|
|
571
|
-
public multiplyScalarAndAdd(
|
|
579
|
+
public multiplyScalarAndAdd(
|
|
580
|
+
matrix: Readonly<Matrix2Like>,
|
|
581
|
+
scalar: number
|
|
582
|
+
): Matrix2 {
|
|
572
583
|
return multiplyScalarAndAdd(this, matrix, scalar, new Matrix2());
|
|
573
584
|
}
|
|
574
585
|
|
|
@@ -588,7 +599,7 @@ export default class Matrix2
|
|
|
588
599
|
* @returns The scaled matrix.
|
|
589
600
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
590
601
|
*/
|
|
591
|
-
public scale(vector: Vector2Like): Matrix2 {
|
|
602
|
+
public scale(vector: Readonly<Vector2Like>): Matrix2 {
|
|
592
603
|
return scale(this, vector, new Matrix2());
|
|
593
604
|
}
|
|
594
605
|
|
|
@@ -598,7 +609,7 @@ export default class Matrix2
|
|
|
598
609
|
* @returns The difference between the matrices.
|
|
599
610
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
600
611
|
*/
|
|
601
|
-
public subtract(matrix: Matrix2Like): Matrix2 {
|
|
612
|
+
public subtract(matrix: Readonly<Matrix2Like>): Matrix2 {
|
|
602
613
|
return subtract(this, matrix, new Matrix2());
|
|
603
614
|
}
|
|
604
615
|
|
package/src/linalg/Matrix3.ts
CHANGED
|
@@ -122,7 +122,7 @@ export const fromRotation = <T extends Matrix3Like>(r: number, out: T): T => {
|
|
|
122
122
|
* @public
|
|
123
123
|
*/
|
|
124
124
|
export const fromScaling = <T extends Matrix3Like>(
|
|
125
|
-
vector: Vector2Like
|
|
125
|
+
vector: Readonly<Vector2Like>,
|
|
126
126
|
out: T
|
|
127
127
|
): T => fromValues(vector[0], 0, 0, 0, vector[1], 0, 0, 0, 1, out);
|
|
128
128
|
|
|
@@ -135,7 +135,7 @@ export const fromScaling = <T extends Matrix3Like>(
|
|
|
135
135
|
* @public
|
|
136
136
|
*/
|
|
137
137
|
export const fromTranslation = <T extends Matrix3Like>(
|
|
138
|
-
vector: Vector2Like
|
|
138
|
+
vector: Readonly<Vector2Like>,
|
|
139
139
|
out: T
|
|
140
140
|
): T => fromValues(1, 0, 0, 0, 1, 0, vector[0], vector[1], 1, out);
|
|
141
141
|
|
|
@@ -149,7 +149,7 @@ export const fromTranslation = <T extends Matrix3Like>(
|
|
|
149
149
|
* @public
|
|
150
150
|
*/
|
|
151
151
|
export const fromQuaternion = <T extends Matrix3Like>(
|
|
152
|
-
quaternion: QuaternionLike
|
|
152
|
+
quaternion: Readonly<QuaternionLike>,
|
|
153
153
|
out: T
|
|
154
154
|
): T => {
|
|
155
155
|
const x = quaternion[0];
|
|
@@ -233,7 +233,7 @@ export const fromEuler = <T extends Matrix3Like>(
|
|
|
233
233
|
* @public
|
|
234
234
|
*/
|
|
235
235
|
export const normalFromMatrix4 = <T extends Matrix3Like>(
|
|
236
|
-
matrix: Matrix4Like
|
|
236
|
+
matrix: Readonly<Matrix4Like>,
|
|
237
237
|
out: T
|
|
238
238
|
): T => {
|
|
239
239
|
const a00 = matrix[0];
|
|
@@ -311,7 +311,7 @@ export const projection = <T extends Matrix3Like>(
|
|
|
311
311
|
* @public
|
|
312
312
|
*/
|
|
313
313
|
export const fromMatrix4 = <T extends Matrix3Like>(
|
|
314
|
-
matrix: Matrix4Like
|
|
314
|
+
matrix: Readonly<Matrix4Like>,
|
|
315
315
|
out: T
|
|
316
316
|
): T =>
|
|
317
317
|
fromValues(
|
|
@@ -334,7 +334,10 @@ export const fromMatrix4 = <T extends Matrix3Like>(
|
|
|
334
334
|
* @returns Whether or not the matrices are equivalent.
|
|
335
335
|
* @public
|
|
336
336
|
*/
|
|
337
|
-
export const equals = (
|
|
337
|
+
export const equals = (
|
|
338
|
+
a: Readonly<Matrix3Like>,
|
|
339
|
+
b: Readonly<Matrix3Like>
|
|
340
|
+
): boolean =>
|
|
338
341
|
approxRelative(a[0], b[0]) &&
|
|
339
342
|
approxRelative(a[1], b[1]) &&
|
|
340
343
|
approxRelative(a[2], b[2]) &&
|
|
@@ -352,7 +355,10 @@ export const equals = (a: Matrix3Like, b: Matrix3Like): boolean =>
|
|
|
352
355
|
* @returns Whether or not the matrices are equivalent.
|
|
353
356
|
* @public
|
|
354
357
|
*/
|
|
355
|
-
export const exactEquals = (
|
|
358
|
+
export const exactEquals = (
|
|
359
|
+
a: Readonly<Matrix3Like>,
|
|
360
|
+
b: Readonly<Matrix3Like>
|
|
361
|
+
): boolean =>
|
|
356
362
|
a[0] === b[0] &&
|
|
357
363
|
a[1] === b[1] &&
|
|
358
364
|
a[2] === b[2] &&
|
|
@@ -373,8 +379,8 @@ export const exactEquals = (a: Matrix3Like, b: Matrix3Like): boolean =>
|
|
|
373
379
|
* @public
|
|
374
380
|
*/
|
|
375
381
|
export const add = <T extends Matrix3Like>(
|
|
376
|
-
a: Matrix3Like
|
|
377
|
-
b: Matrix3Like
|
|
382
|
+
a: Readonly<Matrix3Like>,
|
|
383
|
+
b: Readonly<Matrix3Like>,
|
|
378
384
|
out: T
|
|
379
385
|
): T =>
|
|
380
386
|
fromValues(
|
|
@@ -399,7 +405,7 @@ export const add = <T extends Matrix3Like>(
|
|
|
399
405
|
* @public
|
|
400
406
|
*/
|
|
401
407
|
export const adjoint = <T extends Matrix3Like>(
|
|
402
|
-
matrix: Matrix3Like
|
|
408
|
+
matrix: Readonly<Matrix3Like>,
|
|
403
409
|
out: T
|
|
404
410
|
): T => {
|
|
405
411
|
const a00 = matrix[0];
|
|
@@ -433,7 +439,10 @@ export const adjoint = <T extends Matrix3Like>(
|
|
|
433
439
|
* @returns The copy matrix.
|
|
434
440
|
* @public
|
|
435
441
|
*/
|
|
436
|
-
export const copy = <T extends Matrix3Like>(
|
|
442
|
+
export const copy = <T extends Matrix3Like>(
|
|
443
|
+
matrix: Readonly<Matrix3Like>,
|
|
444
|
+
out: T
|
|
445
|
+
): T =>
|
|
437
446
|
fromValues(
|
|
438
447
|
matrix[0],
|
|
439
448
|
matrix[1],
|
|
@@ -454,7 +463,7 @@ export const copy = <T extends Matrix3Like>(matrix: Matrix3Like, out: T): T =>
|
|
|
454
463
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
455
464
|
* @public
|
|
456
465
|
*/
|
|
457
|
-
export const frob = (matrix: Matrix3Like): number =>
|
|
466
|
+
export const frob = (matrix: Readonly<Matrix3Like>): number =>
|
|
458
467
|
Math.hypot(
|
|
459
468
|
matrix[0],
|
|
460
469
|
matrix[1],
|
|
@@ -477,8 +486,8 @@ export const frob = (matrix: Matrix3Like): number =>
|
|
|
477
486
|
* @public
|
|
478
487
|
*/
|
|
479
488
|
export const multiply = <T extends Matrix3Like>(
|
|
480
|
-
a: Matrix3Like
|
|
481
|
-
b: Matrix3Like
|
|
489
|
+
a: Readonly<Matrix3Like>,
|
|
490
|
+
b: Readonly<Matrix3Like>,
|
|
482
491
|
out: T
|
|
483
492
|
): T => {
|
|
484
493
|
const a00 = a[0];
|
|
@@ -525,7 +534,7 @@ export const multiply = <T extends Matrix3Like>(
|
|
|
525
534
|
* @public
|
|
526
535
|
*/
|
|
527
536
|
export const multiplyScalar = <T extends Matrix3Like>(
|
|
528
|
-
matrix: Matrix3Like
|
|
537
|
+
matrix: Readonly<Matrix3Like>,
|
|
529
538
|
scalar: number,
|
|
530
539
|
out: T
|
|
531
540
|
): T =>
|
|
@@ -554,8 +563,8 @@ export const multiplyScalar = <T extends Matrix3Like>(
|
|
|
554
563
|
* @public
|
|
555
564
|
*/
|
|
556
565
|
export const multiplyScalarAndAdd = <T extends Matrix3Like>(
|
|
557
|
-
a: Matrix3Like
|
|
558
|
-
b: Matrix3Like
|
|
566
|
+
a: Readonly<Matrix3Like>,
|
|
567
|
+
b: Readonly<Matrix3Like>,
|
|
559
568
|
scalar: number,
|
|
560
569
|
out: T
|
|
561
570
|
): T =>
|
|
@@ -582,8 +591,8 @@ export const multiplyScalarAndAdd = <T extends Matrix3Like>(
|
|
|
582
591
|
* @public
|
|
583
592
|
*/
|
|
584
593
|
export const subtract = <T extends Matrix3Like>(
|
|
585
|
-
a: Matrix3Like
|
|
586
|
-
b: Matrix3Like
|
|
594
|
+
a: Readonly<Matrix3Like>,
|
|
595
|
+
b: Readonly<Matrix3Like>,
|
|
587
596
|
out: T
|
|
588
597
|
): T =>
|
|
589
598
|
fromValues(
|
|
@@ -608,7 +617,7 @@ export const subtract = <T extends Matrix3Like>(
|
|
|
608
617
|
* @public
|
|
609
618
|
*/
|
|
610
619
|
export const transpose = <T extends Matrix3Like>(
|
|
611
|
-
matrix: Matrix3Like
|
|
620
|
+
matrix: Readonly<Matrix3Like>,
|
|
612
621
|
out: T
|
|
613
622
|
): T => {
|
|
614
623
|
if (out === matrix) {
|
|
@@ -645,7 +654,7 @@ export const transpose = <T extends Matrix3Like>(
|
|
|
645
654
|
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
646
655
|
* @public
|
|
647
656
|
*/
|
|
648
|
-
export const determinant = (matrix: Matrix3Like): number => {
|
|
657
|
+
export const determinant = (matrix: Readonly<Matrix3Like>): number => {
|
|
649
658
|
const a10 = matrix[3];
|
|
650
659
|
const a11 = matrix[4];
|
|
651
660
|
const a12 = matrix[5];
|
|
@@ -679,7 +688,7 @@ export const identity = <T extends Matrix3Like>(out: T): T =>
|
|
|
679
688
|
* @public
|
|
680
689
|
*/
|
|
681
690
|
export const invert = <T extends Matrix3Like>(
|
|
682
|
-
matrix: Matrix3Like
|
|
691
|
+
matrix: Readonly<Matrix3Like>,
|
|
683
692
|
out: T
|
|
684
693
|
): T => {
|
|
685
694
|
const a00 = matrix[0];
|
|
@@ -726,7 +735,7 @@ export const invert = <T extends Matrix3Like>(
|
|
|
726
735
|
* @public
|
|
727
736
|
*/
|
|
728
737
|
export const rotate = <T extends Matrix3Like>(
|
|
729
|
-
matrix: Matrix3Like
|
|
738
|
+
matrix: Readonly<Matrix3Like>,
|
|
730
739
|
radians: number,
|
|
731
740
|
out: T
|
|
732
741
|
): T => {
|
|
@@ -764,8 +773,8 @@ export const rotate = <T extends Matrix3Like>(
|
|
|
764
773
|
* @public
|
|
765
774
|
*/
|
|
766
775
|
export const scale = <T extends Matrix3Like>(
|
|
767
|
-
matrix: Matrix3Like
|
|
768
|
-
vector: Vector2Like
|
|
776
|
+
matrix: Readonly<Matrix3Like>,
|
|
777
|
+
vector: Readonly<Vector2Like>,
|
|
769
778
|
out: T
|
|
770
779
|
): T => {
|
|
771
780
|
const x = vector[0];
|
|
@@ -795,8 +804,8 @@ export const scale = <T extends Matrix3Like>(
|
|
|
795
804
|
* @public
|
|
796
805
|
*/
|
|
797
806
|
export const translate = <T extends Matrix3Like>(
|
|
798
|
-
matrix: Matrix3Like
|
|
799
|
-
vector: Vector2Like
|
|
807
|
+
matrix: Readonly<Matrix3Like>,
|
|
808
|
+
vector: Readonly<Vector2Like>,
|
|
800
809
|
out: T
|
|
801
810
|
): T => {
|
|
802
811
|
const a00 = matrix[0];
|
|
@@ -923,7 +932,7 @@ export default class Matrix3
|
|
|
923
932
|
* @param matrix - The four-by-four matrix.
|
|
924
933
|
* @returns The three-by-three matrix.
|
|
925
934
|
*/
|
|
926
|
-
public static fromMatrix4(matrix: Matrix4Like): Matrix3 {
|
|
935
|
+
public static fromMatrix4(matrix: Readonly<Matrix4Like>): Matrix3 {
|
|
927
936
|
return fromMatrix4(matrix, new Matrix3());
|
|
928
937
|
}
|
|
929
938
|
|
|
@@ -934,7 +943,7 @@ export default class Matrix3
|
|
|
934
943
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
935
944
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
936
945
|
*/
|
|
937
|
-
public static fromQuaternion(quaternion: QuaternionLike): Matrix3 {
|
|
946
|
+
public static fromQuaternion(quaternion: Readonly<QuaternionLike>): Matrix3 {
|
|
938
947
|
return fromQuaternion(quaternion, new Matrix3());
|
|
939
948
|
}
|
|
940
949
|
|
|
@@ -954,7 +963,7 @@ export default class Matrix3
|
|
|
954
963
|
* @returns The transformation matrix.
|
|
955
964
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
956
965
|
*/
|
|
957
|
-
public static fromScaling(vector: Vector2Like): Matrix3 {
|
|
966
|
+
public static fromScaling(vector: Readonly<Vector2Like>): Matrix3 {
|
|
958
967
|
return fromScaling(vector, new Matrix3());
|
|
959
968
|
}
|
|
960
969
|
|
|
@@ -964,7 +973,7 @@ export default class Matrix3
|
|
|
964
973
|
* @returns The transformation matrix.
|
|
965
974
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
966
975
|
*/
|
|
967
|
-
public static fromTranslation(vector: Vector2Like): Matrix3 {
|
|
976
|
+
public static fromTranslation(vector: Readonly<Vector2Like>): Matrix3 {
|
|
968
977
|
return fromTranslation(vector, new Matrix3());
|
|
969
978
|
}
|
|
970
979
|
|
|
@@ -1012,7 +1021,7 @@ export default class Matrix3
|
|
|
1012
1021
|
* @returns The normal matrix.
|
|
1013
1022
|
* @see {@link https://en.wikipedia.org/wiki/Normal_matrix | Normal matrix}
|
|
1014
1023
|
*/
|
|
1015
|
-
public static normalFromMatrix4(matrix: Matrix4Like): Matrix3 {
|
|
1024
|
+
public static normalFromMatrix4(matrix: Readonly<Matrix4Like>): Matrix3 {
|
|
1016
1025
|
return normalFromMatrix4(matrix, new Matrix3());
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
@@ -1034,7 +1043,7 @@ export default class Matrix3
|
|
|
1034
1043
|
* @returns The sum of the matrices.
|
|
1035
1044
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
1036
1045
|
*/
|
|
1037
|
-
public add(matrix: Matrix3Like): Matrix3 {
|
|
1046
|
+
public add(matrix: Readonly<Matrix3Like>): Matrix3 {
|
|
1038
1047
|
return add(this, matrix, new Matrix3());
|
|
1039
1048
|
}
|
|
1040
1049
|
|
|
@@ -1060,7 +1069,7 @@ export default class Matrix3
|
|
|
1060
1069
|
* @param matrix - The matrix to copy.
|
|
1061
1070
|
* @returns This matrix.
|
|
1062
1071
|
*/
|
|
1063
|
-
public copy(matrix: Matrix3Like): this {
|
|
1072
|
+
public copy(matrix: Readonly<Matrix3Like>): this {
|
|
1064
1073
|
return copy(matrix, this);
|
|
1065
1074
|
}
|
|
1066
1075
|
|
|
@@ -1069,7 +1078,7 @@ export default class Matrix3
|
|
|
1069
1078
|
* @param matrix - The other matrix.
|
|
1070
1079
|
* @returns Whether or not the matrices are equivalent.
|
|
1071
1080
|
*/
|
|
1072
|
-
public equals(matrix: Matrix3Like): boolean {
|
|
1081
|
+
public equals(matrix: Readonly<Matrix3Like>): boolean {
|
|
1073
1082
|
return equals(this, matrix);
|
|
1074
1083
|
}
|
|
1075
1084
|
|
|
@@ -1078,7 +1087,7 @@ export default class Matrix3
|
|
|
1078
1087
|
* @param matrix - The other matrix.
|
|
1079
1088
|
* @returns Whether or not the matrices are equivalent.
|
|
1080
1089
|
*/
|
|
1081
|
-
public exactEquals(matrix: Matrix3Like): boolean {
|
|
1090
|
+
public exactEquals(matrix: Readonly<Matrix3Like>): boolean {
|
|
1082
1091
|
return exactEquals(this, matrix);
|
|
1083
1092
|
}
|
|
1084
1093
|
|
|
@@ -1106,7 +1115,7 @@ export default class Matrix3
|
|
|
1106
1115
|
* @returns The product of the matrices.
|
|
1107
1116
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
1108
1117
|
*/
|
|
1109
|
-
public multiply(matrix: Matrix3Like): Matrix3 {
|
|
1118
|
+
public multiply(matrix: Readonly<Matrix3Like>): Matrix3 {
|
|
1110
1119
|
return multiply(this, matrix, new Matrix3());
|
|
1111
1120
|
}
|
|
1112
1121
|
|
|
@@ -1128,7 +1137,10 @@ export default class Matrix3
|
|
|
1128
1137
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
1129
1138
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
1130
1139
|
*/
|
|
1131
|
-
public multiplyScalarAndAdd(
|
|
1140
|
+
public multiplyScalarAndAdd(
|
|
1141
|
+
matrix: Readonly<Matrix3Like>,
|
|
1142
|
+
scalar: number
|
|
1143
|
+
): Matrix3 {
|
|
1132
1144
|
return multiplyScalarAndAdd(this, matrix, scalar, new Matrix3());
|
|
1133
1145
|
}
|
|
1134
1146
|
|
|
@@ -1148,7 +1160,7 @@ export default class Matrix3
|
|
|
1148
1160
|
* @returns The scaled matrix.
|
|
1149
1161
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
1150
1162
|
*/
|
|
1151
|
-
public scale(vector: Vector2Like): Matrix3 {
|
|
1163
|
+
public scale(vector: Readonly<Vector2Like>): Matrix3 {
|
|
1152
1164
|
return scale(this, vector, new Matrix3());
|
|
1153
1165
|
}
|
|
1154
1166
|
|
|
@@ -1158,7 +1170,7 @@ export default class Matrix3
|
|
|
1158
1170
|
* @returns The difference between the matrices.
|
|
1159
1171
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
1160
1172
|
*/
|
|
1161
|
-
public subtract(matrix: Matrix3Like): Matrix3 {
|
|
1173
|
+
public subtract(matrix: Readonly<Matrix3Like>): Matrix3 {
|
|
1162
1174
|
return subtract(this, matrix, new Matrix3());
|
|
1163
1175
|
}
|
|
1164
1176
|
|
|
@@ -1168,7 +1180,7 @@ export default class Matrix3
|
|
|
1168
1180
|
* @returns The translated matrix.
|
|
1169
1181
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
1170
1182
|
*/
|
|
1171
|
-
public translate(vector: Vector2Like): Matrix3 {
|
|
1183
|
+
public translate(vector: Readonly<Vector2Like>): Matrix3 {
|
|
1172
1184
|
return translate(this, vector, new Matrix3());
|
|
1173
1185
|
}
|
|
1174
1186
|
|