@math.gl/core 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/base/math-array.d.ts +1 -2
- package/dist/classes/base/math-array.js +220 -266
- package/dist/classes/base/matrix.d.ts +1 -2
- package/dist/classes/base/matrix.js +52 -53
- package/dist/classes/base/vector.d.ts +1 -2
- package/dist/classes/base/vector.js +121 -135
- package/dist/classes/euler.d.ts +2 -3
- package/dist/classes/euler.js +462 -533
- package/dist/classes/matrix3.d.ts +2 -3
- package/dist/classes/matrix3.js +185 -190
- package/dist/classes/matrix4.d.ts +1 -2
- package/dist/classes/matrix4.js +516 -452
- package/dist/classes/pose.d.ts +4 -5
- package/dist/classes/pose.js +104 -119
- package/dist/classes/quaternion.d.ts +1 -2
- package/dist/classes/quaternion.js +257 -233
- package/dist/classes/spherical-coordinates.d.ts +3 -4
- package/dist/classes/spherical-coordinates.js +138 -147
- package/dist/classes/vector2.d.ts +1 -2
- package/dist/classes/vector2.js +101 -85
- package/dist/classes/vector3.d.ts +1 -2
- package/dist/classes/vector3.js +125 -136
- package/dist/classes/vector4.d.ts +2 -3
- package/dist/classes/vector4.js +106 -114
- package/dist/gl-matrix/common.d.ts +0 -1
- package/dist/gl-matrix/common.js +38 -6
- package/dist/gl-matrix/mat3.d.ts +0 -1
- package/dist/gl-matrix/mat3.js +699 -425
- package/dist/gl-matrix/mat4.d.ts +0 -1
- package/dist/gl-matrix/mat4.js +1879 -1339
- package/dist/gl-matrix/quat.d.ts +0 -1
- package/dist/gl-matrix/quat.js +655 -257
- package/dist/gl-matrix/vec2.d.ts +0 -1
- package/dist/gl-matrix/vec2.js +529 -212
- package/dist/gl-matrix/vec3.d.ts +0 -1
- package/dist/gl-matrix/vec3.js +703 -335
- package/dist/gl-matrix/vec4.d.ts +0 -1
- package/dist/gl-matrix/vec4.js +579 -293
- package/dist/gl-matrix/wip/index.d.ts +3 -4
- package/dist/gl-matrix/wip/index.js +2 -1
- package/dist/gl-matrix/wip/mat2.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2.js +333 -157
- package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2d.js +377 -202
- package/dist/gl-matrix/wip/quat2.d.ts +0 -1
- package/dist/gl-matrix/wip/quat2.js +647 -409
- package/dist/index.cjs +60 -100
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +21 -22
- package/dist/index.js +23 -16
- package/dist/lib/assert.d.ts +0 -1
- package/dist/lib/assert.js +3 -4
- package/dist/lib/common.d.ts +2 -3
- package/dist/lib/common.js +163 -134
- package/dist/lib/gl-matrix-extras.d.ts +0 -1
- package/dist/lib/gl-matrix-extras.js +39 -36
- package/dist/lib/math-utils.d.ts +0 -1
- package/dist/lib/math-utils.js +2 -1
- package/dist/lib/validators.d.ts +0 -1
- package/dist/lib/validators.js +22 -25
- package/package.json +5 -6
- package/src/classes/matrix3.ts +1 -1
- package/dist/classes/base/math-array.d.ts.map +0 -1
- package/dist/classes/base/math-array.js.map +0 -1
- package/dist/classes/base/matrix.d.ts.map +0 -1
- package/dist/classes/base/matrix.js.map +0 -1
- package/dist/classes/base/vector.d.ts.map +0 -1
- package/dist/classes/base/vector.js.map +0 -1
- package/dist/classes/euler.d.ts.map +0 -1
- package/dist/classes/euler.js.map +0 -1
- package/dist/classes/matrix3.d.ts.map +0 -1
- package/dist/classes/matrix3.js.map +0 -1
- package/dist/classes/matrix4.d.ts.map +0 -1
- package/dist/classes/matrix4.js.map +0 -1
- package/dist/classes/pose.d.ts.map +0 -1
- package/dist/classes/pose.js.map +0 -1
- package/dist/classes/quaternion.d.ts.map +0 -1
- package/dist/classes/quaternion.js.map +0 -1
- package/dist/classes/spherical-coordinates.d.ts.map +0 -1
- package/dist/classes/spherical-coordinates.js.map +0 -1
- package/dist/classes/vector2.d.ts.map +0 -1
- package/dist/classes/vector2.js.map +0 -1
- package/dist/classes/vector3.d.ts.map +0 -1
- package/dist/classes/vector3.js.map +0 -1
- package/dist/classes/vector4.d.ts.map +0 -1
- package/dist/classes/vector4.js.map +0 -1
- package/dist/gl-matrix/common.d.ts.map +0 -1
- package/dist/gl-matrix/common.js.map +0 -1
- package/dist/gl-matrix/mat3.d.ts.map +0 -1
- package/dist/gl-matrix/mat3.js.map +0 -1
- package/dist/gl-matrix/mat4.d.ts.map +0 -1
- package/dist/gl-matrix/mat4.js.map +0 -1
- package/dist/gl-matrix/quat.d.ts.map +0 -1
- package/dist/gl-matrix/quat.js.map +0 -1
- package/dist/gl-matrix/vec2.d.ts.map +0 -1
- package/dist/gl-matrix/vec2.js.map +0 -1
- package/dist/gl-matrix/vec3.d.ts.map +0 -1
- package/dist/gl-matrix/vec3.js.map +0 -1
- package/dist/gl-matrix/vec4.d.ts.map +0 -1
- package/dist/gl-matrix/vec4.js.map +0 -1
- package/dist/gl-matrix/wip/index.d.ts.map +0 -1
- package/dist/gl-matrix/wip/index.js.map +0 -1
- package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2.js.map +0 -1
- package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2d.js.map +0 -1
- package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/quat2.js.map +0 -1
- package/dist/gl-matrix/wip/types.d.js +0 -2
- package/dist/gl-matrix/wip/types.d.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/assert.d.ts.map +0 -1
- package/dist/lib/assert.js.map +0 -1
- package/dist/lib/common.d.ts.map +0 -1
- package/dist/lib/common.js.map +0 -1
- package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
- package/dist/lib/gl-matrix-extras.js.map +0 -1
- package/dist/lib/gl-matrix.d.js +0 -2
- package/dist/lib/gl-matrix.d.js.map +0 -1
- package/dist/lib/math-utils.d.ts.map +0 -1
- package/dist/lib/math-utils.js.map +0 -1
- package/dist/lib/validators.d.ts.map +0 -1
- package/dist/lib/validators.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as mat2 from
|
|
2
|
-
import * as mat2d from
|
|
3
|
-
import * as quat2 from
|
|
1
|
+
import * as mat2 from './mat2.js';
|
|
2
|
+
import * as mat2d from './mat2d.js';
|
|
3
|
+
import * as quat2 from './quat2.js';
|
|
4
4
|
export { glMatrix, mat2, mat2d, mat3, mat4, quat, quat2, vec2, vec3, vec4 };
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @eslint-disable
|
|
2
|
+
// @ts-nocheck
|
|
1
3
|
import * as glMatrix from './common.js';
|
|
2
4
|
import * as mat2 from './mat2.js';
|
|
3
5
|
import * as mat2d from './mat2d.js';
|
|
@@ -9,4 +11,3 @@ import * as vec2 from './vec2.js';
|
|
|
9
11
|
import * as vec3 from './vec3.js';
|
|
10
12
|
import * as vec4 from './vec4.js';
|
|
11
13
|
export { glMatrix, mat2, mat2d, mat3, mat4, quat, quat2, vec2, vec3, vec4 };
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,208 +1,384 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
1
3
|
import * as glMatrix from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* 2x2 Matrix
|
|
6
|
+
* @module mat2
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new identity mat2
|
|
10
|
+
*
|
|
11
|
+
* @returns {mat2} a new 2x2 matrix
|
|
12
|
+
*/
|
|
2
13
|
export function create() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
out[3] = 1;
|
|
12
|
-
return out;
|
|
14
|
+
let out = new glMatrix.ARRAY_TYPE(4);
|
|
15
|
+
if (glMatrix.ARRAY_TYPE != Float32Array) {
|
|
16
|
+
out[1] = 0;
|
|
17
|
+
out[2] = 0;
|
|
18
|
+
}
|
|
19
|
+
out[0] = 1;
|
|
20
|
+
out[3] = 1;
|
|
21
|
+
return out;
|
|
13
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new mat2 initialized with values from an existing matrix
|
|
25
|
+
*
|
|
26
|
+
* @param {ReadonlyMat2} a matrix to clone
|
|
27
|
+
* @returns {mat2} a new 2x2 matrix
|
|
28
|
+
*/
|
|
14
29
|
export function clone(a) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
let out = new glMatrix.ARRAY_TYPE(4);
|
|
31
|
+
out[0] = a[0];
|
|
32
|
+
out[1] = a[1];
|
|
33
|
+
out[2] = a[2];
|
|
34
|
+
out[3] = a[3];
|
|
35
|
+
return out;
|
|
21
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Copy the values from one mat2 to another
|
|
39
|
+
*
|
|
40
|
+
* @param {mat2} out the receiving matrix
|
|
41
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
42
|
+
* @returns {mat2} out
|
|
43
|
+
*/
|
|
22
44
|
export function copy(out, a) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
out[0] = a[0];
|
|
46
|
+
out[1] = a[1];
|
|
47
|
+
out[2] = a[2];
|
|
48
|
+
out[3] = a[3];
|
|
49
|
+
return out;
|
|
28
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Set a mat2 to the identity matrix
|
|
53
|
+
*
|
|
54
|
+
* @param {mat2} out the receiving matrix
|
|
55
|
+
* @returns {mat2} out
|
|
56
|
+
*/
|
|
29
57
|
export function identity(out) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
58
|
+
out[0] = 1;
|
|
59
|
+
out[1] = 0;
|
|
60
|
+
out[2] = 0;
|
|
61
|
+
out[3] = 1;
|
|
62
|
+
return out;
|
|
35
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a new mat2 with the given values
|
|
66
|
+
*
|
|
67
|
+
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
68
|
+
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
69
|
+
* @param {Number} m10 Component in column 1, row 0 position (index 2)
|
|
70
|
+
* @param {Number} m11 Component in column 1, row 1 position (index 3)
|
|
71
|
+
* @returns {mat2} out A new 2x2 matrix
|
|
72
|
+
*/
|
|
36
73
|
export function fromValues(m00, m01, m10, m11) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
let out = new glMatrix.ARRAY_TYPE(4);
|
|
75
|
+
out[0] = m00;
|
|
76
|
+
out[1] = m01;
|
|
77
|
+
out[2] = m10;
|
|
78
|
+
out[3] = m11;
|
|
79
|
+
return out;
|
|
43
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Set the components of a mat2 to the given values
|
|
83
|
+
*
|
|
84
|
+
* @param {mat2} out the receiving matrix
|
|
85
|
+
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
86
|
+
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
87
|
+
* @param {Number} m10 Component in column 1, row 0 position (index 2)
|
|
88
|
+
* @param {Number} m11 Component in column 1, row 1 position (index 3)
|
|
89
|
+
* @returns {mat2} out
|
|
90
|
+
*/
|
|
44
91
|
export function set(out, m00, m01, m10, m11) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
92
|
+
out[0] = m00;
|
|
93
|
+
out[1] = m01;
|
|
94
|
+
out[2] = m10;
|
|
95
|
+
out[3] = m11;
|
|
96
|
+
return out;
|
|
50
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Transpose the values of a mat2
|
|
100
|
+
*
|
|
101
|
+
* @param {mat2} out the receiving matrix
|
|
102
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
103
|
+
* @returns {mat2} out
|
|
104
|
+
*/
|
|
51
105
|
export function transpose(out, a) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
out
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
// If we are transposing ourselves we can skip a few steps but have to cache
|
|
107
|
+
// some values
|
|
108
|
+
if (out === a) {
|
|
109
|
+
let a1 = a[1];
|
|
110
|
+
out[1] = a[2];
|
|
111
|
+
out[2] = a1;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
out[0] = a[0];
|
|
115
|
+
out[1] = a[2];
|
|
116
|
+
out[2] = a[1];
|
|
117
|
+
out[3] = a[3];
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
64
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Inverts a mat2
|
|
123
|
+
*
|
|
124
|
+
* @param {mat2} out the receiving matrix
|
|
125
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
126
|
+
* @returns {mat2} out
|
|
127
|
+
*/
|
|
65
128
|
export function invert(out, a) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
out[1] = -a1 * det;
|
|
79
|
-
out[2] = -a2 * det;
|
|
80
|
-
out[3] = a0 * det;
|
|
81
|
-
return out;
|
|
129
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
|
|
130
|
+
// Calculate the determinant
|
|
131
|
+
let det = a0 * a3 - a2 * a1;
|
|
132
|
+
if (!det) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
det = 1.0 / det;
|
|
136
|
+
out[0] = a3 * det;
|
|
137
|
+
out[1] = -a1 * det;
|
|
138
|
+
out[2] = -a2 * det;
|
|
139
|
+
out[3] = a0 * det;
|
|
140
|
+
return out;
|
|
82
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Calculates the adjugate of a mat2
|
|
144
|
+
*
|
|
145
|
+
* @param {mat2} out the receiving matrix
|
|
146
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
147
|
+
* @returns {mat2} out
|
|
148
|
+
*/
|
|
83
149
|
export function adjoint(out, a) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
150
|
+
// Caching this value is necessary if out == a
|
|
151
|
+
let a0 = a[0];
|
|
152
|
+
out[0] = a[3];
|
|
153
|
+
out[1] = -a[1];
|
|
154
|
+
out[2] = -a[2];
|
|
155
|
+
out[3] = a0;
|
|
156
|
+
return out;
|
|
90
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Calculates the determinant of a mat2
|
|
160
|
+
*
|
|
161
|
+
* @param {ReadonlyMat2} a the source matrix
|
|
162
|
+
* @returns {Number} determinant of a
|
|
163
|
+
*/
|
|
91
164
|
export function determinant(a) {
|
|
92
|
-
|
|
165
|
+
return a[0] * a[3] - a[2] * a[1];
|
|
93
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Multiplies two mat2's
|
|
169
|
+
*
|
|
170
|
+
* @param {mat2} out the receiving matrix
|
|
171
|
+
* @param {ReadonlyMat2} a the first operand
|
|
172
|
+
* @param {ReadonlyMat2} b the second operand
|
|
173
|
+
* @returns {mat2} out
|
|
174
|
+
*/
|
|
94
175
|
export function multiply(out, a, b) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
b3 = b[3];
|
|
103
|
-
out[0] = a0 * b0 + a2 * b1;
|
|
104
|
-
out[1] = a1 * b0 + a3 * b1;
|
|
105
|
-
out[2] = a0 * b2 + a2 * b3;
|
|
106
|
-
out[3] = a1 * b2 + a3 * b3;
|
|
107
|
-
return out;
|
|
176
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
|
|
177
|
+
let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
|
|
178
|
+
out[0] = a0 * b0 + a2 * b1;
|
|
179
|
+
out[1] = a1 * b0 + a3 * b1;
|
|
180
|
+
out[2] = a0 * b2 + a2 * b3;
|
|
181
|
+
out[3] = a1 * b2 + a3 * b3;
|
|
182
|
+
return out;
|
|
108
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Rotates a mat2 by the given angle
|
|
186
|
+
*
|
|
187
|
+
* @param {mat2} out the receiving matrix
|
|
188
|
+
* @param {ReadonlyMat2} a the matrix to rotate
|
|
189
|
+
* @param {Number} rad the angle to rotate the matrix by
|
|
190
|
+
* @returns {mat2} out
|
|
191
|
+
*/
|
|
109
192
|
export function rotate(out, a, rad) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
out[2] = a0 * -s + a2 * c;
|
|
119
|
-
out[3] = a1 * -s + a3 * c;
|
|
120
|
-
return out;
|
|
193
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
|
|
194
|
+
let s = Math.sin(rad);
|
|
195
|
+
let c = Math.cos(rad);
|
|
196
|
+
out[0] = a0 * c + a2 * s;
|
|
197
|
+
out[1] = a1 * c + a3 * s;
|
|
198
|
+
out[2] = a0 * -s + a2 * c;
|
|
199
|
+
out[3] = a1 * -s + a3 * c;
|
|
200
|
+
return out;
|
|
121
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Scales the mat2 by the dimensions in the given vec2
|
|
204
|
+
*
|
|
205
|
+
* @param {mat2} out the receiving matrix
|
|
206
|
+
* @param {ReadonlyMat2} a the matrix to rotate
|
|
207
|
+
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
|
|
208
|
+
* @returns {mat2} out
|
|
209
|
+
**/
|
|
122
210
|
export function scale(out, a, v) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
out[1] = a1 * v0;
|
|
131
|
-
out[2] = a2 * v1;
|
|
132
|
-
out[3] = a3 * v1;
|
|
133
|
-
return out;
|
|
211
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
|
|
212
|
+
let v0 = v[0], v1 = v[1];
|
|
213
|
+
out[0] = a0 * v0;
|
|
214
|
+
out[1] = a1 * v0;
|
|
215
|
+
out[2] = a2 * v1;
|
|
216
|
+
out[3] = a3 * v1;
|
|
217
|
+
return out;
|
|
134
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates a matrix from a given angle
|
|
221
|
+
* This is equivalent to (but much faster than):
|
|
222
|
+
*
|
|
223
|
+
* mat2.identity(dest);
|
|
224
|
+
* mat2.rotate(dest, dest, rad);
|
|
225
|
+
*
|
|
226
|
+
* @param {mat2} out mat2 receiving operation result
|
|
227
|
+
* @param {Number} rad the angle to rotate the matrix by
|
|
228
|
+
* @returns {mat2} out
|
|
229
|
+
*/
|
|
135
230
|
export function fromRotation(out, rad) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
231
|
+
let s = Math.sin(rad);
|
|
232
|
+
let c = Math.cos(rad);
|
|
233
|
+
out[0] = c;
|
|
234
|
+
out[1] = s;
|
|
235
|
+
out[2] = -s;
|
|
236
|
+
out[3] = c;
|
|
237
|
+
return out;
|
|
143
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Creates a matrix from a vector scaling
|
|
241
|
+
* This is equivalent to (but much faster than):
|
|
242
|
+
*
|
|
243
|
+
* mat2.identity(dest);
|
|
244
|
+
* mat2.scale(dest, dest, vec);
|
|
245
|
+
*
|
|
246
|
+
* @param {mat2} out mat2 receiving operation result
|
|
247
|
+
* @param {ReadonlyVec2} v Scaling vector
|
|
248
|
+
* @returns {mat2} out
|
|
249
|
+
*/
|
|
144
250
|
export function fromScaling(out, v) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
251
|
+
out[0] = v[0];
|
|
252
|
+
out[1] = 0;
|
|
253
|
+
out[2] = 0;
|
|
254
|
+
out[3] = v[1];
|
|
255
|
+
return out;
|
|
150
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns a string representation of a mat2
|
|
259
|
+
*
|
|
260
|
+
* @param {ReadonlyMat2} a matrix to represent as a string
|
|
261
|
+
* @returns {String} string representation of the matrix
|
|
262
|
+
*/
|
|
151
263
|
export function str(a) {
|
|
152
|
-
|
|
264
|
+
return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
|
|
153
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Returns Frobenius norm of a mat2
|
|
268
|
+
*
|
|
269
|
+
* @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of
|
|
270
|
+
* @returns {Number} Frobenius norm
|
|
271
|
+
*/
|
|
154
272
|
export function frob(a) {
|
|
155
|
-
|
|
273
|
+
return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]);
|
|
156
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
|
|
277
|
+
* @param {ReadonlyMat2} L the lower triangular matrix
|
|
278
|
+
* @param {ReadonlyMat2} D the diagonal matrix
|
|
279
|
+
* @param {ReadonlyMat2} U the upper triangular matrix
|
|
280
|
+
* @param {ReadonlyMat2} a the input matrix to factorize
|
|
281
|
+
*/
|
|
157
282
|
export function LDU(L, D, U, a) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
283
|
+
L[2] = a[2] / a[0];
|
|
284
|
+
U[0] = a[0];
|
|
285
|
+
U[1] = a[1];
|
|
286
|
+
U[3] = a[3] - L[2] * U[1];
|
|
287
|
+
return [L, D, U];
|
|
163
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Adds two mat2's
|
|
291
|
+
*
|
|
292
|
+
* @param {mat2} out the receiving matrix
|
|
293
|
+
* @param {ReadonlyMat2} a the first operand
|
|
294
|
+
* @param {ReadonlyMat2} b the second operand
|
|
295
|
+
* @returns {mat2} out
|
|
296
|
+
*/
|
|
164
297
|
export function add(out, a, b) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
298
|
+
out[0] = a[0] + b[0];
|
|
299
|
+
out[1] = a[1] + b[1];
|
|
300
|
+
out[2] = a[2] + b[2];
|
|
301
|
+
out[3] = a[3] + b[3];
|
|
302
|
+
return out;
|
|
170
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Subtracts matrix b from matrix a
|
|
306
|
+
*
|
|
307
|
+
* @param {mat2} out the receiving matrix
|
|
308
|
+
* @param {ReadonlyMat2} a the first operand
|
|
309
|
+
* @param {ReadonlyMat2} b the second operand
|
|
310
|
+
* @returns {mat2} out
|
|
311
|
+
*/
|
|
171
312
|
export function subtract(out, a, b) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
313
|
+
out[0] = a[0] - b[0];
|
|
314
|
+
out[1] = a[1] - b[1];
|
|
315
|
+
out[2] = a[2] - b[2];
|
|
316
|
+
out[3] = a[3] - b[3];
|
|
317
|
+
return out;
|
|
177
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
321
|
+
*
|
|
322
|
+
* @param {ReadonlyMat2} a The first matrix.
|
|
323
|
+
* @param {ReadonlyMat2} b The second matrix.
|
|
324
|
+
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
325
|
+
*/
|
|
178
326
|
export function exactEquals(a, b) {
|
|
179
|
-
|
|
327
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
|
|
180
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
331
|
+
*
|
|
332
|
+
* @param {ReadonlyMat2} a The first matrix.
|
|
333
|
+
* @param {ReadonlyMat2} b The second matrix.
|
|
334
|
+
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
335
|
+
*/
|
|
181
336
|
export function equals(a, b) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
b2 = b[2],
|
|
189
|
-
b3 = b[3];
|
|
190
|
-
return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));
|
|
337
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
|
|
338
|
+
let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
|
|
339
|
+
return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
|
|
340
|
+
Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
|
|
341
|
+
Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
|
|
342
|
+
Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)));
|
|
191
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Multiply each element of the matrix by a scalar.
|
|
346
|
+
*
|
|
347
|
+
* @param {mat2} out the receiving matrix
|
|
348
|
+
* @param {ReadonlyMat2} a the matrix to scale
|
|
349
|
+
* @param {Number} b amount to scale the matrix's elements by
|
|
350
|
+
* @returns {mat2} out
|
|
351
|
+
*/
|
|
192
352
|
export function multiplyScalar(out, a, b) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
353
|
+
out[0] = a[0] * b;
|
|
354
|
+
out[1] = a[1] * b;
|
|
355
|
+
out[2] = a[2] * b;
|
|
356
|
+
out[3] = a[3] * b;
|
|
357
|
+
return out;
|
|
198
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Adds two mat2's after multiplying each element of the second operand by a scalar value.
|
|
361
|
+
*
|
|
362
|
+
* @param {mat2} out the receiving vector
|
|
363
|
+
* @param {ReadonlyMat2} a the first operand
|
|
364
|
+
* @param {ReadonlyMat2} b the second operand
|
|
365
|
+
* @param {Number} scale the amount to scale b's elements by before adding
|
|
366
|
+
* @returns {mat2} out
|
|
367
|
+
*/
|
|
199
368
|
export function multiplyScalarAndAdd(out, a, b, scale) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
369
|
+
out[0] = a[0] + b[0] * scale;
|
|
370
|
+
out[1] = a[1] + b[1] * scale;
|
|
371
|
+
out[2] = a[2] + b[2] * scale;
|
|
372
|
+
out[3] = a[3] + b[3] * scale;
|
|
373
|
+
return out;
|
|
205
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Alias for {@link mat2.multiply}
|
|
377
|
+
* @function
|
|
378
|
+
*/
|
|
206
379
|
export const mul = multiply;
|
|
380
|
+
/**
|
|
381
|
+
* Alias for {@link mat2.subtract}
|
|
382
|
+
* @function
|
|
383
|
+
*/
|
|
207
384
|
export const sub = subtract;
|
|
208
|
-
//# sourceMappingURL=mat2.js.map
|