@lakuna/umath 2.0.0 → 3.0.0
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/LICENSE +1 -1
- package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
- package/dist/algorithms/greatestCommonDivisor.js +14 -4
- package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +124 -124
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +173 -165
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix.d.ts +24 -24
- package/dist/linalg/Matrix.d.ts.map +1 -1
- package/dist/linalg/Matrix2.d.ts +63 -63
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +92 -88
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +107 -107
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +147 -138
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +200 -201
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +272 -251
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +116 -116
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +175 -161
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +5 -5
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +12 -12
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +15 -15
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +70 -70
- package/dist/linalg/SlowVector.d.ts.map +1 -1
- package/dist/linalg/SlowVector.js +153 -153
- package/dist/linalg/SlowVector.js.map +1 -1
- package/dist/linalg/SquareMatrix.d.ts +8 -8
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector.d.ts +85 -84
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +104 -104
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +145 -143
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +130 -130
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +176 -173
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +101 -101
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +144 -140
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +2 -2
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/types/FieldOfView.d.ts +2 -2
- package/dist/types/FieldOfView.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +21 -11
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +42 -31
- package/dist/utility/BigNumber.js.map +1 -1
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -1
- package/dist/utility/createAxisAngleLike.js.map +1 -1
- package/package.json +11 -9
- package/src/algorithms/greatestCommonDivisor.ts +19 -7
- package/src/index.ts +17 -13
- package/src/linalg/DualQuaternion.ts +208 -193
- package/src/linalg/Matrix.ts +28 -28
- package/src/linalg/Matrix2.ts +117 -108
- package/src/linalg/Matrix3.ts +177 -158
- package/src/linalg/Matrix4.ts +386 -348
- package/src/linalg/Quaternion.ts +207 -189
- package/src/linalg/SlowMatrix.ts +19 -18
- package/src/linalg/SlowSquareMatrix.ts +19 -18
- package/src/linalg/SlowVector.ts +170 -169
- package/src/linalg/SquareMatrix.ts +9 -9
- package/src/linalg/Vector.ts +91 -89
- package/src/linalg/Vector2.ts +160 -155
- package/src/linalg/Vector3.ts +206 -199
- package/src/linalg/Vector4.ts +165 -156
- package/src/types/AxisAngle.ts +3 -3
- package/src/types/FieldOfView.ts +3 -3
- package/src/utility/BigNumber.ts +63 -41
- package/src/utility/createAxisAngleLike.ts +1 -0
package/src/linalg/Matrix.ts
CHANGED
|
@@ -1,63 +1,54 @@
|
|
|
1
1
|
import type { Matrix4Like } from "./Matrix4.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* An object that could be interpreted as a matrix.
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export type MatrixLike = Record<number, number>;
|
|
8
|
-
|
|
9
3
|
/**
|
|
10
4
|
* A rectangular array of numbers, arranged in rows and columns.
|
|
11
5
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_(mathematics) | Matrix}
|
|
12
6
|
* @public
|
|
13
7
|
*/
|
|
14
8
|
export default interface Matrix extends MatrixLike {
|
|
15
|
-
/** The number of rows in this matrix. */
|
|
16
|
-
height: number;
|
|
17
|
-
|
|
18
|
-
/** The number of columns in this matrix. */
|
|
19
|
-
width: number;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get the Frobenius norm of this matrix.
|
|
23
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
24
|
-
*/
|
|
25
|
-
get frob(): number;
|
|
26
|
-
|
|
27
9
|
/**
|
|
28
10
|
* Add two matrices of the same size.
|
|
29
11
|
* @param matrix - The other matrix.
|
|
30
12
|
* @returns The sum of the matrices.
|
|
31
13
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
32
14
|
*/
|
|
33
|
-
add(matrix: Matrix4Like)
|
|
15
|
+
add: (matrix: Matrix4Like) => MatrixLike;
|
|
34
16
|
|
|
35
17
|
/**
|
|
36
18
|
* Create a copy of this matrix.
|
|
37
19
|
* @returns A copy of this matrix.
|
|
38
20
|
*/
|
|
39
|
-
clone()
|
|
21
|
+
clone: () => MatrixLike;
|
|
40
22
|
|
|
41
23
|
/**
|
|
42
24
|
* Copy the values of another matrix into this one.
|
|
43
25
|
* @param matrix - The matrix to copy.
|
|
44
26
|
* @returns This matrix.
|
|
45
27
|
*/
|
|
46
|
-
copy(matrix: Matrix4Like)
|
|
28
|
+
copy: (matrix: Matrix4Like) => this;
|
|
47
29
|
|
|
48
30
|
/**
|
|
49
31
|
* Determine whether or not this matrix is roughly equivalent to another.
|
|
50
32
|
* @param matrix - The other matrix.
|
|
51
33
|
* @returns Whether the matrices are equivalent.
|
|
52
34
|
*/
|
|
53
|
-
equals(matrix: Matrix4Like)
|
|
35
|
+
equals: (matrix: Matrix4Like) => boolean;
|
|
54
36
|
|
|
55
37
|
/**
|
|
56
38
|
* Determine whether or not this matrix is exactly equivalent to another.
|
|
57
39
|
* @param matrix - The other matrix.
|
|
58
40
|
* @returns Whether the matrices are equivalent.
|
|
59
41
|
*/
|
|
60
|
-
exactEquals(matrix: Matrix4Like)
|
|
42
|
+
exactEquals: (matrix: Matrix4Like) => boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the Frobenius norm of this matrix.
|
|
46
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
47
|
+
*/
|
|
48
|
+
get frob(): number;
|
|
49
|
+
|
|
50
|
+
/** The number of rows in this matrix. */
|
|
51
|
+
height: number;
|
|
61
52
|
|
|
62
53
|
/**
|
|
63
54
|
* Multiply this matrix by another.
|
|
@@ -65,7 +56,7 @@ export default interface Matrix extends MatrixLike {
|
|
|
65
56
|
* @returns The product of the matrices.
|
|
66
57
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
67
58
|
*/
|
|
68
|
-
multiply(matrix: Matrix4Like)
|
|
59
|
+
multiply: (matrix: Matrix4Like) => MatrixLike;
|
|
69
60
|
|
|
70
61
|
/**
|
|
71
62
|
* Multiply this matrix by a scalar value.
|
|
@@ -73,7 +64,7 @@ export default interface Matrix extends MatrixLike {
|
|
|
73
64
|
* @returns The product of the matrix and the scalar value.
|
|
74
65
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
75
66
|
*/
|
|
76
|
-
multiplyScalar(scalar: number)
|
|
67
|
+
multiplyScalar: (scalar: number) => MatrixLike;
|
|
77
68
|
|
|
78
69
|
/**
|
|
79
70
|
* Add this matrix to another after multiplying the other by a scalar.
|
|
@@ -83,7 +74,7 @@ export default interface Matrix extends MatrixLike {
|
|
|
83
74
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
84
75
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
85
76
|
*/
|
|
86
|
-
multiplyScalarAndAdd(matrix: Matrix4Like, scalar: number)
|
|
77
|
+
multiplyScalarAndAdd: (matrix: Matrix4Like, scalar: number) => MatrixLike;
|
|
87
78
|
|
|
88
79
|
/**
|
|
89
80
|
* Subtract another matrix from this one.
|
|
@@ -91,12 +82,21 @@ export default interface Matrix extends MatrixLike {
|
|
|
91
82
|
* @returns The difference between the matrices.
|
|
92
83
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
93
84
|
*/
|
|
94
|
-
subtract(matrix: Matrix4Like)
|
|
85
|
+
subtract: (matrix: Matrix4Like) => MatrixLike;
|
|
95
86
|
|
|
96
87
|
/**
|
|
97
88
|
* Transpose this matrix.
|
|
98
89
|
* @returns The transpose of this matrix.
|
|
99
90
|
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
100
91
|
*/
|
|
101
|
-
transpose()
|
|
92
|
+
transpose: () => MatrixLike;
|
|
93
|
+
|
|
94
|
+
/** The number of columns in this matrix. */
|
|
95
|
+
width: number;
|
|
102
96
|
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* An object that could be interpreted as a matrix.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export type MatrixLike = Record<number, number>;
|
package/src/linalg/Matrix2.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { MatrixLike } from "./Matrix.js";
|
|
2
|
+
import type SquareMatrix from "./SquareMatrix.js";
|
|
3
|
+
import type { Vector2Like } from "./Vector2.js";
|
|
4
|
+
|
|
5
|
+
import approxRelative from "../algorithms/approxRelative.js";
|
|
6
|
+
import SingularMatrixError from "../utility/SingularMatrixError.js";
|
|
1
7
|
import {
|
|
2
8
|
add as vector4Add,
|
|
3
9
|
copy as vector4Copy,
|
|
@@ -8,11 +14,6 @@ import {
|
|
|
8
14
|
scaleAndAdd as vector4ScaleAndAdd,
|
|
9
15
|
subtract as vector4Subtract
|
|
10
16
|
} from "./Vector4.js";
|
|
11
|
-
import type { MatrixLike } from "./Matrix.js";
|
|
12
|
-
import SingularMatrixError from "../utility/SingularMatrixError.js";
|
|
13
|
-
import type SquareMatrix from "./SquareMatrix.js";
|
|
14
|
-
import type { Vector2Like } from "./Vector2.js";
|
|
15
|
-
import approxRelative from "../algorithms/approxRelative.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Numbers arranged into two columns and two rows.
|
|
@@ -21,15 +22,19 @@ import approxRelative from "../algorithms/approxRelative.js";
|
|
|
21
22
|
*/
|
|
22
23
|
export interface Matrix2Like extends MatrixLike {
|
|
23
24
|
/** The value in the first column and first row. */
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24
26
|
0: number;
|
|
25
27
|
|
|
26
28
|
/** The value in the first column and second row. */
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
30
|
1: number;
|
|
28
31
|
|
|
29
32
|
/** The value in the second column and first row. */
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
30
34
|
2: number;
|
|
31
35
|
|
|
32
36
|
/** The value in the second column and second row. */
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
38
|
3: number;
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -38,9 +43,9 @@ export interface Matrix2Like extends MatrixLike {
|
|
|
38
43
|
* @returns A two-by-two matrix-like object.
|
|
39
44
|
* @public
|
|
40
45
|
*/
|
|
41
|
-
export const createMatrix2Like = (): Float32Array & Matrix2Like =>
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
export const createMatrix2Like = (): Float32Array & Matrix2Like =>
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
48
|
+
new Float32Array(4) as Float32Array & Matrix2Like;
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* Create a two-by-two matrix with the given values.
|
|
@@ -371,8 +376,60 @@ export const scale = <T extends Matrix2Like>(
|
|
|
371
376
|
*/
|
|
372
377
|
export default class Matrix2
|
|
373
378
|
extends Float32Array
|
|
374
|
-
implements
|
|
379
|
+
implements Matrix2Like, SquareMatrix
|
|
375
380
|
{
|
|
381
|
+
/** The value in the first column and first row. */
|
|
382
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
383
|
+
public 0: number;
|
|
384
|
+
|
|
385
|
+
/** The value in the first column and second row. */
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
387
|
+
public 1: number;
|
|
388
|
+
|
|
389
|
+
/** The value in the second column and first row. */
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
391
|
+
public 2: number;
|
|
392
|
+
|
|
393
|
+
/** The value in the second column and second row. */
|
|
394
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
395
|
+
public 3: number;
|
|
396
|
+
|
|
397
|
+
/** The number of rows in this matrix. */
|
|
398
|
+
public readonly height: 2;
|
|
399
|
+
|
|
400
|
+
/** The number of columns in this matrix. */
|
|
401
|
+
public readonly width: 2;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Get the determinant of this matrix.
|
|
405
|
+
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
406
|
+
*/
|
|
407
|
+
public get determinant(): number {
|
|
408
|
+
return determinant(this);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Get the Frobenius norm of this matrix.
|
|
413
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
414
|
+
*/
|
|
415
|
+
public get frob(): number {
|
|
416
|
+
return frob(this);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Create a two-by-two identity matrix.
|
|
421
|
+
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
422
|
+
*/
|
|
423
|
+
public constructor() {
|
|
424
|
+
super(4);
|
|
425
|
+
|
|
426
|
+
this[0] = 1;
|
|
427
|
+
this[3] = 1;
|
|
428
|
+
|
|
429
|
+
this.width = 2;
|
|
430
|
+
this.height = 2;
|
|
431
|
+
}
|
|
432
|
+
|
|
376
433
|
/**
|
|
377
434
|
* Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
|
|
378
435
|
* @param r - The angle in radians.
|
|
@@ -410,56 +467,6 @@ export default class Matrix2
|
|
|
410
467
|
return fromValues(c0r0, c0r1, c1r0, c1r1, new Matrix2());
|
|
411
468
|
}
|
|
412
469
|
|
|
413
|
-
/**
|
|
414
|
-
* Create a two-by-two identity matrix.
|
|
415
|
-
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
416
|
-
*/
|
|
417
|
-
public constructor() {
|
|
418
|
-
super(4);
|
|
419
|
-
|
|
420
|
-
this[0] = 1;
|
|
421
|
-
this[3] = 1;
|
|
422
|
-
|
|
423
|
-
this.width = 2;
|
|
424
|
-
this.height = 2;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/** The value in the first column and first row. */
|
|
428
|
-
public 0: number;
|
|
429
|
-
|
|
430
|
-
/** The value in the first column and second row. */
|
|
431
|
-
public 1: number;
|
|
432
|
-
|
|
433
|
-
/** The value in the second column and first row. */
|
|
434
|
-
public 2: number;
|
|
435
|
-
|
|
436
|
-
/** The value in the second column and second row. */
|
|
437
|
-
public 3: number;
|
|
438
|
-
|
|
439
|
-
/** The number of columns in this matrix. */
|
|
440
|
-
public readonly width: 2;
|
|
441
|
-
|
|
442
|
-
/** The number of rows in this matrix. */
|
|
443
|
-
public readonly height: 2;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Determine whether or not this matrix is roughly equivalent to another.
|
|
447
|
-
* @param matrix - The other matrix.
|
|
448
|
-
* @returns Whether the matrices are equivalent.
|
|
449
|
-
*/
|
|
450
|
-
public equals(matrix: Matrix2Like): boolean {
|
|
451
|
-
return equals(this, matrix);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Determine whether or not this matrix is exactly equivalent to another.
|
|
456
|
-
* @param matrix - The other matrix.
|
|
457
|
-
* @returns Whether the matrices are equivalent.
|
|
458
|
-
*/
|
|
459
|
-
public exactEquals(matrix: Matrix2Like): boolean {
|
|
460
|
-
return exactEquals(this, matrix);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
470
|
/**
|
|
464
471
|
* Add another matrix to this one.
|
|
465
472
|
* @param matrix - The other matrix.
|
|
@@ -497,11 +504,39 @@ export default class Matrix2
|
|
|
497
504
|
}
|
|
498
505
|
|
|
499
506
|
/**
|
|
500
|
-
*
|
|
501
|
-
* @
|
|
507
|
+
* Determine whether or not this matrix is roughly equivalent to another.
|
|
508
|
+
* @param matrix - The other matrix.
|
|
509
|
+
* @returns Whether the matrices are equivalent.
|
|
502
510
|
*/
|
|
503
|
-
public
|
|
504
|
-
return
|
|
511
|
+
public equals(matrix: Matrix2Like): boolean {
|
|
512
|
+
return equals(this, matrix);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Determine whether or not this matrix is exactly equivalent to another.
|
|
517
|
+
* @param matrix - The other matrix.
|
|
518
|
+
* @returns Whether the matrices are equivalent.
|
|
519
|
+
*/
|
|
520
|
+
public exactEquals(matrix: Matrix2Like): boolean {
|
|
521
|
+
return exactEquals(this, matrix);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Reset this matrix to identity.
|
|
526
|
+
* @returns This matrix.
|
|
527
|
+
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
528
|
+
*/
|
|
529
|
+
public identity(): this {
|
|
530
|
+
return identity(this);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Invert this matrix.
|
|
535
|
+
* @returns The inverted matrix.
|
|
536
|
+
* @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
|
|
537
|
+
*/
|
|
538
|
+
public invert(): Matrix2 {
|
|
539
|
+
return invert(this, new Matrix2());
|
|
505
540
|
}
|
|
506
541
|
|
|
507
542
|
/**
|
|
@@ -537,51 +572,6 @@ export default class Matrix2
|
|
|
537
572
|
return multiplyScalarAndAdd(this, matrix, scalar, new Matrix2());
|
|
538
573
|
}
|
|
539
574
|
|
|
540
|
-
/**
|
|
541
|
-
* Subtract another matrix from this one.
|
|
542
|
-
* @param matrix - The other matrix.
|
|
543
|
-
* @returns The difference between the matrices.
|
|
544
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
545
|
-
*/
|
|
546
|
-
public subtract(matrix: Matrix2Like): Matrix2 {
|
|
547
|
-
return subtract(this, matrix, new Matrix2());
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Transpose this matrix.
|
|
552
|
-
* @returns The transpose of this matrix.
|
|
553
|
-
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
554
|
-
*/
|
|
555
|
-
public transpose(): Matrix2 {
|
|
556
|
-
return transpose(this, new Matrix2());
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Get the determinant of this matrix.
|
|
561
|
-
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
562
|
-
*/
|
|
563
|
-
public get determinant(): number {
|
|
564
|
-
return determinant(this);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Reset this matrix to identity.
|
|
569
|
-
* @returns This matrix.
|
|
570
|
-
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
571
|
-
*/
|
|
572
|
-
public identity(): this {
|
|
573
|
-
return identity(this);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Invert this matrix.
|
|
578
|
-
* @returns The inverted matrix.
|
|
579
|
-
* @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
|
|
580
|
-
*/
|
|
581
|
-
public invert(): Matrix2 {
|
|
582
|
-
return invert(this, new Matrix2());
|
|
583
|
-
}
|
|
584
|
-
|
|
585
575
|
/**
|
|
586
576
|
* Rotate this matrix by the given angle.
|
|
587
577
|
* @param r - The angle in radians.
|
|
@@ -601,4 +591,23 @@ export default class Matrix2
|
|
|
601
591
|
public scale(vector: Vector2Like): Matrix2 {
|
|
602
592
|
return scale(this, vector, new Matrix2());
|
|
603
593
|
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Subtract another matrix from this one.
|
|
597
|
+
* @param matrix - The other matrix.
|
|
598
|
+
* @returns The difference between the matrices.
|
|
599
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
600
|
+
*/
|
|
601
|
+
public subtract(matrix: Matrix2Like): Matrix2 {
|
|
602
|
+
return subtract(this, matrix, new Matrix2());
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Transpose this matrix.
|
|
607
|
+
* @returns The transpose of this matrix.
|
|
608
|
+
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
609
|
+
*/
|
|
610
|
+
public transpose(): Matrix2 {
|
|
611
|
+
return transpose(this, new Matrix2());
|
|
612
|
+
}
|
|
604
613
|
}
|