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