@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/Matrix4.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import Quaternion, {
|
|
2
|
-
type QuaternionLike,
|
|
3
|
-
fromValues as quaternionFromValues
|
|
4
|
-
} from "./Quaternion.js";
|
|
5
|
-
import Vector3, {
|
|
6
|
-
type Vector3Like,
|
|
7
|
-
createVector3Like,
|
|
8
|
-
fromValues as vector3FromValues
|
|
9
|
-
} from "./Vector3.js";
|
|
10
|
-
import type { DualQuaternionLike } from "./DualQuaternion.js";
|
|
11
1
|
import type FieldOfView from "../types/FieldOfView.js";
|
|
12
|
-
import
|
|
2
|
+
import type { DualQuaternionLike } from "./DualQuaternion.js";
|
|
13
3
|
import type { MatrixLike } from "./Matrix.js";
|
|
14
|
-
import SingularMatrixError from "../utility/SingularMatrixError.js";
|
|
15
4
|
import type SquareMatrix from "./SquareMatrix.js";
|
|
5
|
+
|
|
16
6
|
import approx from "../algorithms/approx.js";
|
|
17
7
|
import approxRelative from "../algorithms/approxRelative.js";
|
|
18
8
|
import degreesToRadians from "../algorithms/degreesToRadians.js";
|
|
19
9
|
import epsilon from "../utility/epsilon.js";
|
|
10
|
+
import MagnitudeError from "../utility/MagnitudeError.js";
|
|
11
|
+
import SingularMatrixError from "../utility/SingularMatrixError.js";
|
|
12
|
+
import Quaternion, {
|
|
13
|
+
fromValues as quaternionFromValues,
|
|
14
|
+
type QuaternionLike
|
|
15
|
+
} from "./Quaternion.js";
|
|
16
|
+
import Vector3, {
|
|
17
|
+
createVector3Like,
|
|
18
|
+
fromValues as vector3FromValues,
|
|
19
|
+
type Vector3Like
|
|
20
|
+
} from "./Vector3.js";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Numbers arranged into four columns and four rows.
|
|
@@ -25,51 +26,67 @@ import epsilon from "../utility/epsilon.js";
|
|
|
25
26
|
*/
|
|
26
27
|
export interface Matrix4Like extends MatrixLike {
|
|
27
28
|
/** The value in the first column and first row. */
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28
30
|
0: number;
|
|
29
31
|
|
|
30
32
|
/** The value in the first column and second row. */
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
31
34
|
1: number;
|
|
32
35
|
|
|
33
36
|
/** The value in the first column and third row. */
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
34
38
|
2: number;
|
|
35
39
|
|
|
36
40
|
/** The value in the first column and fourth row. */
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
37
42
|
3: number;
|
|
38
43
|
|
|
39
44
|
/** The value in the second column and first row. */
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
46
|
4: number;
|
|
41
47
|
|
|
42
48
|
/** The value in the second column and second row. */
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
43
50
|
5: number;
|
|
44
51
|
|
|
45
52
|
/** The value in the second column and third row. */
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
46
54
|
6: number;
|
|
47
55
|
|
|
48
56
|
/** The value in the second column and fourth row. */
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
49
58
|
7: number;
|
|
50
59
|
|
|
51
60
|
/** The value in the third column and first row. */
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
52
62
|
8: number;
|
|
53
63
|
|
|
54
64
|
/** The value in the third column and second row. */
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
55
66
|
9: number;
|
|
56
67
|
|
|
57
68
|
/** The value in the third column and third row. */
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
58
70
|
10: number;
|
|
59
71
|
|
|
60
72
|
/** The value in the third column and fourth row. */
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
61
74
|
11: number;
|
|
62
75
|
|
|
63
76
|
/** The value in the fourth column and first row. */
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
64
78
|
12: number;
|
|
65
79
|
|
|
66
80
|
/** The value in the fourth column and second row. */
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
67
82
|
13: number;
|
|
68
83
|
|
|
69
84
|
/** The value in the fourth column and third row. */
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
70
86
|
14: number;
|
|
71
87
|
|
|
72
88
|
/** The value in the fourth column and fourth row. */
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
73
90
|
15: number;
|
|
74
91
|
}
|
|
75
92
|
|
|
@@ -78,9 +95,9 @@ export interface Matrix4Like extends MatrixLike {
|
|
|
78
95
|
* @returns A four-by-four matrix-like object.
|
|
79
96
|
* @public
|
|
80
97
|
*/
|
|
81
|
-
export const createMatrix4Like = (): Float32Array & Matrix4Like =>
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
export const createMatrix4Like = (): Float32Array & Matrix4Like =>
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
100
|
+
new Float32Array(16) as Float32Array & Matrix4Like;
|
|
84
101
|
|
|
85
102
|
/**
|
|
86
103
|
* Create a four-by-four matrix with the given values.
|
|
@@ -277,6 +294,7 @@ export const fromRotation = <T extends Matrix4Like>(
|
|
|
277
294
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
278
295
|
* @public
|
|
279
296
|
*/
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
280
298
|
export const fromXRotation = <T extends Matrix4Like>(
|
|
281
299
|
radians: number,
|
|
282
300
|
out: T
|
|
@@ -295,6 +313,7 @@ export const fromXRotation = <T extends Matrix4Like>(
|
|
|
295
313
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
296
314
|
* @public
|
|
297
315
|
*/
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
298
317
|
export const fromYRotation = <T extends Matrix4Like>(
|
|
299
318
|
radians: number,
|
|
300
319
|
out: T
|
|
@@ -313,6 +332,7 @@ export const fromYRotation = <T extends Matrix4Like>(
|
|
|
313
332
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
314
333
|
* @public
|
|
315
334
|
*/
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
316
336
|
export const fromZRotation = <T extends Matrix4Like>(
|
|
317
337
|
radians: number,
|
|
318
338
|
out: T
|
|
@@ -2080,67 +2100,168 @@ export const getRotation = <T extends QuaternionLike>(
|
|
|
2080
2100
|
*/
|
|
2081
2101
|
export default class Matrix4
|
|
2082
2102
|
extends Float32Array
|
|
2083
|
-
implements
|
|
2103
|
+
implements Matrix4Like, SquareMatrix
|
|
2084
2104
|
{
|
|
2105
|
+
/** The value in the first column and first row. */
|
|
2106
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2107
|
+
public 0: number;
|
|
2108
|
+
|
|
2109
|
+
/** The value in the first column and second row. */
|
|
2110
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2111
|
+
public 1: number;
|
|
2112
|
+
|
|
2113
|
+
/** The value in the first column and third row. */
|
|
2114
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2115
|
+
public 2: number;
|
|
2116
|
+
|
|
2117
|
+
/** The value in the first column and fourth row. */
|
|
2118
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2119
|
+
public 3: number;
|
|
2120
|
+
|
|
2121
|
+
/** The value in the second column and first row. */
|
|
2122
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2123
|
+
public 4: number;
|
|
2124
|
+
|
|
2125
|
+
/** The value in the second column and second row. */
|
|
2126
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2127
|
+
public 5: number;
|
|
2128
|
+
|
|
2129
|
+
/** The value in the second column and third row. */
|
|
2130
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2131
|
+
public 6: number;
|
|
2132
|
+
|
|
2133
|
+
/** The value in the second column and fourth row. */
|
|
2134
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2135
|
+
public 7: number;
|
|
2136
|
+
|
|
2137
|
+
/** The value in the third column and first row. */
|
|
2138
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2139
|
+
public 8: number;
|
|
2140
|
+
|
|
2141
|
+
/** The value in the third column and second row. */
|
|
2142
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2143
|
+
public 9: number;
|
|
2144
|
+
|
|
2145
|
+
/** The value in the third column and third row. */
|
|
2146
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2147
|
+
public 10: number;
|
|
2148
|
+
|
|
2149
|
+
/** The value in the third column and fourth row. */
|
|
2150
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2151
|
+
public 11: number;
|
|
2152
|
+
|
|
2153
|
+
/** The value in the fourth column and first row. */
|
|
2154
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2155
|
+
public 12: number;
|
|
2156
|
+
|
|
2157
|
+
/** The value in the fourth column and second row. */
|
|
2158
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2159
|
+
public 13: number;
|
|
2160
|
+
|
|
2161
|
+
/** The value in the fourth column and third row. */
|
|
2162
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2163
|
+
public 14: number;
|
|
2164
|
+
|
|
2165
|
+
/** The value in the fourth column and fourth row. */
|
|
2166
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2167
|
+
public 15: number;
|
|
2168
|
+
|
|
2169
|
+
/** The number of rows in this matrix. */
|
|
2170
|
+
public readonly height: 4;
|
|
2171
|
+
|
|
2172
|
+
/** The number of columns in this matrix. */
|
|
2173
|
+
public readonly width: 4;
|
|
2174
|
+
|
|
2085
2175
|
/**
|
|
2086
|
-
*
|
|
2087
|
-
* @
|
|
2088
|
-
|
|
2176
|
+
* Get the determinant of this matrix.
|
|
2177
|
+
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
2178
|
+
*/
|
|
2179
|
+
public get determinant(): number {
|
|
2180
|
+
return determinant(this);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* Get the Frobenius norm of this matrix.
|
|
2185
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
2186
|
+
*/
|
|
2187
|
+
public get frob(): number {
|
|
2188
|
+
return frob(this);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
/**
|
|
2192
|
+
* Get the scaling vector component of this transformation matrix.
|
|
2193
|
+
* @returns The rotation.
|
|
2194
|
+
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2195
|
+
*/
|
|
2196
|
+
public get rotation(): Quaternion {
|
|
2197
|
+
return getRotation(this, new Quaternion());
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Get the scaling vector component of this transformation matrix.
|
|
2202
|
+
* @returns The scaling.
|
|
2089
2203
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2090
2204
|
*/
|
|
2091
|
-
public
|
|
2092
|
-
return
|
|
2205
|
+
public get scaling(): Vector3 {
|
|
2206
|
+
return getScaling(this, new Vector3());
|
|
2093
2207
|
}
|
|
2094
2208
|
|
|
2095
2209
|
/**
|
|
2096
|
-
*
|
|
2097
|
-
* @param vector - The scaling vector.
|
|
2098
|
-
* @returns The transformation matrix.
|
|
2210
|
+
* The translation vector component of this transformation matrix.
|
|
2099
2211
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2100
2212
|
*/
|
|
2101
|
-
public
|
|
2102
|
-
return
|
|
2213
|
+
public get translation(): Vector3 {
|
|
2214
|
+
return getTranslation(this, new Vector3());
|
|
2103
2215
|
}
|
|
2104
2216
|
|
|
2105
2217
|
/**
|
|
2106
|
-
* Create a
|
|
2107
|
-
* @
|
|
2108
|
-
* @param axis - The axis to rotate around.
|
|
2109
|
-
* @returns The transformation matrix.
|
|
2110
|
-
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2218
|
+
* Create a four-by-four identity matrix.
|
|
2219
|
+
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
2111
2220
|
*/
|
|
2112
|
-
public
|
|
2113
|
-
|
|
2221
|
+
public constructor() {
|
|
2222
|
+
super(16);
|
|
2223
|
+
|
|
2224
|
+
this[0] = 1;
|
|
2225
|
+
this[5] = 1;
|
|
2226
|
+
this[10] = 1;
|
|
2227
|
+
this[15] = 1;
|
|
2228
|
+
|
|
2229
|
+
this.width = 4;
|
|
2230
|
+
this.height = 4;
|
|
2114
2231
|
}
|
|
2115
2232
|
|
|
2116
2233
|
/**
|
|
2117
|
-
* Create a transformation matrix
|
|
2118
|
-
* @param
|
|
2234
|
+
* Create a transformation matrix from a dual quaternion.
|
|
2235
|
+
* @param quaternion - The dual quaternion.
|
|
2119
2236
|
* @returns The transformation matrix.
|
|
2237
|
+
* @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
|
|
2120
2238
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2239
|
+
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2121
2240
|
*/
|
|
2122
|
-
public static
|
|
2123
|
-
return
|
|
2241
|
+
public static fromDualQuaternion(quaternion: DualQuaternionLike): Matrix4 {
|
|
2242
|
+
return fromDualQuaternion(quaternion, new Matrix4());
|
|
2124
2243
|
}
|
|
2125
2244
|
|
|
2126
2245
|
/**
|
|
2127
|
-
* Create a transformation matrix
|
|
2128
|
-
* @param
|
|
2246
|
+
* Create a transformation matrix from a quaternion.
|
|
2247
|
+
* @param quaternion - The quaternion.
|
|
2129
2248
|
* @returns The transformation matrix.
|
|
2130
2249
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2250
|
+
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2131
2251
|
*/
|
|
2132
|
-
public static
|
|
2133
|
-
return
|
|
2252
|
+
public static fromQuaternion(quaternion: QuaternionLike): Matrix4 {
|
|
2253
|
+
return fromQuaternion(quaternion, new Matrix4());
|
|
2134
2254
|
}
|
|
2135
2255
|
|
|
2136
2256
|
/**
|
|
2137
2257
|
* Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
|
|
2138
2258
|
* @param r - The angle in radians.
|
|
2259
|
+
* @param axis - The axis to rotate around.
|
|
2139
2260
|
* @returns The transformation matrix.
|
|
2140
2261
|
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2141
2262
|
*/
|
|
2142
|
-
public static
|
|
2143
|
-
return
|
|
2263
|
+
public static fromRotation(r: number, axis: Vector3Like): Matrix4 {
|
|
2264
|
+
return fromRotation(r, axis, new Matrix4());
|
|
2144
2265
|
}
|
|
2145
2266
|
|
|
2146
2267
|
/**
|
|
@@ -2206,105 +2327,154 @@ export default class Matrix4
|
|
|
2206
2327
|
}
|
|
2207
2328
|
|
|
2208
2329
|
/**
|
|
2209
|
-
* Create a transformation matrix
|
|
2210
|
-
* @param
|
|
2330
|
+
* Create a transformation matrix that represents a scaling by the given vector.
|
|
2331
|
+
* @param vector - The scaling vector.
|
|
2211
2332
|
* @returns The transformation matrix.
|
|
2212
|
-
* @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
|
|
2213
|
-
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2214
2333
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2215
2334
|
*/
|
|
2216
|
-
public static
|
|
2217
|
-
return
|
|
2335
|
+
public static fromScaling(vector: Vector3Like): Matrix4 {
|
|
2336
|
+
return fromScaling(vector, new Matrix4());
|
|
2218
2337
|
}
|
|
2219
2338
|
|
|
2220
2339
|
/**
|
|
2221
|
-
* Create a transformation matrix
|
|
2222
|
-
* @param
|
|
2340
|
+
* Create a transformation matrix that represents a translation by the given vector.
|
|
2341
|
+
* @param vector - The translation vector.
|
|
2223
2342
|
* @returns The transformation matrix.
|
|
2224
|
-
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2225
2343
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2226
2344
|
*/
|
|
2227
|
-
public static
|
|
2228
|
-
return
|
|
2345
|
+
public static fromTranslation(vector: Vector3Like): Matrix4 {
|
|
2346
|
+
return fromTranslation(vector, new Matrix4());
|
|
2229
2347
|
}
|
|
2230
2348
|
|
|
2231
2349
|
/**
|
|
2232
|
-
*
|
|
2233
|
-
* @param
|
|
2234
|
-
* @param
|
|
2235
|
-
* @param
|
|
2236
|
-
* @param
|
|
2237
|
-
* @param
|
|
2238
|
-
* @param
|
|
2239
|
-
* @
|
|
2240
|
-
* @
|
|
2241
|
-
* @
|
|
2350
|
+
* Create a two-by-two matrix with the given values.
|
|
2351
|
+
* @param c0r0 - The value in the first column and first row.
|
|
2352
|
+
* @param c0r1 - The value in the first column and second row.
|
|
2353
|
+
* @param c0r2 - The value in the first column and third row.
|
|
2354
|
+
* @param c0r3 - The value in the first column and fourth row.
|
|
2355
|
+
* @param c1r0 - The value in the second column and first row.
|
|
2356
|
+
* @param c1r1 - The value in the second column and second row.
|
|
2357
|
+
* @param c1r2 - The value in the second column and third row.
|
|
2358
|
+
* @param c1r3 - The value in the second column and fourth row.
|
|
2359
|
+
* @param c2r0 - The value in the third column and first row.
|
|
2360
|
+
* @param c2r1 - The value in the third column and second row.
|
|
2361
|
+
* @param c2r2 - The value in the third column and third row.
|
|
2362
|
+
* @param c2r3 - The value in the third column and fourth row.
|
|
2363
|
+
* @param c3r0 - The value in the fourth column and first row.
|
|
2364
|
+
* @param c3r1 - The value in the fourth column and second row.
|
|
2365
|
+
* @param c3r2 - The value in the fourth column and third row.
|
|
2366
|
+
* @param c3r3 - The value in the fourth column and fourth row.
|
|
2367
|
+
* @returns The matrix.
|
|
2242
2368
|
*/
|
|
2243
|
-
public static
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2369
|
+
public static fromValues(
|
|
2370
|
+
c0r0: number,
|
|
2371
|
+
c0r1: number,
|
|
2372
|
+
c0r2: number,
|
|
2373
|
+
c0r3: number,
|
|
2374
|
+
c1r0: number,
|
|
2375
|
+
c1r1: number,
|
|
2376
|
+
c1r2: number,
|
|
2377
|
+
c1r3: number,
|
|
2378
|
+
c2r0: number,
|
|
2379
|
+
c2r1: number,
|
|
2380
|
+
c2r2: number,
|
|
2381
|
+
c2r3: number,
|
|
2382
|
+
c3r0: number,
|
|
2383
|
+
c3r1: number,
|
|
2384
|
+
c3r2: number,
|
|
2385
|
+
c3r3: number
|
|
2250
2386
|
): Matrix4 {
|
|
2251
|
-
return
|
|
2387
|
+
return fromValues(
|
|
2388
|
+
c0r0,
|
|
2389
|
+
c0r1,
|
|
2390
|
+
c0r2,
|
|
2391
|
+
c0r3,
|
|
2392
|
+
c1r0,
|
|
2393
|
+
c1r1,
|
|
2394
|
+
c1r2,
|
|
2395
|
+
c1r3,
|
|
2396
|
+
c2r0,
|
|
2397
|
+
c2r1,
|
|
2398
|
+
c2r2,
|
|
2399
|
+
c2r3,
|
|
2400
|
+
c3r0,
|
|
2401
|
+
c3r1,
|
|
2402
|
+
c3r2,
|
|
2403
|
+
c3r3,
|
|
2404
|
+
new Matrix4()
|
|
2405
|
+
);
|
|
2252
2406
|
}
|
|
2253
2407
|
|
|
2254
2408
|
/**
|
|
2255
|
-
* Create a
|
|
2256
|
-
* @param
|
|
2257
|
-
* @
|
|
2258
|
-
* @
|
|
2259
|
-
* @param far - The far bound of the frustum.
|
|
2260
|
-
* @returns The perspective projection matrix.
|
|
2261
|
-
* @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
|
|
2262
|
-
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2409
|
+
* Create a transformation matrix that represents a rotation by the given angle around the X-axis.
|
|
2410
|
+
* @param r - The angle in radians.
|
|
2411
|
+
* @returns The transformation matrix.
|
|
2412
|
+
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2263
2413
|
*/
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
near: number,
|
|
2268
|
-
far: number
|
|
2269
|
-
): Matrix4 {
|
|
2270
|
-
return perspective(fov, aspect, near, far, new Matrix4());
|
|
2414
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2415
|
+
public static fromXRotation(r: number): Matrix4 {
|
|
2416
|
+
return fromXRotation(r, new Matrix4());
|
|
2271
2417
|
}
|
|
2272
2418
|
|
|
2273
2419
|
/**
|
|
2274
|
-
* Create a
|
|
2275
|
-
* @param
|
|
2276
|
-
* @
|
|
2420
|
+
* Create a transformation matrix that represents a rotation by the given angle around the Y-axis.
|
|
2421
|
+
* @param r - The angle in radians.
|
|
2422
|
+
* @returns The transformation matrix.
|
|
2423
|
+
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2424
|
+
*/
|
|
2425
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2426
|
+
public static fromYRotation(r: number): Matrix4 {
|
|
2427
|
+
return fromYRotation(r, new Matrix4());
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
|
|
2432
|
+
* @param r - The angle in radians.
|
|
2433
|
+
* @returns The transformation matrix.
|
|
2434
|
+
* @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
|
|
2435
|
+
*/
|
|
2436
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2437
|
+
public static fromZRotation(r: number): Matrix4 {
|
|
2438
|
+
return fromZRotation(r, new Matrix4());
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
/**
|
|
2442
|
+
* Generate a frustum matrix with the given bounds.
|
|
2443
|
+
* @param left - The left bound of the frustum.
|
|
2444
|
+
* @param right - The right bound of the frustum.
|
|
2445
|
+
* @param bottom - The bottom bound of the frustum.
|
|
2446
|
+
* @param top - The top bound of the frustum.
|
|
2277
2447
|
* @param near - The near bound of the frustum.
|
|
2278
2448
|
* @param far - The far bound of the frustum.
|
|
2279
|
-
* @returns The
|
|
2449
|
+
* @returns The frustum matrix.
|
|
2280
2450
|
* @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
|
|
2281
2451
|
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2282
2452
|
*/
|
|
2283
|
-
public static
|
|
2284
|
-
|
|
2285
|
-
|
|
2453
|
+
public static frustum(
|
|
2454
|
+
left: number,
|
|
2455
|
+
right: number,
|
|
2456
|
+
bottom: number,
|
|
2457
|
+
top: number,
|
|
2286
2458
|
near: number,
|
|
2287
2459
|
far: number
|
|
2288
2460
|
): Matrix4 {
|
|
2289
|
-
return
|
|
2461
|
+
return frustum(left, right, bottom, top, near, far, new Matrix4());
|
|
2290
2462
|
}
|
|
2291
2463
|
|
|
2292
2464
|
/**
|
|
2293
|
-
*
|
|
2294
|
-
* @param
|
|
2295
|
-
* @param
|
|
2296
|
-
* @param
|
|
2297
|
-
* @returns The
|
|
2298
|
-
* @see {@link https://en.wikipedia.org/wiki/
|
|
2299
|
-
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2300
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
|
|
2465
|
+
* Generate a look-at matrix. If you want a matrix that actually makes an object look at another object, use `targetTo` instead.
|
|
2466
|
+
* @param eye - The position of the viewer.
|
|
2467
|
+
* @param center - The point that the viewer is looking at.
|
|
2468
|
+
* @param up - The local up direction.
|
|
2469
|
+
* @returns The look-at matrix.
|
|
2470
|
+
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2301
2471
|
*/
|
|
2302
|
-
public static
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2472
|
+
public static lookAt(
|
|
2473
|
+
eye: Vector3Like,
|
|
2474
|
+
center: Vector3Like,
|
|
2475
|
+
up: Vector3Like = [0, 1, 0]
|
|
2306
2476
|
): Matrix4 {
|
|
2307
|
-
return
|
|
2477
|
+
return lookAt(eye, center, up, new Matrix4());
|
|
2308
2478
|
}
|
|
2309
2479
|
|
|
2310
2480
|
/**
|
|
@@ -2354,19 +2524,59 @@ export default class Matrix4
|
|
|
2354
2524
|
}
|
|
2355
2525
|
|
|
2356
2526
|
/**
|
|
2357
|
-
*
|
|
2358
|
-
* @param
|
|
2359
|
-
* @param
|
|
2360
|
-
* @param
|
|
2361
|
-
* @
|
|
2362
|
-
* @
|
|
2527
|
+
* Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
|
|
2528
|
+
* @param fov - The vertical field of view in radians.
|
|
2529
|
+
* @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
|
|
2530
|
+
* @param near - The near bound of the frustum.
|
|
2531
|
+
* @param far - The far bound of the frustum.
|
|
2532
|
+
* @returns The perspective projection matrix.
|
|
2533
|
+
* @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
|
|
2534
|
+
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2363
2535
|
*/
|
|
2364
|
-
public static
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2536
|
+
public static perspective(
|
|
2537
|
+
fov: number,
|
|
2538
|
+
aspect: number,
|
|
2539
|
+
near: number,
|
|
2540
|
+
far: number
|
|
2368
2541
|
): Matrix4 {
|
|
2369
|
-
return
|
|
2542
|
+
return perspective(fov, aspect, near, far, new Matrix4());
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
/**
|
|
2546
|
+
* Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
|
|
2547
|
+
* @param fov - The field of view.
|
|
2548
|
+
* @param near - The near bound of the frustum.
|
|
2549
|
+
* @param far - The far bound of the frustum.
|
|
2550
|
+
* @returns The perspective projection matrix.
|
|
2551
|
+
* @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
|
|
2552
|
+
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2553
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
|
|
2554
|
+
*/
|
|
2555
|
+
public static perspectiveFromFieldOfView(
|
|
2556
|
+
fov: FieldOfView,
|
|
2557
|
+
near: number,
|
|
2558
|
+
far: number
|
|
2559
|
+
): Matrix4 {
|
|
2560
|
+
return perspectiveFromFieldOfView(fov, near, far, new Matrix4());
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
|
|
2565
|
+
* @param fov - The vertical field of view in radians.
|
|
2566
|
+
* @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
|
|
2567
|
+
* @param near - The near bound of the frustum.
|
|
2568
|
+
* @param far - The far bound of the frustum.
|
|
2569
|
+
* @returns The perspective projection matrix.
|
|
2570
|
+
* @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
|
|
2571
|
+
* @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
|
|
2572
|
+
*/
|
|
2573
|
+
public static perspectiveGpu(
|
|
2574
|
+
fov: number,
|
|
2575
|
+
aspect: number,
|
|
2576
|
+
near: number,
|
|
2577
|
+
far: number
|
|
2578
|
+
): Matrix4 {
|
|
2579
|
+
return perspectiveGpu(fov, aspect, near, far, new Matrix4());
|
|
2370
2580
|
}
|
|
2371
2581
|
|
|
2372
2582
|
/**
|
|
@@ -2385,153 +2595,6 @@ export default class Matrix4
|
|
|
2385
2595
|
return targetTo(eye, target, up, new Matrix4());
|
|
2386
2596
|
}
|
|
2387
2597
|
|
|
2388
|
-
/**
|
|
2389
|
-
* Create a two-by-two matrix with the given values.
|
|
2390
|
-
* @param c0r0 - The value in the first column and first row.
|
|
2391
|
-
* @param c0r1 - The value in the first column and second row.
|
|
2392
|
-
* @param c0r2 - The value in the first column and third row.
|
|
2393
|
-
* @param c0r3 - The value in the first column and fourth row.
|
|
2394
|
-
* @param c1r0 - The value in the second column and first row.
|
|
2395
|
-
* @param c1r1 - The value in the second column and second row.
|
|
2396
|
-
* @param c1r2 - The value in the second column and third row.
|
|
2397
|
-
* @param c1r3 - The value in the second column and fourth row.
|
|
2398
|
-
* @param c2r0 - The value in the third column and first row.
|
|
2399
|
-
* @param c2r1 - The value in the third column and second row.
|
|
2400
|
-
* @param c2r2 - The value in the third column and third row.
|
|
2401
|
-
* @param c2r3 - The value in the third column and fourth row.
|
|
2402
|
-
* @param c3r0 - The value in the fourth column and first row.
|
|
2403
|
-
* @param c3r1 - The value in the fourth column and second row.
|
|
2404
|
-
* @param c3r2 - The value in the fourth column and third row.
|
|
2405
|
-
* @param c3r3 - The value in the fourth column and fourth row.
|
|
2406
|
-
* @returns The matrix.
|
|
2407
|
-
*/
|
|
2408
|
-
public static fromValues(
|
|
2409
|
-
c0r0: number,
|
|
2410
|
-
c0r1: number,
|
|
2411
|
-
c0r2: number,
|
|
2412
|
-
c0r3: number,
|
|
2413
|
-
c1r0: number,
|
|
2414
|
-
c1r1: number,
|
|
2415
|
-
c1r2: number,
|
|
2416
|
-
c1r3: number,
|
|
2417
|
-
c2r0: number,
|
|
2418
|
-
c2r1: number,
|
|
2419
|
-
c2r2: number,
|
|
2420
|
-
c2r3: number,
|
|
2421
|
-
c3r0: number,
|
|
2422
|
-
c3r1: number,
|
|
2423
|
-
c3r2: number,
|
|
2424
|
-
c3r3: number
|
|
2425
|
-
): Matrix4 {
|
|
2426
|
-
return fromValues(
|
|
2427
|
-
c0r0,
|
|
2428
|
-
c0r1,
|
|
2429
|
-
c0r2,
|
|
2430
|
-
c0r3,
|
|
2431
|
-
c1r0,
|
|
2432
|
-
c1r1,
|
|
2433
|
-
c1r2,
|
|
2434
|
-
c1r3,
|
|
2435
|
-
c2r0,
|
|
2436
|
-
c2r1,
|
|
2437
|
-
c2r2,
|
|
2438
|
-
c2r3,
|
|
2439
|
-
c3r0,
|
|
2440
|
-
c3r1,
|
|
2441
|
-
c3r2,
|
|
2442
|
-
c3r3,
|
|
2443
|
-
new Matrix4()
|
|
2444
|
-
);
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* Create a four-by-four identity matrix.
|
|
2449
|
-
* @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
|
|
2450
|
-
*/
|
|
2451
|
-
public constructor() {
|
|
2452
|
-
super(16);
|
|
2453
|
-
|
|
2454
|
-
this[0] = 1;
|
|
2455
|
-
this[5] = 1;
|
|
2456
|
-
this[10] = 1;
|
|
2457
|
-
this[15] = 1;
|
|
2458
|
-
|
|
2459
|
-
this.width = 4;
|
|
2460
|
-
this.height = 4;
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
/** The value in the first column and first row. */
|
|
2464
|
-
public 0: number;
|
|
2465
|
-
|
|
2466
|
-
/** The value in the first column and second row. */
|
|
2467
|
-
public 1: number;
|
|
2468
|
-
|
|
2469
|
-
/** The value in the first column and third row. */
|
|
2470
|
-
public 2: number;
|
|
2471
|
-
|
|
2472
|
-
/** The value in the first column and fourth row. */
|
|
2473
|
-
public 3: number;
|
|
2474
|
-
|
|
2475
|
-
/** The value in the second column and first row. */
|
|
2476
|
-
public 4: number;
|
|
2477
|
-
|
|
2478
|
-
/** The value in the second column and second row. */
|
|
2479
|
-
public 5: number;
|
|
2480
|
-
|
|
2481
|
-
/** The value in the second column and third row. */
|
|
2482
|
-
public 6: number;
|
|
2483
|
-
|
|
2484
|
-
/** The value in the second column and fourth row. */
|
|
2485
|
-
public 7: number;
|
|
2486
|
-
|
|
2487
|
-
/** The value in the third column and first row. */
|
|
2488
|
-
public 8: number;
|
|
2489
|
-
|
|
2490
|
-
/** The value in the third column and second row. */
|
|
2491
|
-
public 9: number;
|
|
2492
|
-
|
|
2493
|
-
/** The value in the third column and third row. */
|
|
2494
|
-
public 10: number;
|
|
2495
|
-
|
|
2496
|
-
/** The value in the third column and fourth row. */
|
|
2497
|
-
public 11: number;
|
|
2498
|
-
|
|
2499
|
-
/** The value in the fourth column and first row. */
|
|
2500
|
-
public 12: number;
|
|
2501
|
-
|
|
2502
|
-
/** The value in the fourth column and second row. */
|
|
2503
|
-
public 13: number;
|
|
2504
|
-
|
|
2505
|
-
/** The value in the fourth column and third row. */
|
|
2506
|
-
public 14: number;
|
|
2507
|
-
|
|
2508
|
-
/** The value in the fourth column and fourth row. */
|
|
2509
|
-
public 15: number;
|
|
2510
|
-
|
|
2511
|
-
/** The number of columns in this matrix. */
|
|
2512
|
-
public readonly width: 4;
|
|
2513
|
-
|
|
2514
|
-
/** The number of rows in this matrix. */
|
|
2515
|
-
public readonly height: 4;
|
|
2516
|
-
|
|
2517
|
-
/**
|
|
2518
|
-
* Determine whether or not this matrix is roughly equivalent to another.
|
|
2519
|
-
* @param matrix - The other matrix.
|
|
2520
|
-
* @returns Whether or not the matrices are equivalent.
|
|
2521
|
-
*/
|
|
2522
|
-
public equals(matrix: Matrix4Like): boolean {
|
|
2523
|
-
return equals(this, matrix);
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
/**
|
|
2527
|
-
* Determine whether or not this matrix is exactly equivalent to another.
|
|
2528
|
-
* @param matrix - The other matrix.
|
|
2529
|
-
* @returns Whether or not the matrices are equivalent.
|
|
2530
|
-
*/
|
|
2531
|
-
public exactEquals(matrix: Matrix4Like): boolean {
|
|
2532
|
-
return exactEquals(this, matrix);
|
|
2533
|
-
}
|
|
2534
|
-
|
|
2535
2598
|
/**
|
|
2536
2599
|
* Add two matrices of the same size.
|
|
2537
2600
|
* @param matrix - The other matrix.
|
|
@@ -2569,70 +2632,21 @@ export default class Matrix4
|
|
|
2569
2632
|
}
|
|
2570
2633
|
|
|
2571
2634
|
/**
|
|
2572
|
-
*
|
|
2573
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
|
|
2574
|
-
*/
|
|
2575
|
-
public get frob(): number {
|
|
2576
|
-
return frob(this);
|
|
2577
|
-
}
|
|
2578
|
-
|
|
2579
|
-
/**
|
|
2580
|
-
* Multiply this matrix by another.
|
|
2581
|
-
* @param matrix - The other matrix.
|
|
2582
|
-
* @returns The product of the matrices.
|
|
2583
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2584
|
-
*/
|
|
2585
|
-
public multiply(matrix: Matrix4Like): Matrix4 {
|
|
2586
|
-
return multiply(this, matrix, new Matrix4());
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2589
|
-
/**
|
|
2590
|
-
* Multiply this matrix by a scalar value.
|
|
2591
|
-
* @param scalar - The scalar value.
|
|
2592
|
-
* @returns The product of the matrix and the scalar value.
|
|
2593
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2594
|
-
*/
|
|
2595
|
-
public multiplyScalar(scalar: number): Matrix4 {
|
|
2596
|
-
return multiplyScalar(this, scalar, new Matrix4());
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
/**
|
|
2600
|
-
* Add this matrix to another after multiplying the other by a scalar.
|
|
2635
|
+
* Determine whether or not this matrix is roughly equivalent to another.
|
|
2601
2636
|
* @param matrix - The other matrix.
|
|
2602
|
-
* @
|
|
2603
|
-
* @returns The sum.
|
|
2604
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
2605
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2637
|
+
* @returns Whether or not the matrices are equivalent.
|
|
2606
2638
|
*/
|
|
2607
|
-
public
|
|
2608
|
-
return
|
|
2639
|
+
public equals(matrix: Matrix4Like): boolean {
|
|
2640
|
+
return equals(this, matrix);
|
|
2609
2641
|
}
|
|
2610
2642
|
|
|
2611
2643
|
/**
|
|
2612
|
-
*
|
|
2644
|
+
* Determine whether or not this matrix is exactly equivalent to another.
|
|
2613
2645
|
* @param matrix - The other matrix.
|
|
2614
|
-
* @returns
|
|
2615
|
-
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
2616
|
-
*/
|
|
2617
|
-
public subtract(matrix: Matrix4Like): Matrix4 {
|
|
2618
|
-
return subtract(this, matrix, new Matrix4());
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
/**
|
|
2622
|
-
* Transpose this matrix.
|
|
2623
|
-
* @returns The transpose of this matrix.
|
|
2624
|
-
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
2625
|
-
*/
|
|
2626
|
-
public transpose(): Matrix4 {
|
|
2627
|
-
return transpose(this, new Matrix4());
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
|
-
/**
|
|
2631
|
-
* Get the determinant of this matrix.
|
|
2632
|
-
* @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
|
|
2646
|
+
* @returns Whether or not the matrices are equivalent.
|
|
2633
2647
|
*/
|
|
2634
|
-
public
|
|
2635
|
-
return
|
|
2648
|
+
public exactEquals(matrix: Matrix4Like): boolean {
|
|
2649
|
+
return exactEquals(this, matrix);
|
|
2636
2650
|
}
|
|
2637
2651
|
|
|
2638
2652
|
/**
|
|
@@ -2654,23 +2668,35 @@ export default class Matrix4
|
|
|
2654
2668
|
}
|
|
2655
2669
|
|
|
2656
2670
|
/**
|
|
2657
|
-
*
|
|
2658
|
-
* @param
|
|
2659
|
-
* @returns The
|
|
2660
|
-
* @see {@link https://en.wikipedia.org/wiki/
|
|
2671
|
+
* Multiply this matrix by another.
|
|
2672
|
+
* @param matrix - The other matrix.
|
|
2673
|
+
* @returns The product of the matrices.
|
|
2674
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2661
2675
|
*/
|
|
2662
|
-
public
|
|
2663
|
-
return
|
|
2676
|
+
public multiply(matrix: Matrix4Like): Matrix4 {
|
|
2677
|
+
return multiply(this, matrix, new Matrix4());
|
|
2664
2678
|
}
|
|
2665
2679
|
|
|
2666
2680
|
/**
|
|
2667
|
-
*
|
|
2668
|
-
* @param
|
|
2669
|
-
* @returns The
|
|
2670
|
-
* @see {@link https://en.wikipedia.org/wiki/
|
|
2681
|
+
* Multiply this matrix by a scalar value.
|
|
2682
|
+
* @param scalar - The scalar value.
|
|
2683
|
+
* @returns The product of the matrix and the scalar value.
|
|
2684
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2671
2685
|
*/
|
|
2672
|
-
public
|
|
2673
|
-
return
|
|
2686
|
+
public multiplyScalar(scalar: number): Matrix4 {
|
|
2687
|
+
return multiplyScalar(this, scalar, new Matrix4());
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
/**
|
|
2691
|
+
* Add this matrix to another after multiplying the other by a scalar.
|
|
2692
|
+
* @param matrix - The other matrix.
|
|
2693
|
+
* @param scalar - The scalar.
|
|
2694
|
+
* @returns The sum.
|
|
2695
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
2696
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
|
|
2697
|
+
*/
|
|
2698
|
+
public multiplyScalarAndAdd(matrix: Matrix4Like, scalar: number): Matrix4 {
|
|
2699
|
+
return multiplyScalarAndAdd(this, matrix, scalar, new Matrix4());
|
|
2674
2700
|
}
|
|
2675
2701
|
|
|
2676
2702
|
/**
|
|
@@ -2715,12 +2741,13 @@ export default class Matrix4
|
|
|
2715
2741
|
}
|
|
2716
2742
|
|
|
2717
2743
|
/**
|
|
2718
|
-
*
|
|
2719
|
-
* @
|
|
2744
|
+
* Scale this matrix by the given vector.
|
|
2745
|
+
* @param vector - The scaling vector.
|
|
2746
|
+
* @returns The scaled matrix.
|
|
2720
2747
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2721
2748
|
*/
|
|
2722
|
-
public
|
|
2723
|
-
return
|
|
2749
|
+
public scale(vector: Vector3Like): Matrix4 {
|
|
2750
|
+
return scale(this, vector, new Matrix4());
|
|
2724
2751
|
}
|
|
2725
2752
|
|
|
2726
2753
|
/**
|
|
@@ -2734,20 +2761,31 @@ export default class Matrix4
|
|
|
2734
2761
|
}
|
|
2735
2762
|
|
|
2736
2763
|
/**
|
|
2737
|
-
*
|
|
2738
|
-
* @
|
|
2764
|
+
* Subtract another matrix from this one.
|
|
2765
|
+
* @param matrix - The other matrix.
|
|
2766
|
+
* @returns The difference between the matrices.
|
|
2767
|
+
* @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
|
|
2768
|
+
*/
|
|
2769
|
+
public subtract(matrix: Matrix4Like): Matrix4 {
|
|
2770
|
+
return subtract(this, matrix, new Matrix4());
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
/**
|
|
2774
|
+
* Translate this matrix by the given vector.
|
|
2775
|
+
* @param vector - The translation vector.
|
|
2776
|
+
* @returns The translated matrix.
|
|
2739
2777
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
2740
2778
|
*/
|
|
2741
|
-
public
|
|
2742
|
-
return
|
|
2779
|
+
public translate(vector: Vector3Like): Matrix4 {
|
|
2780
|
+
return translate(this, vector, new Matrix4());
|
|
2743
2781
|
}
|
|
2744
2782
|
|
|
2745
2783
|
/**
|
|
2746
|
-
*
|
|
2747
|
-
* @returns The
|
|
2748
|
-
* @see {@link https://en.wikipedia.org/wiki/
|
|
2784
|
+
* Transpose this matrix.
|
|
2785
|
+
* @returns The transpose of this matrix.
|
|
2786
|
+
* @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
|
|
2749
2787
|
*/
|
|
2750
|
-
public
|
|
2751
|
-
return
|
|
2788
|
+
public transpose(): Matrix4 {
|
|
2789
|
+
return transpose(this, new Matrix4());
|
|
2752
2790
|
}
|
|
2753
2791
|
}
|