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