@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.
Files changed (124) hide show
  1. package/dist/classes/base/math-array.d.ts +1 -2
  2. package/dist/classes/base/math-array.js +220 -266
  3. package/dist/classes/base/matrix.d.ts +1 -2
  4. package/dist/classes/base/matrix.js +52 -53
  5. package/dist/classes/base/vector.d.ts +1 -2
  6. package/dist/classes/base/vector.js +121 -135
  7. package/dist/classes/euler.d.ts +2 -3
  8. package/dist/classes/euler.js +462 -533
  9. package/dist/classes/matrix3.d.ts +2 -3
  10. package/dist/classes/matrix3.js +185 -190
  11. package/dist/classes/matrix4.d.ts +1 -2
  12. package/dist/classes/matrix4.js +516 -452
  13. package/dist/classes/pose.d.ts +4 -5
  14. package/dist/classes/pose.js +104 -119
  15. package/dist/classes/quaternion.d.ts +1 -2
  16. package/dist/classes/quaternion.js +257 -233
  17. package/dist/classes/spherical-coordinates.d.ts +3 -4
  18. package/dist/classes/spherical-coordinates.js +138 -147
  19. package/dist/classes/vector2.d.ts +1 -2
  20. package/dist/classes/vector2.js +101 -85
  21. package/dist/classes/vector3.d.ts +1 -2
  22. package/dist/classes/vector3.js +125 -136
  23. package/dist/classes/vector4.d.ts +2 -3
  24. package/dist/classes/vector4.js +106 -114
  25. package/dist/gl-matrix/common.d.ts +0 -1
  26. package/dist/gl-matrix/common.js +38 -6
  27. package/dist/gl-matrix/mat3.d.ts +0 -1
  28. package/dist/gl-matrix/mat3.js +699 -425
  29. package/dist/gl-matrix/mat4.d.ts +0 -1
  30. package/dist/gl-matrix/mat4.js +1879 -1339
  31. package/dist/gl-matrix/quat.d.ts +0 -1
  32. package/dist/gl-matrix/quat.js +655 -257
  33. package/dist/gl-matrix/vec2.d.ts +0 -1
  34. package/dist/gl-matrix/vec2.js +529 -212
  35. package/dist/gl-matrix/vec3.d.ts +0 -1
  36. package/dist/gl-matrix/vec3.js +703 -335
  37. package/dist/gl-matrix/vec4.d.ts +0 -1
  38. package/dist/gl-matrix/vec4.js +579 -293
  39. package/dist/gl-matrix/wip/index.d.ts +3 -4
  40. package/dist/gl-matrix/wip/index.js +2 -1
  41. package/dist/gl-matrix/wip/mat2.d.ts +0 -1
  42. package/dist/gl-matrix/wip/mat2.js +333 -157
  43. package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
  44. package/dist/gl-matrix/wip/mat2d.js +377 -202
  45. package/dist/gl-matrix/wip/quat2.d.ts +0 -1
  46. package/dist/gl-matrix/wip/quat2.js +647 -409
  47. package/dist/index.cjs +60 -100
  48. package/dist/index.cjs.map +7 -0
  49. package/dist/index.d.ts +21 -22
  50. package/dist/index.js +23 -16
  51. package/dist/lib/assert.d.ts +0 -1
  52. package/dist/lib/assert.js +3 -4
  53. package/dist/lib/common.d.ts +2 -3
  54. package/dist/lib/common.js +163 -134
  55. package/dist/lib/gl-matrix-extras.d.ts +0 -1
  56. package/dist/lib/gl-matrix-extras.js +39 -36
  57. package/dist/lib/math-utils.d.ts +0 -1
  58. package/dist/lib/math-utils.js +2 -1
  59. package/dist/lib/validators.d.ts +0 -1
  60. package/dist/lib/validators.js +22 -25
  61. package/package.json +5 -6
  62. package/src/classes/matrix3.ts +1 -1
  63. package/dist/classes/base/math-array.d.ts.map +0 -1
  64. package/dist/classes/base/math-array.js.map +0 -1
  65. package/dist/classes/base/matrix.d.ts.map +0 -1
  66. package/dist/classes/base/matrix.js.map +0 -1
  67. package/dist/classes/base/vector.d.ts.map +0 -1
  68. package/dist/classes/base/vector.js.map +0 -1
  69. package/dist/classes/euler.d.ts.map +0 -1
  70. package/dist/classes/euler.js.map +0 -1
  71. package/dist/classes/matrix3.d.ts.map +0 -1
  72. package/dist/classes/matrix3.js.map +0 -1
  73. package/dist/classes/matrix4.d.ts.map +0 -1
  74. package/dist/classes/matrix4.js.map +0 -1
  75. package/dist/classes/pose.d.ts.map +0 -1
  76. package/dist/classes/pose.js.map +0 -1
  77. package/dist/classes/quaternion.d.ts.map +0 -1
  78. package/dist/classes/quaternion.js.map +0 -1
  79. package/dist/classes/spherical-coordinates.d.ts.map +0 -1
  80. package/dist/classes/spherical-coordinates.js.map +0 -1
  81. package/dist/classes/vector2.d.ts.map +0 -1
  82. package/dist/classes/vector2.js.map +0 -1
  83. package/dist/classes/vector3.d.ts.map +0 -1
  84. package/dist/classes/vector3.js.map +0 -1
  85. package/dist/classes/vector4.d.ts.map +0 -1
  86. package/dist/classes/vector4.js.map +0 -1
  87. package/dist/gl-matrix/common.d.ts.map +0 -1
  88. package/dist/gl-matrix/common.js.map +0 -1
  89. package/dist/gl-matrix/mat3.d.ts.map +0 -1
  90. package/dist/gl-matrix/mat3.js.map +0 -1
  91. package/dist/gl-matrix/mat4.d.ts.map +0 -1
  92. package/dist/gl-matrix/mat4.js.map +0 -1
  93. package/dist/gl-matrix/quat.d.ts.map +0 -1
  94. package/dist/gl-matrix/quat.js.map +0 -1
  95. package/dist/gl-matrix/vec2.d.ts.map +0 -1
  96. package/dist/gl-matrix/vec2.js.map +0 -1
  97. package/dist/gl-matrix/vec3.d.ts.map +0 -1
  98. package/dist/gl-matrix/vec3.js.map +0 -1
  99. package/dist/gl-matrix/vec4.d.ts.map +0 -1
  100. package/dist/gl-matrix/vec4.js.map +0 -1
  101. package/dist/gl-matrix/wip/index.d.ts.map +0 -1
  102. package/dist/gl-matrix/wip/index.js.map +0 -1
  103. package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
  104. package/dist/gl-matrix/wip/mat2.js.map +0 -1
  105. package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
  106. package/dist/gl-matrix/wip/mat2d.js.map +0 -1
  107. package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
  108. package/dist/gl-matrix/wip/quat2.js.map +0 -1
  109. package/dist/gl-matrix/wip/types.d.js +0 -2
  110. package/dist/gl-matrix/wip/types.d.js.map +0 -1
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/lib/assert.d.ts.map +0 -1
  114. package/dist/lib/assert.js.map +0 -1
  115. package/dist/lib/common.d.ts.map +0 -1
  116. package/dist/lib/common.js.map +0 -1
  117. package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
  118. package/dist/lib/gl-matrix-extras.js.map +0 -1
  119. package/dist/lib/gl-matrix.d.js +0 -2
  120. package/dist/lib/gl-matrix.d.js.map +0 -1
  121. package/dist/lib/math-utils.d.ts.map +0 -1
  122. package/dist/lib/math-utils.js.map +0 -1
  123. package/dist/lib/validators.d.ts.map +0 -1
  124. 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
- let out = new glMatrix.ARRAY_TYPE(6);
4
-
5
- if (glMatrix.ARRAY_TYPE != Float32Array) {
6
- out[1] = 0;
7
- out[2] = 0;
8
- out[4] = 0;
9
- out[5] = 0;
10
- }
11
-
12
- out[0] = 1;
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
- let out = new glMatrix.ARRAY_TYPE(6);
18
- out[0] = a[0];
19
- out[1] = a[1];
20
- out[2] = a[2];
21
- out[3] = a[3];
22
- out[4] = a[4];
23
- out[5] = a[5];
24
- return out;
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
- out[0] = a[0];
28
- out[1] = a[1];
29
- out[2] = a[2];
30
- out[3] = a[3];
31
- out[4] = a[4];
32
- out[5] = a[5];
33
- return out;
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
- out[0] = 1;
37
- out[1] = 0;
38
- out[2] = 0;
39
- out[3] = 1;
40
- out[4] = 0;
41
- out[5] = 0;
42
- return out;
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
- let out = new glMatrix.ARRAY_TYPE(6);
46
- out[0] = a;
47
- out[1] = b;
48
- out[2] = c;
49
- out[3] = d;
50
- out[4] = tx;
51
- out[5] = ty;
52
- return out;
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
- out[0] = a;
56
- out[1] = b;
57
- out[2] = c;
58
- out[3] = d;
59
- out[4] = tx;
60
- out[5] = ty;
61
- return out;
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
- let aa = a[0],
65
- ab = a[1],
66
- ac = a[2],
67
- ad = a[3];
68
- let atx = a[4],
69
- aty = a[5];
70
- let det = aa * ad - ab * ac;
71
-
72
- if (!det) {
73
- return null;
74
- }
75
-
76
- det = 1.0 / det;
77
- out[0] = ad * det;
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
- return a[0] * a[3] - a[1] * a[2];
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
- let a0 = a[0],
90
- a1 = a[1],
91
- a2 = a[2],
92
- a3 = a[3],
93
- a4 = a[4],
94
- a5 = a[5];
95
- let b0 = b[0],
96
- b1 = b[1],
97
- b2 = b[2],
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
- let a0 = a[0],
111
- a1 = a[1],
112
- a2 = a[2],
113
- a3 = a[3],
114
- a4 = a[4],
115
- a5 = a[5];
116
- let s = Math.sin(rad);
117
- let c = Math.cos(rad);
118
- out[0] = a0 * c + a2 * s;
119
- out[1] = a1 * c + a3 * s;
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
- let a0 = a[0],
128
- a1 = a[1],
129
- a2 = a[2],
130
- a3 = a[3],
131
- a4 = a[4],
132
- a5 = a[5];
133
- let v0 = v[0],
134
- v1 = v[1];
135
- out[0] = a0 * v0;
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
- let a0 = a[0],
145
- a1 = a[1],
146
- a2 = a[2],
147
- a3 = a[3],
148
- a4 = a[4],
149
- a5 = a[5];
150
- let v0 = v[0],
151
- v1 = v[1];
152
- out[0] = a0;
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
- let s = Math.sin(rad),
162
- c = Math.cos(rad);
163
- out[0] = c;
164
- out[1] = s;
165
- out[2] = -s;
166
- out[3] = c;
167
- out[4] = 0;
168
- out[5] = 0;
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
- out[0] = v[0];
173
- out[1] = 0;
174
- out[2] = 0;
175
- out[3] = v[1];
176
- out[4] = 0;
177
- out[5] = 0;
178
- return out;
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
- out[0] = 1;
182
- out[1] = 0;
183
- out[2] = 0;
184
- out[3] = 1;
185
- out[4] = v[0];
186
- out[5] = v[1];
187
- return out;
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
- return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ')';
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
- 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);
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
- out[0] = a[0] + b[0];
197
- out[1] = a[1] + b[1];
198
- out[2] = a[2] + b[2];
199
- out[3] = a[3] + b[3];
200
- out[4] = a[4] + b[4];
201
- out[5] = a[5] + b[5];
202
- return out;
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
- out[0] = a[0] - b[0];
206
- out[1] = a[1] - b[1];
207
- out[2] = a[2] - b[2];
208
- out[3] = a[3] - b[3];
209
- out[4] = a[4] - b[4];
210
- out[5] = a[5] - b[5];
211
- return out;
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
- out[0] = a[0] * b;
215
- out[1] = a[1] * b;
216
- out[2] = a[2] * b;
217
- out[3] = a[3] * b;
218
- out[4] = a[4] * b;
219
- out[5] = a[5] * b;
220
- return out;
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
- out[0] = a[0] + b[0] * scale;
224
- out[1] = a[1] + b[1] * scale;
225
- out[2] = a[2] + b[2] * scale;
226
- out[3] = a[3] + b[3] * scale;
227
- out[4] = a[4] + b[4] * scale;
228
- out[5] = a[5] + b[5] * scale;
229
- return out;
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
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];
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
- let a0 = a[0],
236
- a1 = a[1],
237
- a2 = a[2],
238
- a3 = a[3],
239
- a4 = a[4],
240
- a5 = a[5];
241
- let b0 = b[0],
242
- b1 = b[1],
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
@@ -349,4 +349,3 @@ export declare function exactEquals(a: any, b: any): boolean;
349
349
  * @returns {Boolean} true if the dual quats are equal, false otherwise.
350
350
  */
351
351
  export declare function equals(a: any, b: any): boolean;
352
- //# sourceMappingURL=quat2.d.ts.map