@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,251 +1,426 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
1
3
|
import * as glMatrix from './common.js';
|
|
4
|
+
/**
|
|
5
|
+
* 2x3 Matrix
|
|
6
|
+
* @module mat2d
|
|
7
|
+
* @description
|
|
8
|
+
* A mat2d contains six elements defined as:
|
|
9
|
+
* <pre>
|
|
10
|
+
* [a, b,
|
|
11
|
+
* c, d,
|
|
12
|
+
* tx, ty]
|
|
13
|
+
* </pre>
|
|
14
|
+
* This is a short form for the 3x3 matrix:
|
|
15
|
+
* <pre>
|
|
16
|
+
* [a, b, 0,
|
|
17
|
+
* c, d, 0,
|
|
18
|
+
* tx, ty, 1]
|
|
19
|
+
* </pre>
|
|
20
|
+
* The last column is ignored so the array is shorter and operations are faster.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new identity mat2d
|
|
24
|
+
*
|
|
25
|
+
* @returns {mat2d} a new 2x3 matrix
|
|
26
|
+
*/
|
|
2
27
|
export function create() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
out[3] = 1;
|
|
14
|
-
return out;
|
|
28
|
+
let out = new glMatrix.ARRAY_TYPE(6);
|
|
29
|
+
if (glMatrix.ARRAY_TYPE != Float32Array) {
|
|
30
|
+
out[1] = 0;
|
|
31
|
+
out[2] = 0;
|
|
32
|
+
out[4] = 0;
|
|
33
|
+
out[5] = 0;
|
|
34
|
+
}
|
|
35
|
+
out[0] = 1;
|
|
36
|
+
out[3] = 1;
|
|
37
|
+
return out;
|
|
15
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new mat2d initialized with values from an existing matrix
|
|
41
|
+
*
|
|
42
|
+
* @param {ReadonlyMat2d} a matrix to clone
|
|
43
|
+
* @returns {mat2d} a new 2x3 matrix
|
|
44
|
+
*/
|
|
16
45
|
export function clone(a) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
let out = new glMatrix.ARRAY_TYPE(6);
|
|
47
|
+
out[0] = a[0];
|
|
48
|
+
out[1] = a[1];
|
|
49
|
+
out[2] = a[2];
|
|
50
|
+
out[3] = a[3];
|
|
51
|
+
out[4] = a[4];
|
|
52
|
+
out[5] = a[5];
|
|
53
|
+
return out;
|
|
25
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Copy the values from one mat2d to another
|
|
57
|
+
*
|
|
58
|
+
* @param {mat2d} out the receiving matrix
|
|
59
|
+
* @param {ReadonlyMat2d} a the source matrix
|
|
60
|
+
* @returns {mat2d} out
|
|
61
|
+
*/
|
|
26
62
|
export function copy(out, a) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
63
|
+
out[0] = a[0];
|
|
64
|
+
out[1] = a[1];
|
|
65
|
+
out[2] = a[2];
|
|
66
|
+
out[3] = a[3];
|
|
67
|
+
out[4] = a[4];
|
|
68
|
+
out[5] = a[5];
|
|
69
|
+
return out;
|
|
34
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Set a mat2d to the identity matrix
|
|
73
|
+
*
|
|
74
|
+
* @param {mat2d} out the receiving matrix
|
|
75
|
+
* @returns {mat2d} out
|
|
76
|
+
*/
|
|
35
77
|
export function identity(out) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
78
|
+
out[0] = 1;
|
|
79
|
+
out[1] = 0;
|
|
80
|
+
out[2] = 0;
|
|
81
|
+
out[3] = 1;
|
|
82
|
+
out[4] = 0;
|
|
83
|
+
out[5] = 0;
|
|
84
|
+
return out;
|
|
43
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a new mat2d with the given values
|
|
88
|
+
*
|
|
89
|
+
* @param {Number} a Component A (index 0)
|
|
90
|
+
* @param {Number} b Component B (index 1)
|
|
91
|
+
* @param {Number} c Component C (index 2)
|
|
92
|
+
* @param {Number} d Component D (index 3)
|
|
93
|
+
* @param {Number} tx Component TX (index 4)
|
|
94
|
+
* @param {Number} ty Component TY (index 5)
|
|
95
|
+
* @returns {mat2d} A new mat2d
|
|
96
|
+
*/
|
|
44
97
|
export function fromValues(a, b, c, d, tx, ty) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
98
|
+
let out = new glMatrix.ARRAY_TYPE(6);
|
|
99
|
+
out[0] = a;
|
|
100
|
+
out[1] = b;
|
|
101
|
+
out[2] = c;
|
|
102
|
+
out[3] = d;
|
|
103
|
+
out[4] = tx;
|
|
104
|
+
out[5] = ty;
|
|
105
|
+
return out;
|
|
53
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Set the components of a mat2d to the given values
|
|
109
|
+
*
|
|
110
|
+
* @param {mat2d} out the receiving matrix
|
|
111
|
+
* @param {Number} a Component A (index 0)
|
|
112
|
+
* @param {Number} b Component B (index 1)
|
|
113
|
+
* @param {Number} c Component C (index 2)
|
|
114
|
+
* @param {Number} d Component D (index 3)
|
|
115
|
+
* @param {Number} tx Component TX (index 4)
|
|
116
|
+
* @param {Number} ty Component TY (index 5)
|
|
117
|
+
* @returns {mat2d} out
|
|
118
|
+
*/
|
|
54
119
|
export function set(out, a, b, c, d, tx, ty) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
120
|
+
out[0] = a;
|
|
121
|
+
out[1] = b;
|
|
122
|
+
out[2] = c;
|
|
123
|
+
out[3] = d;
|
|
124
|
+
out[4] = tx;
|
|
125
|
+
out[5] = ty;
|
|
126
|
+
return out;
|
|
62
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Inverts a mat2d
|
|
130
|
+
*
|
|
131
|
+
* @param {mat2d} out the receiving matrix
|
|
132
|
+
* @param {ReadonlyMat2d} a the source matrix
|
|
133
|
+
* @returns {mat2d} out
|
|
134
|
+
*/
|
|
63
135
|
export function invert(out, a) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
out[1] = -ab * det;
|
|
79
|
-
out[2] = -ac * det;
|
|
80
|
-
out[3] = aa * det;
|
|
81
|
-
out[4] = (ac * aty - ad * atx) * det;
|
|
82
|
-
out[5] = (ab * atx - aa * aty) * det;
|
|
83
|
-
return out;
|
|
136
|
+
let aa = a[0], ab = a[1], ac = a[2], ad = a[3];
|
|
137
|
+
let atx = a[4], aty = a[5];
|
|
138
|
+
let det = aa * ad - ab * ac;
|
|
139
|
+
if (!det) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
det = 1.0 / det;
|
|
143
|
+
out[0] = ad * det;
|
|
144
|
+
out[1] = -ab * det;
|
|
145
|
+
out[2] = -ac * det;
|
|
146
|
+
out[3] = aa * det;
|
|
147
|
+
out[4] = (ac * aty - ad * atx) * det;
|
|
148
|
+
out[5] = (ab * atx - aa * aty) * det;
|
|
149
|
+
return out;
|
|
84
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Calculates the determinant of a mat2d
|
|
153
|
+
*
|
|
154
|
+
* @param {ReadonlyMat2d} a the source matrix
|
|
155
|
+
* @returns {Number} determinant of a
|
|
156
|
+
*/
|
|
85
157
|
export function determinant(a) {
|
|
86
|
-
|
|
158
|
+
return a[0] * a[3] - a[1] * a[2];
|
|
87
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Multiplies two mat2d's
|
|
162
|
+
*
|
|
163
|
+
* @param {mat2d} out the receiving matrix
|
|
164
|
+
* @param {ReadonlyMat2d} a the first operand
|
|
165
|
+
* @param {ReadonlyMat2d} b the second operand
|
|
166
|
+
* @returns {mat2d} out
|
|
167
|
+
*/
|
|
88
168
|
export function multiply(out, a, b) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
b3 = b[3],
|
|
99
|
-
b4 = b[4],
|
|
100
|
-
b5 = b[5];
|
|
101
|
-
out[0] = a0 * b0 + a2 * b1;
|
|
102
|
-
out[1] = a1 * b0 + a3 * b1;
|
|
103
|
-
out[2] = a0 * b2 + a2 * b3;
|
|
104
|
-
out[3] = a1 * b2 + a3 * b3;
|
|
105
|
-
out[4] = a0 * b4 + a2 * b5 + a4;
|
|
106
|
-
out[5] = a1 * b4 + a3 * b5 + a5;
|
|
107
|
-
return out;
|
|
169
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
|
|
170
|
+
let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
|
|
171
|
+
out[0] = a0 * b0 + a2 * b1;
|
|
172
|
+
out[1] = a1 * b0 + a3 * b1;
|
|
173
|
+
out[2] = a0 * b2 + a2 * b3;
|
|
174
|
+
out[3] = a1 * b2 + a3 * b3;
|
|
175
|
+
out[4] = a0 * b4 + a2 * b5 + a4;
|
|
176
|
+
out[5] = a1 * b4 + a3 * b5 + a5;
|
|
177
|
+
return out;
|
|
108
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Rotates a mat2d by the given angle
|
|
181
|
+
*
|
|
182
|
+
* @param {mat2d} out the receiving matrix
|
|
183
|
+
* @param {ReadonlyMat2d} a the matrix to rotate
|
|
184
|
+
* @param {Number} rad the angle to rotate the matrix by
|
|
185
|
+
* @returns {mat2d} out
|
|
186
|
+
*/
|
|
109
187
|
export function rotate(out, a, rad) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
out[2] = a0 * -s + a2 * c;
|
|
121
|
-
out[3] = a1 * -s + a3 * c;
|
|
122
|
-
out[4] = a4;
|
|
123
|
-
out[5] = a5;
|
|
124
|
-
return out;
|
|
188
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
|
|
189
|
+
let s = Math.sin(rad);
|
|
190
|
+
let c = Math.cos(rad);
|
|
191
|
+
out[0] = a0 * c + a2 * s;
|
|
192
|
+
out[1] = a1 * c + a3 * s;
|
|
193
|
+
out[2] = a0 * -s + a2 * c;
|
|
194
|
+
out[3] = a1 * -s + a3 * c;
|
|
195
|
+
out[4] = a4;
|
|
196
|
+
out[5] = a5;
|
|
197
|
+
return out;
|
|
125
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Scales the mat2d by the dimensions in the given vec2
|
|
201
|
+
*
|
|
202
|
+
* @param {mat2d} out the receiving matrix
|
|
203
|
+
* @param {ReadonlyMat2d} a the matrix to translate
|
|
204
|
+
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
|
|
205
|
+
* @returns {mat2d} out
|
|
206
|
+
**/
|
|
126
207
|
export function scale(out, a, v) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
out[1] = a1 * v0;
|
|
137
|
-
out[2] = a2 * v1;
|
|
138
|
-
out[3] = a3 * v1;
|
|
139
|
-
out[4] = a4;
|
|
140
|
-
out[5] = a5;
|
|
141
|
-
return out;
|
|
208
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
|
|
209
|
+
let v0 = v[0], v1 = v[1];
|
|
210
|
+
out[0] = a0 * v0;
|
|
211
|
+
out[1] = a1 * v0;
|
|
212
|
+
out[2] = a2 * v1;
|
|
213
|
+
out[3] = a3 * v1;
|
|
214
|
+
out[4] = a4;
|
|
215
|
+
out[5] = a5;
|
|
216
|
+
return out;
|
|
142
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Translates the mat2d by the dimensions in the given vec2
|
|
220
|
+
*
|
|
221
|
+
* @param {mat2d} out the receiving matrix
|
|
222
|
+
* @param {ReadonlyMat2d} a the matrix to translate
|
|
223
|
+
* @param {ReadonlyVec2} v the vec2 to translate the matrix by
|
|
224
|
+
* @returns {mat2d} out
|
|
225
|
+
**/
|
|
143
226
|
export function translate(out, a, v) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
out[1] = a1;
|
|
154
|
-
out[2] = a2;
|
|
155
|
-
out[3] = a3;
|
|
156
|
-
out[4] = a0 * v0 + a2 * v1 + a4;
|
|
157
|
-
out[5] = a1 * v0 + a3 * v1 + a5;
|
|
158
|
-
return out;
|
|
227
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
|
|
228
|
+
let v0 = v[0], v1 = v[1];
|
|
229
|
+
out[0] = a0;
|
|
230
|
+
out[1] = a1;
|
|
231
|
+
out[2] = a2;
|
|
232
|
+
out[3] = a3;
|
|
233
|
+
out[4] = a0 * v0 + a2 * v1 + a4;
|
|
234
|
+
out[5] = a1 * v0 + a3 * v1 + a5;
|
|
235
|
+
return out;
|
|
159
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Creates a matrix from a given angle
|
|
239
|
+
* This is equivalent to (but much faster than):
|
|
240
|
+
*
|
|
241
|
+
* mat2d.identity(dest);
|
|
242
|
+
* mat2d.rotate(dest, dest, rad);
|
|
243
|
+
*
|
|
244
|
+
* @param {mat2d} out mat2d receiving operation result
|
|
245
|
+
* @param {Number} rad the angle to rotate the matrix by
|
|
246
|
+
* @returns {mat2d} out
|
|
247
|
+
*/
|
|
160
248
|
export function fromRotation(out, rad) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return out;
|
|
249
|
+
let s = Math.sin(rad), c = Math.cos(rad);
|
|
250
|
+
out[0] = c;
|
|
251
|
+
out[1] = s;
|
|
252
|
+
out[2] = -s;
|
|
253
|
+
out[3] = c;
|
|
254
|
+
out[4] = 0;
|
|
255
|
+
out[5] = 0;
|
|
256
|
+
return out;
|
|
170
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Creates a matrix from a vector scaling
|
|
260
|
+
* This is equivalent to (but much faster than):
|
|
261
|
+
*
|
|
262
|
+
* mat2d.identity(dest);
|
|
263
|
+
* mat2d.scale(dest, dest, vec);
|
|
264
|
+
*
|
|
265
|
+
* @param {mat2d} out mat2d receiving operation result
|
|
266
|
+
* @param {ReadonlyVec2} v Scaling vector
|
|
267
|
+
* @returns {mat2d} out
|
|
268
|
+
*/
|
|
171
269
|
export function fromScaling(out, v) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
270
|
+
out[0] = v[0];
|
|
271
|
+
out[1] = 0;
|
|
272
|
+
out[2] = 0;
|
|
273
|
+
out[3] = v[1];
|
|
274
|
+
out[4] = 0;
|
|
275
|
+
out[5] = 0;
|
|
276
|
+
return out;
|
|
179
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Creates a matrix from a vector translation
|
|
280
|
+
* This is equivalent to (but much faster than):
|
|
281
|
+
*
|
|
282
|
+
* mat2d.identity(dest);
|
|
283
|
+
* mat2d.translate(dest, dest, vec);
|
|
284
|
+
*
|
|
285
|
+
* @param {mat2d} out mat2d receiving operation result
|
|
286
|
+
* @param {ReadonlyVec2} v Translation vector
|
|
287
|
+
* @returns {mat2d} out
|
|
288
|
+
*/
|
|
180
289
|
export function fromTranslation(out, v) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
290
|
+
out[0] = 1;
|
|
291
|
+
out[1] = 0;
|
|
292
|
+
out[2] = 0;
|
|
293
|
+
out[3] = 1;
|
|
294
|
+
out[4] = v[0];
|
|
295
|
+
out[5] = v[1];
|
|
296
|
+
return out;
|
|
188
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns a string representation of a mat2d
|
|
300
|
+
*
|
|
301
|
+
* @param {ReadonlyMat2d} a matrix to represent as a string
|
|
302
|
+
* @returns {String} string representation of the matrix
|
|
303
|
+
*/
|
|
189
304
|
export function str(a) {
|
|
190
|
-
|
|
305
|
+
return ('mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ')');
|
|
191
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns Frobenius norm of a mat2d
|
|
309
|
+
*
|
|
310
|
+
* @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of
|
|
311
|
+
* @returns {Number} Frobenius norm
|
|
312
|
+
*/
|
|
192
313
|
export function frob(a) {
|
|
193
|
-
|
|
314
|
+
return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + 1);
|
|
194
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Adds two mat2d's
|
|
318
|
+
*
|
|
319
|
+
* @param {mat2d} out the receiving matrix
|
|
320
|
+
* @param {ReadonlyMat2d} a the first operand
|
|
321
|
+
* @param {ReadonlyMat2d} b the second operand
|
|
322
|
+
* @returns {mat2d} out
|
|
323
|
+
*/
|
|
195
324
|
export function add(out, a, b) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
325
|
+
out[0] = a[0] + b[0];
|
|
326
|
+
out[1] = a[1] + b[1];
|
|
327
|
+
out[2] = a[2] + b[2];
|
|
328
|
+
out[3] = a[3] + b[3];
|
|
329
|
+
out[4] = a[4] + b[4];
|
|
330
|
+
out[5] = a[5] + b[5];
|
|
331
|
+
return out;
|
|
203
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Subtracts matrix b from matrix a
|
|
335
|
+
*
|
|
336
|
+
* @param {mat2d} out the receiving matrix
|
|
337
|
+
* @param {ReadonlyMat2d} a the first operand
|
|
338
|
+
* @param {ReadonlyMat2d} b the second operand
|
|
339
|
+
* @returns {mat2d} out
|
|
340
|
+
*/
|
|
204
341
|
export function subtract(out, a, b) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
342
|
+
out[0] = a[0] - b[0];
|
|
343
|
+
out[1] = a[1] - b[1];
|
|
344
|
+
out[2] = a[2] - b[2];
|
|
345
|
+
out[3] = a[3] - b[3];
|
|
346
|
+
out[4] = a[4] - b[4];
|
|
347
|
+
out[5] = a[5] - b[5];
|
|
348
|
+
return out;
|
|
212
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Multiply each element of the matrix by a scalar.
|
|
352
|
+
*
|
|
353
|
+
* @param {mat2d} out the receiving matrix
|
|
354
|
+
* @param {ReadonlyMat2d} a the matrix to scale
|
|
355
|
+
* @param {Number} b amount to scale the matrix's elements by
|
|
356
|
+
* @returns {mat2d} out
|
|
357
|
+
*/
|
|
213
358
|
export function multiplyScalar(out, a, b) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
359
|
+
out[0] = a[0] * b;
|
|
360
|
+
out[1] = a[1] * b;
|
|
361
|
+
out[2] = a[2] * b;
|
|
362
|
+
out[3] = a[3] * b;
|
|
363
|
+
out[4] = a[4] * b;
|
|
364
|
+
out[5] = a[5] * b;
|
|
365
|
+
return out;
|
|
221
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Adds two mat2d's after multiplying each element of the second operand by a scalar value.
|
|
369
|
+
*
|
|
370
|
+
* @param {mat2d} out the receiving vector
|
|
371
|
+
* @param {ReadonlyMat2d} a the first operand
|
|
372
|
+
* @param {ReadonlyMat2d} b the second operand
|
|
373
|
+
* @param {Number} scale the amount to scale b's elements by before adding
|
|
374
|
+
* @returns {mat2d} out
|
|
375
|
+
*/
|
|
222
376
|
export function multiplyScalarAndAdd(out, a, b, scale) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
377
|
+
out[0] = a[0] + b[0] * scale;
|
|
378
|
+
out[1] = a[1] + b[1] * scale;
|
|
379
|
+
out[2] = a[2] + b[2] * scale;
|
|
380
|
+
out[3] = a[3] + b[3] * scale;
|
|
381
|
+
out[4] = a[4] + b[4] * scale;
|
|
382
|
+
out[5] = a[5] + b[5] * scale;
|
|
383
|
+
return out;
|
|
230
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
387
|
+
*
|
|
388
|
+
* @param {ReadonlyMat2d} a The first matrix.
|
|
389
|
+
* @param {ReadonlyMat2d} b The second matrix.
|
|
390
|
+
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
391
|
+
*/
|
|
231
392
|
export function exactEquals(a, b) {
|
|
232
|
-
|
|
393
|
+
return (a[0] === b[0] &&
|
|
394
|
+
a[1] === b[1] &&
|
|
395
|
+
a[2] === b[2] &&
|
|
396
|
+
a[3] === b[3] &&
|
|
397
|
+
a[4] === b[4] &&
|
|
398
|
+
a[5] === b[5]);
|
|
233
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
402
|
+
*
|
|
403
|
+
* @param {ReadonlyMat2d} a The first matrix.
|
|
404
|
+
* @param {ReadonlyMat2d} b The second matrix.
|
|
405
|
+
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
406
|
+
*/
|
|
234
407
|
export function equals(a, b) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
b2 = b[2],
|
|
244
|
-
b3 = b[3],
|
|
245
|
-
b4 = b[4],
|
|
246
|
-
b5 = b[5];
|
|
247
|
-
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)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5));
|
|
408
|
+
let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];
|
|
409
|
+
let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
|
|
410
|
+
return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
|
|
411
|
+
Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
|
|
412
|
+
Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
|
|
413
|
+
Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&
|
|
414
|
+
Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&
|
|
415
|
+
Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)));
|
|
248
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Alias for {@link mat2d.multiply}
|
|
419
|
+
* @function
|
|
420
|
+
*/
|
|
249
421
|
export const mul = multiply;
|
|
422
|
+
/**
|
|
423
|
+
* Alias for {@link mat2d.subtract}
|
|
424
|
+
* @function
|
|
425
|
+
*/
|
|
250
426
|
export const sub = subtract;
|
|
251
|
-
//# sourceMappingURL=mat2d.js.map
|