@lakuna/umath 1.5.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 +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +131 -154
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +188 -203
- 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 +74 -88
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +114 -124
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +118 -139
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +169 -201
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +217 -257
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +310 -374
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +120 -151
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +187 -204
- 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 +63 -89
- 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 +165 -0
- package/dist/linalg/SlowVector.d.ts.map +1 -0
- package/dist/linalg/SlowVector.js +369 -0
- package/dist/linalg/SlowVector.js.map +1 -0
- package/dist/linalg/SquareMatrix.d.ts +8 -8
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector.d.ts +84 -84
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +115 -137
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +164 -188
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +141 -167
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +200 -237
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +111 -131
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +163 -187
- 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/MatrixSizeError.d.ts +1 -1
- package/dist/utility/MatrixSizeError.d.ts.map +1 -1
- package/dist/utility/MatrixSizeError.js +1 -1
- package/dist/utility/MatrixSizeError.js.map +1 -1
- package/dist/utility/VectorSizeError.d.ts +12 -0
- package/dist/utility/VectorSizeError.d.ts.map +1 -0
- package/dist/utility/VectorSizeError.js +15 -0
- package/dist/utility/VectorSizeError.js.map +1 -0
- package/dist/utility/createAxisAngleLike.d.ts +10 -0
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
- package/dist/utility/createAxisAngleLike.js +10 -0
- package/dist/utility/createAxisAngleLike.js.map +1 -0
- package/package.json +11 -11
- package/src/algorithms/greatestCommonDivisor.ts +19 -7
- package/src/index.ts +24 -13
- package/src/linalg/DualQuaternion.ts +224 -292
- package/src/linalg/Matrix.ts +28 -28
- package/src/linalg/Matrix2.ts +138 -180
- package/src/linalg/Matrix3.ts +211 -286
- package/src/linalg/Matrix4.ts +466 -584
- package/src/linalg/Quaternion.ts +221 -294
- package/src/linalg/SlowMatrix.ts +97 -95
- package/src/linalg/SlowSquareMatrix.ts +19 -18
- package/src/linalg/SlowVector.ts +450 -0
- package/src/linalg/SquareMatrix.ts +9 -9
- package/src/linalg/Vector.ts +90 -90
- package/src/linalg/Vector2.ts +181 -266
- package/src/linalg/Vector3.ts +230 -342
- package/src/linalg/Vector4.ts +183 -257
- package/src/types/AxisAngle.ts +3 -3
- package/src/types/FieldOfView.ts +3 -3
- package/src/utility/BigNumber.ts +63 -41
- package/src/utility/MatrixSizeError.ts +1 -1
- package/src/utility/VectorSizeError.ts +14 -0
- package/src/utility/createAxisAngleLike.ts +14 -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,53 +376,44 @@ 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
|
{
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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;
|
|
389
402
|
|
|
390
403
|
/**
|
|
391
|
-
*
|
|
392
|
-
* @
|
|
393
|
-
* @param out - The matrix to store the result in.
|
|
394
|
-
* @returns The transformation matrix.
|
|
395
|
-
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
404
|
+
* Get the determinant of this matrix.
|
|
405
|
+
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
396
406
|
*/
|
|
397
|
-
public
|
|
398
|
-
|
|
399
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
400
|
-
): T {
|
|
401
|
-
return fromScaling(vector, out);
|
|
407
|
+
public get determinant(): number {
|
|
408
|
+
return determinant(this);
|
|
402
409
|
}
|
|
403
410
|
|
|
404
411
|
/**
|
|
405
|
-
*
|
|
406
|
-
* @
|
|
407
|
-
* @param c0r1 - The value in the first column and second row.
|
|
408
|
-
* @param c1r0 - The value in the second column and first row.
|
|
409
|
-
* @param c1r1 - The value in the second column and second row.
|
|
410
|
-
* @param out - The matrix to store the result in.
|
|
411
|
-
* @returns The matrix.
|
|
412
|
+
* Get the Frobenius norm of this matrix.
|
|
413
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
412
414
|
*/
|
|
413
|
-
public
|
|
414
|
-
|
|
415
|
-
c0r1: number,
|
|
416
|
-
c1r0: number,
|
|
417
|
-
c1r1: number,
|
|
418
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
419
|
-
): T {
|
|
420
|
-
return fromValues(c0r0, c0r1, c1r0, c1r1, out);
|
|
415
|
+
public get frob(): number {
|
|
416
|
+
return frob(this);
|
|
421
417
|
}
|
|
422
418
|
|
|
423
419
|
/**
|
|
@@ -434,77 +430,68 @@ export default class Matrix2
|
|
|
434
430
|
this.height = 2;
|
|
435
431
|
}
|
|
436
432
|
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
/** The value in the second column and second row. */
|
|
447
|
-
public 3: number;
|
|
448
|
-
|
|
449
|
-
/** The number of columns in this matrix. */
|
|
450
|
-
public readonly width: 2;
|
|
451
|
-
|
|
452
|
-
/** The number of rows in this matrix. */
|
|
453
|
-
public readonly height: 2;
|
|
433
|
+
/**
|
|
434
|
+
* Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
|
|
435
|
+
* @param r - The angle in radians.
|
|
436
|
+
* @returns The transformation matrix.
|
|
437
|
+
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
438
|
+
*/
|
|
439
|
+
public static fromRotation(r: number): Matrix2 {
|
|
440
|
+
return fromRotation(r, new Matrix2());
|
|
441
|
+
}
|
|
454
442
|
|
|
455
443
|
/**
|
|
456
|
-
*
|
|
457
|
-
* @param
|
|
458
|
-
* @returns
|
|
444
|
+
* Create a transformation matrix that represents a scaling by the given vector.
|
|
445
|
+
* @param vector - The scaling vector.
|
|
446
|
+
* @returns The transformation matrix.
|
|
447
|
+
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
459
448
|
*/
|
|
460
|
-
public
|
|
461
|
-
return
|
|
449
|
+
public static fromScaling(vector: Vector2Like): Matrix2 {
|
|
450
|
+
return fromScaling(vector, new Matrix2());
|
|
462
451
|
}
|
|
463
452
|
|
|
464
453
|
/**
|
|
465
|
-
*
|
|
466
|
-
* @param
|
|
467
|
-
* @
|
|
454
|
+
* Create a two-by-two matrix with the given values.
|
|
455
|
+
* @param c0r0 - The value in the first column and first row.
|
|
456
|
+
* @param c0r1 - The value in the first column and second row.
|
|
457
|
+
* @param c1r0 - The value in the second column and first row.
|
|
458
|
+
* @param c1r1 - The value in the second column and second row.
|
|
459
|
+
* @returns The matrix.
|
|
468
460
|
*/
|
|
469
|
-
public
|
|
470
|
-
|
|
461
|
+
public static fromValues(
|
|
462
|
+
c0r0: number,
|
|
463
|
+
c0r1: number,
|
|
464
|
+
c1r0: number,
|
|
465
|
+
c1r1: number
|
|
466
|
+
): Matrix2 {
|
|
467
|
+
return fromValues(c0r0, c0r1, c1r0, c1r1, new Matrix2());
|
|
471
468
|
}
|
|
472
469
|
|
|
473
470
|
/**
|
|
474
471
|
* Add another matrix to this one.
|
|
475
472
|
* @param matrix - The other matrix.
|
|
476
|
-
* @param out - The matrix to store the result in.
|
|
477
473
|
* @returns The sum of the matrices.
|
|
478
474
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
479
475
|
*/
|
|
480
|
-
public add
|
|
481
|
-
matrix
|
|
482
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
483
|
-
): T {
|
|
484
|
-
return add(this, matrix, out);
|
|
476
|
+
public add(matrix: Matrix2Like): Matrix2 {
|
|
477
|
+
return add(this, matrix, new Matrix2());
|
|
485
478
|
}
|
|
486
479
|
|
|
487
480
|
/**
|
|
488
481
|
* Calculate the adjugate of this matrix.
|
|
489
|
-
* @param out - The matrix to store the result in.
|
|
490
482
|
* @returns The adjugate of this matrix.
|
|
491
483
|
* @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
|
|
492
484
|
*/
|
|
493
|
-
public adjoint
|
|
494
|
-
|
|
495
|
-
): T {
|
|
496
|
-
return adjoint(this, out);
|
|
485
|
+
public adjoint(): Matrix2 {
|
|
486
|
+
return adjoint(this, new Matrix2());
|
|
497
487
|
}
|
|
498
488
|
|
|
499
489
|
/**
|
|
500
490
|
* Copy the values from this matrix to another one.
|
|
501
|
-
* @param out - The matrix to store the result in.
|
|
502
491
|
* @returns The copy.
|
|
503
492
|
*/
|
|
504
|
-
public clone
|
|
505
|
-
|
|
506
|
-
): T {
|
|
507
|
-
return copy(this, out);
|
|
493
|
+
public clone(): Matrix2 {
|
|
494
|
+
return copy(this, new Matrix2());
|
|
508
495
|
}
|
|
509
496
|
|
|
510
497
|
/**
|
|
@@ -517,139 +504,110 @@ export default class Matrix2
|
|
|
517
504
|
}
|
|
518
505
|
|
|
519
506
|
/**
|
|
520
|
-
*
|
|
521
|
-
* @
|
|
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.
|
|
522
510
|
*/
|
|
523
|
-
public
|
|
524
|
-
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());
|
|
525
540
|
}
|
|
526
541
|
|
|
527
542
|
/**
|
|
528
543
|
* Multiply this matrix by another.
|
|
529
544
|
* @param matrix - The other matrix.
|
|
530
|
-
* @param out - The matrix to store the result in.
|
|
531
545
|
* @returns The product of the matrices.
|
|
532
546
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
533
547
|
* @public
|
|
534
548
|
*/
|
|
535
|
-
public multiply
|
|
536
|
-
matrix
|
|
537
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
538
|
-
): T {
|
|
539
|
-
return multiply(this, matrix, out);
|
|
549
|
+
public multiply(matrix: Matrix2Like): Matrix2 {
|
|
550
|
+
return multiply(this, matrix, new Matrix2());
|
|
540
551
|
}
|
|
541
552
|
|
|
542
553
|
/**
|
|
543
554
|
* Multiply this matrix by a scalar value.
|
|
544
555
|
* @param scalar - The scalar value.
|
|
545
|
-
* @param out - The matrix to store the result in.
|
|
546
556
|
* @returns The product of the matrix and the scalar value.
|
|
547
557
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
548
558
|
*/
|
|
549
|
-
public multiplyScalar
|
|
550
|
-
scalar
|
|
551
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
552
|
-
): T {
|
|
553
|
-
return multiplyScalar(this, scalar, out);
|
|
559
|
+
public multiplyScalar(scalar: number): Matrix2 {
|
|
560
|
+
return multiplyScalar(this, scalar, new Matrix2());
|
|
554
561
|
}
|
|
555
562
|
|
|
556
563
|
/**
|
|
557
564
|
* Add this matrix to another after multiplying the other by a scalar.
|
|
558
565
|
* @param matrix - The other matrix.
|
|
559
566
|
* @param scalar - The scalar.
|
|
560
|
-
* @param out - The matrix to store the result in.
|
|
561
567
|
* @returns The sum.
|
|
562
568
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
563
569
|
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
564
570
|
*/
|
|
565
|
-
public multiplyScalarAndAdd
|
|
566
|
-
matrix
|
|
567
|
-
scalar: number,
|
|
568
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
569
|
-
): T {
|
|
570
|
-
return multiplyScalarAndAdd(this, matrix, scalar, out);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* Subtract another matrix from this one.
|
|
575
|
-
* @param matrix - The other matrix.
|
|
576
|
-
* @param out - The matrix to store the result in.
|
|
577
|
-
* @returns The difference between the matrices.
|
|
578
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
579
|
-
*/
|
|
580
|
-
public subtract<T extends Matrix2Like = Matrix2>(
|
|
581
|
-
matrix: Matrix2Like,
|
|
582
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
583
|
-
): T {
|
|
584
|
-
return subtract(this, matrix, out);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Transpose this matrix.
|
|
589
|
-
* @param out - The matrix to store the result in.
|
|
590
|
-
* @returns The transpose of this matrix.
|
|
591
|
-
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
592
|
-
*/
|
|
593
|
-
public transpose<T extends Matrix2Like = Matrix2>(
|
|
594
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
595
|
-
): T {
|
|
596
|
-
return transpose(this, out);
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Get the determinant of this matrix.
|
|
601
|
-
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
602
|
-
*/
|
|
603
|
-
public get determinant(): number {
|
|
604
|
-
return determinant(this);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Reset this matrix to identity.
|
|
609
|
-
* @returns This matrix.
|
|
610
|
-
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
611
|
-
*/
|
|
612
|
-
public identity(): this {
|
|
613
|
-
return identity(this);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Invert this matrix.
|
|
618
|
-
* @param out - The matrix to store the result in.
|
|
619
|
-
* @returns The inverted matrix.
|
|
620
|
-
* @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
|
|
621
|
-
*/
|
|
622
|
-
public invert<T extends Matrix2Like = Matrix2>(
|
|
623
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
624
|
-
): T {
|
|
625
|
-
return invert(this, out);
|
|
571
|
+
public multiplyScalarAndAdd(matrix: Matrix2Like, scalar: number): Matrix2 {
|
|
572
|
+
return multiplyScalarAndAdd(this, matrix, scalar, new Matrix2());
|
|
626
573
|
}
|
|
627
574
|
|
|
628
575
|
/**
|
|
629
576
|
* Rotate this matrix by the given angle.
|
|
630
577
|
* @param r - The angle in radians.
|
|
631
|
-
* @param out - The matrix to store the result in.
|
|
632
578
|
* @returns The rotated matrix.
|
|
633
579
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
634
580
|
*/
|
|
635
|
-
public rotate
|
|
636
|
-
r
|
|
637
|
-
out: T = new Matrix2() as Matrix2 & T
|
|
638
|
-
): T {
|
|
639
|
-
return rotate(this, r, out);
|
|
581
|
+
public rotate(r: number): Matrix2 {
|
|
582
|
+
return rotate(this, r, new Matrix2());
|
|
640
583
|
}
|
|
641
584
|
|
|
642
585
|
/**
|
|
643
586
|
* Scale this matrix by the given vector.
|
|
644
587
|
* @param vector - The scaling vector.
|
|
645
|
-
* @param out - The matrix to store the result in.
|
|
646
588
|
* @returns The scaled matrix.
|
|
647
589
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
648
590
|
*/
|
|
649
|
-
public scale
|
|
650
|
-
vector
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
591
|
+
public scale(vector: Vector2Like): Matrix2 {
|
|
592
|
+
return scale(this, vector, new Matrix2());
|
|
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());
|
|
654
612
|
}
|
|
655
613
|
}
|