@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,5 +1,4 @@
1
- import * as mat2 from "./mat2.js";
2
- import * as mat2d from "./mat2d.js";
3
- import * as quat2 from "./quat2.js";
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
@@ -226,4 +226,3 @@ export function mul(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
226
226
  * @returns {mat2} out
227
227
  */
228
228
  export function sub(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
229
- //# sourceMappingURL=mat2.d.ts.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
- let out = new glMatrix.ARRAY_TYPE(4);
4
-
5
- if (glMatrix.ARRAY_TYPE != Float32Array) {
6
- out[1] = 0;
7
- out[2] = 0;
8
- }
9
-
10
- out[0] = 1;
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
- let out = new glMatrix.ARRAY_TYPE(4);
16
- out[0] = a[0];
17
- out[1] = a[1];
18
- out[2] = a[2];
19
- out[3] = a[3];
20
- return out;
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
- out[0] = a[0];
24
- out[1] = a[1];
25
- out[2] = a[2];
26
- out[3] = a[3];
27
- return out;
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
- out[0] = 1;
31
- out[1] = 0;
32
- out[2] = 0;
33
- out[3] = 1;
34
- return out;
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
- let out = new glMatrix.ARRAY_TYPE(4);
38
- out[0] = m00;
39
- out[1] = m01;
40
- out[2] = m10;
41
- out[3] = m11;
42
- return out;
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
- out[0] = m00;
46
- out[1] = m01;
47
- out[2] = m10;
48
- out[3] = m11;
49
- return out;
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
- if (out === a) {
53
- let a1 = a[1];
54
- out[1] = a[2];
55
- out[2] = a1;
56
- } else {
57
- out[0] = a[0];
58
- out[1] = a[2];
59
- out[2] = a[1];
60
- out[3] = a[3];
61
- }
62
-
63
- return out;
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
- let a0 = a[0],
67
- a1 = a[1],
68
- a2 = a[2],
69
- a3 = a[3];
70
- let det = a0 * a3 - a2 * a1;
71
-
72
- if (!det) {
73
- return null;
74
- }
75
-
76
- det = 1.0 / det;
77
- out[0] = a3 * det;
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
- let a0 = a[0];
85
- out[0] = a[3];
86
- out[1] = -a[1];
87
- out[2] = -a[2];
88
- out[3] = a0;
89
- return out;
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
- return a[0] * a[3] - a[2] * a[1];
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
- let a0 = a[0],
96
- a1 = a[1],
97
- a2 = a[2],
98
- a3 = a[3];
99
- let b0 = b[0],
100
- b1 = b[1],
101
- b2 = b[2],
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
- let a0 = a[0],
111
- a1 = a[1],
112
- a2 = a[2],
113
- a3 = a[3];
114
- let s = Math.sin(rad);
115
- let c = Math.cos(rad);
116
- out[0] = a0 * c + a2 * s;
117
- out[1] = a1 * c + a3 * s;
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
- let a0 = a[0],
124
- a1 = a[1],
125
- a2 = a[2],
126
- a3 = a[3];
127
- let v0 = v[0],
128
- v1 = v[1];
129
- out[0] = a0 * v0;
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
- let s = Math.sin(rad);
137
- let c = Math.cos(rad);
138
- out[0] = c;
139
- out[1] = s;
140
- out[2] = -s;
141
- out[3] = c;
142
- return out;
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
- out[0] = v[0];
146
- out[1] = 0;
147
- out[2] = 0;
148
- out[3] = v[1];
149
- return out;
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
- return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
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
- return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]);
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
- L[2] = a[2] / a[0];
159
- U[0] = a[0];
160
- U[1] = a[1];
161
- U[3] = a[3] - L[2] * U[1];
162
- return [L, D, U];
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
- out[0] = a[0] + b[0];
166
- out[1] = a[1] + b[1];
167
- out[2] = a[2] + b[2];
168
- out[3] = a[3] + b[3];
169
- return out;
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
- out[0] = a[0] - b[0];
173
- out[1] = a[1] - b[1];
174
- out[2] = a[2] - b[2];
175
- out[3] = a[3] - b[3];
176
- return out;
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
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
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
- let a0 = a[0],
183
- a1 = a[1],
184
- a2 = a[2],
185
- a3 = a[3];
186
- let b0 = b[0],
187
- b1 = b[1],
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
- out[0] = a[0] * b;
194
- out[1] = a[1] * b;
195
- out[2] = a[2] * b;
196
- out[3] = a[3] * b;
197
- return out;
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
- out[0] = a[0] + b[0] * scale;
201
- out[1] = a[1] + b[1] * scale;
202
- out[2] = a[2] + b[2] * scale;
203
- out[3] = a[3] + b[3] * scale;
204
- return out;
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
@@ -241,4 +241,3 @@ export function mul(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
241
241
  * @returns {mat2d} out
242
242
  */
243
243
  export function sub(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
244
- //# sourceMappingURL=mat2d.d.ts.map