@mlightcad/geometry-engine 1.0.0

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 (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/geometry-engine.js +10186 -0
  4. package/dist/geometry-engine.umd.cjs +4 -0
  5. package/lib/geometry/AcGeArea2d.d.ts +61 -0
  6. package/lib/geometry/AcGeArea2d.d.ts.map +1 -0
  7. package/lib/geometry/AcGeArea2d.js +174 -0
  8. package/lib/geometry/AcGeArea2d.js.map +1 -0
  9. package/lib/geometry/AcGeCircArc2d.d.ts +108 -0
  10. package/lib/geometry/AcGeCircArc2d.d.ts.map +1 -0
  11. package/lib/geometry/AcGeCircArc2d.js +412 -0
  12. package/lib/geometry/AcGeCircArc2d.js.map +1 -0
  13. package/lib/geometry/AcGeCircArc3d.d.ts +138 -0
  14. package/lib/geometry/AcGeCircArc3d.d.ts.map +1 -0
  15. package/lib/geometry/AcGeCircArc3d.js +447 -0
  16. package/lib/geometry/AcGeCircArc3d.js.map +1 -0
  17. package/lib/geometry/AcGeCurve2d.d.ts +85 -0
  18. package/lib/geometry/AcGeCurve2d.d.ts.map +1 -0
  19. package/lib/geometry/AcGeCurve2d.js +213 -0
  20. package/lib/geometry/AcGeCurve2d.js.map +1 -0
  21. package/lib/geometry/AcGeCurve3d.d.ts +27 -0
  22. package/lib/geometry/AcGeCurve3d.d.ts.map +1 -0
  23. package/lib/geometry/AcGeCurve3d.js +29 -0
  24. package/lib/geometry/AcGeCurve3d.js.map +1 -0
  25. package/lib/geometry/AcGeEllipseArc2d.d.ts +105 -0
  26. package/lib/geometry/AcGeEllipseArc2d.d.ts.map +1 -0
  27. package/lib/geometry/AcGeEllipseArc2d.js +292 -0
  28. package/lib/geometry/AcGeEllipseArc2d.js.map +1 -0
  29. package/lib/geometry/AcGeEllipseArc3d.d.ts +141 -0
  30. package/lib/geometry/AcGeEllipseArc3d.d.ts.map +1 -0
  31. package/lib/geometry/AcGeEllipseArc3d.js +442 -0
  32. package/lib/geometry/AcGeEllipseArc3d.js.map +1 -0
  33. package/lib/geometry/AcGeLine2d.d.ts +56 -0
  34. package/lib/geometry/AcGeLine2d.d.ts.map +1 -0
  35. package/lib/geometry/AcGeLine2d.js +125 -0
  36. package/lib/geometry/AcGeLine2d.js.map +1 -0
  37. package/lib/geometry/AcGeLine3d.d.ts +134 -0
  38. package/lib/geometry/AcGeLine3d.d.ts.map +1 -0
  39. package/lib/geometry/AcGeLine3d.js +291 -0
  40. package/lib/geometry/AcGeLine3d.js.map +1 -0
  41. package/lib/geometry/AcGeLoop2d.d.ts +59 -0
  42. package/lib/geometry/AcGeLoop2d.d.ts.map +1 -0
  43. package/lib/geometry/AcGeLoop2d.js +141 -0
  44. package/lib/geometry/AcGeLoop2d.js.map +1 -0
  45. package/lib/geometry/AcGePolyline2d.d.ts +90 -0
  46. package/lib/geometry/AcGePolyline2d.d.ts.map +1 -0
  47. package/lib/geometry/AcGePolyline2d.js +224 -0
  48. package/lib/geometry/AcGePolyline2d.js.map +1 -0
  49. package/lib/geometry/AcGeShape.d.ts +12 -0
  50. package/lib/geometry/AcGeShape.d.ts.map +1 -0
  51. package/lib/geometry/AcGeShape.js +22 -0
  52. package/lib/geometry/AcGeShape.js.map +1 -0
  53. package/lib/geometry/AcGeShape2d.d.ts +31 -0
  54. package/lib/geometry/AcGeShape2d.d.ts.map +1 -0
  55. package/lib/geometry/AcGeShape2d.js +51 -0
  56. package/lib/geometry/AcGeShape2d.js.map +1 -0
  57. package/lib/geometry/AcGeShape3d.d.ts +33 -0
  58. package/lib/geometry/AcGeShape3d.d.ts.map +1 -0
  59. package/lib/geometry/AcGeShape3d.js +52 -0
  60. package/lib/geometry/AcGeShape3d.js.map +1 -0
  61. package/lib/geometry/AcGeSpline3d.d.ts +77 -0
  62. package/lib/geometry/AcGeSpline3d.d.ts.map +1 -0
  63. package/lib/geometry/AcGeSpline3d.js +221 -0
  64. package/lib/geometry/AcGeSpline3d.js.map +1 -0
  65. package/lib/geometry/index.d.ts +13 -0
  66. package/lib/geometry/index.d.ts.map +1 -0
  67. package/lib/geometry/index.js +13 -0
  68. package/lib/geometry/index.js.map +1 -0
  69. package/lib/index.d.ts +4 -0
  70. package/lib/index.d.ts.map +1 -0
  71. package/lib/index.js +4 -0
  72. package/lib/index.js.map +1 -0
  73. package/lib/math/AcGeBox2d.d.ts +173 -0
  74. package/lib/math/AcGeBox2d.d.ts.map +1 -0
  75. package/lib/math/AcGeBox2d.js +289 -0
  76. package/lib/math/AcGeBox2d.js.map +1 -0
  77. package/lib/math/AcGeBox3d.d.ts +195 -0
  78. package/lib/math/AcGeBox3d.d.ts.map +1 -0
  79. package/lib/math/AcGeBox3d.js +378 -0
  80. package/lib/math/AcGeBox3d.js.map +1 -0
  81. package/lib/math/AcGeEuler.d.ts +133 -0
  82. package/lib/math/AcGeEuler.d.ts.map +1 -0
  83. package/lib/math/AcGeEuler.js +358 -0
  84. package/lib/math/AcGeEuler.js.map +1 -0
  85. package/lib/math/AcGeMatrix2d.d.ts +203 -0
  86. package/lib/math/AcGeMatrix2d.d.ts.map +1 -0
  87. package/lib/math/AcGeMatrix2d.js +393 -0
  88. package/lib/math/AcGeMatrix2d.js.map +1 -0
  89. package/lib/math/AcGeMatrix3d.d.ts +279 -0
  90. package/lib/math/AcGeMatrix3d.d.ts.map +1 -0
  91. package/lib/math/AcGeMatrix3d.js +1037 -0
  92. package/lib/math/AcGeMatrix3d.js.map +1 -0
  93. package/lib/math/AcGePlane.d.ts +131 -0
  94. package/lib/math/AcGePlane.d.ts.map +1 -0
  95. package/lib/math/AcGePlane.js +218 -0
  96. package/lib/math/AcGePlane.js.map +1 -0
  97. package/lib/math/AcGePoint.d.ts +4 -0
  98. package/lib/math/AcGePoint.d.ts.map +1 -0
  99. package/lib/math/AcGePoint.js +2 -0
  100. package/lib/math/AcGePoint.js.map +1 -0
  101. package/lib/math/AcGePoint2d.d.ts +17 -0
  102. package/lib/math/AcGePoint2d.d.ts.map +1 -0
  103. package/lib/math/AcGePoint2d.js +40 -0
  104. package/lib/math/AcGePoint2d.js.map +1 -0
  105. package/lib/math/AcGePoint3d.d.ts +18 -0
  106. package/lib/math/AcGePoint3d.d.ts.map +1 -0
  107. package/lib/math/AcGePoint3d.js +43 -0
  108. package/lib/math/AcGePoint3d.js.map +1 -0
  109. package/lib/math/AcGeQuaternion.d.ts +230 -0
  110. package/lib/math/AcGeQuaternion.d.ts.map +1 -0
  111. package/lib/math/AcGeQuaternion.js +666 -0
  112. package/lib/math/AcGeQuaternion.js.map +1 -0
  113. package/lib/math/AcGeVector.d.ts +9 -0
  114. package/lib/math/AcGeVector.d.ts.map +1 -0
  115. package/lib/math/AcGeVector.js +2 -0
  116. package/lib/math/AcGeVector.js.map +1 -0
  117. package/lib/math/AcGeVector2d.d.ts +361 -0
  118. package/lib/math/AcGeVector2d.d.ts.map +1 -0
  119. package/lib/math/AcGeVector2d.js +622 -0
  120. package/lib/math/AcGeVector2d.js.map +1 -0
  121. package/lib/math/AcGeVector3d.d.ts +493 -0
  122. package/lib/math/AcGeVector3d.d.ts.map +1 -0
  123. package/lib/math/AcGeVector3d.js +868 -0
  124. package/lib/math/AcGeVector3d.js.map +1 -0
  125. package/lib/math/index.d.ts +14 -0
  126. package/lib/math/index.d.ts.map +1 -0
  127. package/lib/math/index.js +14 -0
  128. package/lib/math/index.js.map +1 -0
  129. package/lib/util/AcGeConstants.d.ts +19 -0
  130. package/lib/util/AcGeConstants.d.ts.map +1 -0
  131. package/lib/util/AcGeConstants.js +25 -0
  132. package/lib/util/AcGeConstants.js.map +1 -0
  133. package/lib/util/AcGeGeometryUtil.d.ts +16 -0
  134. package/lib/util/AcGeGeometryUtil.d.ts.map +1 -0
  135. package/lib/util/AcGeGeometryUtil.js +56 -0
  136. package/lib/util/AcGeGeometryUtil.js.map +1 -0
  137. package/lib/util/AcGeMathUtil.d.ts +203 -0
  138. package/lib/util/AcGeMathUtil.d.ts.map +1 -0
  139. package/lib/util/AcGeMathUtil.js +585 -0
  140. package/lib/util/AcGeMathUtil.js.map +1 -0
  141. package/lib/util/AcGeTol.d.ts +91 -0
  142. package/lib/util/AcGeTol.d.ts.map +1 -0
  143. package/lib/util/AcGeTol.js +83 -0
  144. package/lib/util/AcGeTol.js.map +1 -0
  145. package/lib/util/index.d.ts +5 -0
  146. package/lib/util/index.d.ts.map +1 -0
  147. package/lib/util/index.js +5 -0
  148. package/lib/util/index.js.map +1 -0
  149. package/package.json +42 -0
@@ -0,0 +1,1037 @@
1
+ import { DEFAULT_TOL } from '../util';
2
+ import { AcGeVector3d } from './AcGeVector3d';
3
+ /**
4
+ * The class representing a 4x4 matrix.
5
+ */
6
+ var AcGeMatrix3d = /** @class */ (function () {
7
+ /**
8
+ * Create a 4x4 matrix with the given arguments in row-major order. If no arguments are provided,
9
+ * the constructor initializes the Matrix4 to the 4x4 identity matrix.
10
+ *
11
+ * @param n11 Input element in the first row and the first column
12
+ * @param n12 Input element in the first row and the second column
13
+ * @param n13 Input element in the first row and the third column
14
+ * @param n14 Input element in the first row and the forth column
15
+ * @param n21 Input element in the second row and the first column
16
+ * @param n22 Input element in the second row and the second column
17
+ * @param n23 Input element in the second row and the third column
18
+ * @param n24 Input element in the second row and the forth column
19
+ * @param n31 Input element in the third row and the first column
20
+ * @param n32 Input element in the third row and the second column
21
+ * @param n33 Input element in the third row and the third column
22
+ * @param n34 Input element in the third row and the forth column
23
+ * @param n41 Input element in the forth row and the first column
24
+ * @param n42 Input element in the forth row and the second column
25
+ * @param n43 Input element in the forth row and the third column
26
+ * @param n44 Input element in the forth row and the forth column
27
+ */
28
+ function AcGeMatrix3d(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
29
+ this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
30
+ if (n11 != null &&
31
+ n12 != null &&
32
+ n13 != null &&
33
+ n14 != null &&
34
+ n21 != null &&
35
+ n22 != null &&
36
+ n23 != null &&
37
+ n24 != null &&
38
+ n31 != null &&
39
+ n32 != null &&
40
+ n33 != null &&
41
+ n34 != null &&
42
+ n41 != null &&
43
+ n42 != null &&
44
+ n43 != null &&
45
+ n44 != null) {
46
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
47
+ }
48
+ }
49
+ /**
50
+ * Set the elements of this matrix to the supplied row-major values n11, n12, ... n44.
51
+ *
52
+ * @param n11 Input element in the first row and the first column
53
+ * @param n12 Input element in the first row and the second column
54
+ * @param n13 Input element in the first row and the third column
55
+ * @param n14 Input element in the first row and the forth column
56
+ * @param n21 Input element in the second row and the first column
57
+ * @param n22 Input element in the second row and the second column
58
+ * @param n23 Input element in the second row and the third column
59
+ * @param n24 Input element in the second row and the forth column
60
+ * @param n31 Input element in the third row and the first column
61
+ * @param n32 Input element in the third row and the second column
62
+ * @param n33 Input element in the third row and the third column
63
+ * @param n34 Input element in the third row and the forth column
64
+ * @param n41 Input element in the forth row and the first column
65
+ * @param n42 Input element in the forth row and the second column
66
+ * @param n43 Input element in the forth row and the third column
67
+ * @param n44 Input element in the forth row and the forth column
68
+ * @returns Return this matrix
69
+ */
70
+ AcGeMatrix3d.prototype.set = function (n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
71
+ var te = this.elements;
72
+ te[0] = n11;
73
+ te[4] = n12;
74
+ te[8] = n13;
75
+ te[12] = n14;
76
+ te[1] = n21;
77
+ te[5] = n22;
78
+ te[9] = n23;
79
+ te[13] = n24;
80
+ te[2] = n31;
81
+ te[6] = n32;
82
+ te[10] = n33;
83
+ te[14] = n34;
84
+ te[3] = n41;
85
+ te[7] = n42;
86
+ te[11] = n43;
87
+ te[15] = n44;
88
+ return this;
89
+ };
90
+ /**
91
+ * Reset this matrix to the identity matrix.
92
+ * @returns Return this matrix
93
+ */
94
+ AcGeMatrix3d.prototype.identity = function () {
95
+ this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
96
+ return this;
97
+ };
98
+ AcGeMatrix3d.prototype.clone = function () {
99
+ return new AcGeMatrix3d().fromArray(this.elements);
100
+ };
101
+ /**
102
+ * Copy the elements of matrix m into this matrix.
103
+ * @param m Input one matrix copied from
104
+ * @returns Return this matrix
105
+ */
106
+ AcGeMatrix3d.prototype.copy = function (m) {
107
+ var te = this.elements;
108
+ var me = m.elements;
109
+ te[0] = me[0];
110
+ te[1] = me[1];
111
+ te[2] = me[2];
112
+ te[3] = me[3];
113
+ te[4] = me[4];
114
+ te[5] = me[5];
115
+ te[6] = me[6];
116
+ te[7] = me[7];
117
+ te[8] = me[8];
118
+ te[9] = me[9];
119
+ te[10] = me[10];
120
+ te[11] = me[11];
121
+ te[12] = me[12];
122
+ te[13] = me[13];
123
+ te[14] = me[14];
124
+ te[15] = me[15];
125
+ return this;
126
+ };
127
+ /**
128
+ * Copy the translation component of the supplied matrix m into this matrix's translation component.
129
+ * @param m Input the matrix copied from
130
+ * @returns Return this matrix
131
+ */
132
+ AcGeMatrix3d.prototype.copyPosition = function (m) {
133
+ var te = this.elements, me = m.elements;
134
+ te[12] = me[12];
135
+ te[13] = me[13];
136
+ te[14] = me[14];
137
+ return this;
138
+ };
139
+ /**
140
+ * Set the upper 3x3 elements of this matrix to the values of the 3x3 matrix m.
141
+ * @param m Input one 3x3 matrix
142
+ * @returns Return this matrix
143
+ */
144
+ AcGeMatrix3d.prototype.setFromMatrix3 = function (m) {
145
+ var me = m.elements;
146
+ this.set(me[0], me[3], me[6], 0, me[1], me[4], me[7], 0, me[2], me[5], me[8], 0, 0, 0, 0, 1);
147
+ return this;
148
+ };
149
+ /**
150
+ * Create transform matrix according to the given the normalized extrusion vector
151
+ * @param extrusion Input the normalized extrusion vector
152
+ * @returns Return this matrix
153
+ */
154
+ AcGeMatrix3d.prototype.setFromExtrusionDirection = function (extrusion) {
155
+ if (!DEFAULT_TOL.equalPoint3d(extrusion, AcGeVector3d.Z_AXIS)) {
156
+ var xAxis = new AcGeVector3d(1, 0, 0);
157
+ if (Math.abs(extrusion.x) < 1.0 / 64.0 &&
158
+ Math.abs(extrusion.y) < 1.0 / 64.0) {
159
+ xAxis.crossVectors(AcGeVector3d.Y_AXIS, extrusion).normalize();
160
+ }
161
+ else {
162
+ xAxis.crossVectors(AcGeVector3d.Z_AXIS, extrusion).normalize();
163
+ }
164
+ var yAxis = extrusion.clone().cross(xAxis).normalize();
165
+ this.set(xAxis.x, xAxis.y, xAxis.z, 0, yAxis.x, yAxis.y, yAxis.z, 0, extrusion.x, extrusion.y, extrusion.z, 0, 0, 0, 0, 1);
166
+ }
167
+ else {
168
+ this.identity();
169
+ }
170
+ return this;
171
+ };
172
+ /**
173
+ * Extracts the basis of this matrix into the three axis vectors provided.
174
+ * @param xAxis Input X axis vector
175
+ * @param yAxis Input Y axis vector
176
+ * @param zAxis Input Z axis vector
177
+ * @returns Return this matrix
178
+ */
179
+ AcGeMatrix3d.prototype.extractBasis = function (xAxis, yAxis, zAxis) {
180
+ xAxis.setFromMatrixColumn(this, 0);
181
+ yAxis.setFromMatrixColumn(this, 1);
182
+ zAxis.setFromMatrixColumn(this, 2);
183
+ return this;
184
+ };
185
+ /**
186
+ * Set this to the basis matrix consisting of the three provided basis vectors:
187
+ * @param xAxis Input X axis vector
188
+ * @param yAxis Input Y axis vector
189
+ * @param zAxis Input Z axis vector
190
+ * @returns Return this matrix
191
+ */
192
+ AcGeMatrix3d.prototype.makeBasis = function (xAxis, yAxis, zAxis) {
193
+ this.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1);
194
+ return this;
195
+ };
196
+ /**
197
+ * Extracts the rotation component of the supplied matrix m into this matrix's rotation component.
198
+ * @param m Input one 4x4 matrix
199
+ * @returns Return this matrix
200
+ */
201
+ AcGeMatrix3d.prototype.extractRotation = function (m) {
202
+ // this method does not support reflection matrices
203
+ var te = this.elements;
204
+ var me = m.elements;
205
+ var scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
206
+ var scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
207
+ var scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
208
+ te[0] = me[0] * scaleX;
209
+ te[1] = me[1] * scaleX;
210
+ te[2] = me[2] * scaleX;
211
+ te[3] = 0;
212
+ te[4] = me[4] * scaleY;
213
+ te[5] = me[5] * scaleY;
214
+ te[6] = me[6] * scaleY;
215
+ te[7] = 0;
216
+ te[8] = me[8] * scaleZ;
217
+ te[9] = me[9] * scaleZ;
218
+ te[10] = me[10] * scaleZ;
219
+ te[11] = 0;
220
+ te[12] = 0;
221
+ te[13] = 0;
222
+ te[14] = 0;
223
+ te[15] = 1;
224
+ return this;
225
+ };
226
+ // makeRotationFromEuler(euler) {
227
+ // const te = this.elements
228
+ // const x = euler.x,
229
+ // y = euler.y,
230
+ // z = euler.z
231
+ // const a = Math.cos(x),
232
+ // b = Math.sin(x)
233
+ // const c = Math.cos(y),
234
+ // d = Math.sin(y)
235
+ // const e = Math.cos(z),
236
+ // f = Math.sin(z)
237
+ // if (euler.order === 'XYZ') {
238
+ // const ae = a * e,
239
+ // af = a * f,
240
+ // be = b * e,
241
+ // bf = b * f
242
+ // te[0] = c * e
243
+ // te[4] = -c * f
244
+ // te[8] = d
245
+ // te[1] = af + be * d
246
+ // te[5] = ae - bf * d
247
+ // te[9] = -b * c
248
+ // te[2] = bf - ae * d
249
+ // te[6] = be + af * d
250
+ // te[10] = a * c
251
+ // } else if (euler.order === 'YXZ') {
252
+ // const ce = c * e,
253
+ // cf = c * f,
254
+ // de = d * e,
255
+ // df = d * f
256
+ // te[0] = ce + df * b
257
+ // te[4] = de * b - cf
258
+ // te[8] = a * d
259
+ // te[1] = a * f
260
+ // te[5] = a * e
261
+ // te[9] = -b
262
+ // te[2] = cf * b - de
263
+ // te[6] = df + ce * b
264
+ // te[10] = a * c
265
+ // } else if (euler.order === 'ZXY') {
266
+ // const ce = c * e,
267
+ // cf = c * f,
268
+ // de = d * e,
269
+ // df = d * f
270
+ // te[0] = ce - df * b
271
+ // te[4] = -a * f
272
+ // te[8] = de + cf * b
273
+ // te[1] = cf + de * b
274
+ // te[5] = a * e
275
+ // te[9] = df - ce * b
276
+ // te[2] = -a * d
277
+ // te[6] = b
278
+ // te[10] = a * c
279
+ // } else if (euler.order === 'ZYX') {
280
+ // const ae = a * e,
281
+ // af = a * f,
282
+ // be = b * e,
283
+ // bf = b * f
284
+ // te[0] = c * e
285
+ // te[4] = be * d - af
286
+ // te[8] = ae * d + bf
287
+ // te[1] = c * f
288
+ // te[5] = bf * d + ae
289
+ // te[9] = af * d - be
290
+ // te[2] = -d
291
+ // te[6] = b * c
292
+ // te[10] = a * c
293
+ // } else if (euler.order === 'YZX') {
294
+ // const ac = a * c,
295
+ // ad = a * d,
296
+ // bc = b * c,
297
+ // bd = b * d
298
+ // te[0] = c * e
299
+ // te[4] = bd - ac * f
300
+ // te[8] = bc * f + ad
301
+ // te[1] = f
302
+ // te[5] = a * e
303
+ // te[9] = -b * e
304
+ // te[2] = -d * e
305
+ // te[6] = ad * f + bc
306
+ // te[10] = ac - bd * f
307
+ // } else if (euler.order === 'XZY') {
308
+ // const ac = a * c,
309
+ // ad = a * d,
310
+ // bc = b * c,
311
+ // bd = b * d
312
+ // te[0] = c * e
313
+ // te[4] = -f
314
+ // te[8] = d * e
315
+ // te[1] = ac * f + bd
316
+ // te[5] = a * e
317
+ // te[9] = ad * f - bc
318
+ // te[2] = bc * f - ad
319
+ // te[6] = b * e
320
+ // te[10] = bd * f + ac
321
+ // }
322
+ // // bottom row
323
+ // te[3] = 0
324
+ // te[7] = 0
325
+ // te[11] = 0
326
+ // // last column
327
+ // te[12] = 0
328
+ // te[13] = 0
329
+ // te[14] = 0
330
+ // te[15] = 1
331
+ // return this
332
+ // }
333
+ /**
334
+ * Set the rotation component of this matrix to the rotation specified by q
335
+ * @param q Input one uaternion
336
+ * @returns Return this matrix
337
+ */
338
+ AcGeMatrix3d.prototype.makeRotationFromQuaternion = function (q) {
339
+ return this.compose(_zero, q, _one);
340
+ };
341
+ /**
342
+ * Construct a rotation matrix, looking from eye towards target oriented by the up vector.
343
+ * @param eye Input eye vector
344
+ * @param target Input target vector
345
+ * @param up Input up vector
346
+ * @returns Return this matrix
347
+ */
348
+ AcGeMatrix3d.prototype.lookAt = function (eye, target, up) {
349
+ var te = this.elements;
350
+ _z.subVectors(eye, target);
351
+ if (_z.lengthSq() === 0) {
352
+ // eye and target are in the same position
353
+ _z.z = 1;
354
+ }
355
+ _z.normalize();
356
+ _x.crossVectors(up, _z);
357
+ if (_x.lengthSq() === 0) {
358
+ // up and z are parallel
359
+ if (Math.abs(up.z) === 1) {
360
+ _z.x += 0.0001;
361
+ }
362
+ else {
363
+ _z.z += 0.0001;
364
+ }
365
+ _z.normalize();
366
+ _x.crossVectors(up, _z);
367
+ }
368
+ _x.normalize();
369
+ _y.crossVectors(_z, _x);
370
+ te[0] = _x.x;
371
+ te[4] = _y.x;
372
+ te[8] = _z.x;
373
+ te[1] = _x.y;
374
+ te[5] = _y.y;
375
+ te[9] = _z.y;
376
+ te[2] = _x.z;
377
+ te[6] = _y.z;
378
+ te[10] = _z.z;
379
+ return this;
380
+ };
381
+ /**
382
+ * Post-multiply this matrix by m.
383
+ * @param m Input one 4x4 matrix
384
+ * @returns Return this matrix
385
+ */
386
+ AcGeMatrix3d.prototype.multiply = function (m) {
387
+ return this.multiplyMatrices(this, m);
388
+ };
389
+ /**
390
+ * Pre-multiply this matrix by m.
391
+ * @param m Input one 4x4 matrix
392
+ * @returns Return this matrix
393
+ */
394
+ AcGeMatrix3d.prototype.premultiply = function (m) {
395
+ return this.multiplyMatrices(m, this);
396
+ };
397
+ /**
398
+ * Set this matrix to a x b.
399
+ * @param a Input one 4x4 matrix
400
+ * @param b Input one 4x4 matrix
401
+ * @returns Return this matrix
402
+ */
403
+ AcGeMatrix3d.prototype.multiplyMatrices = function (a, b) {
404
+ var ae = a.elements;
405
+ var be = b.elements;
406
+ var te = this.elements;
407
+ var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
408
+ var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
409
+ var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
410
+ var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
411
+ var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
412
+ var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
413
+ var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
414
+ var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
415
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
416
+ te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
417
+ te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
418
+ te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
419
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
420
+ te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
421
+ te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
422
+ te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
423
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
424
+ te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
425
+ te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
426
+ te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
427
+ te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
428
+ te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
429
+ te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
430
+ te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
431
+ return this;
432
+ };
433
+ /**
434
+ * Multiply every component of the matrix by a scalar value s.
435
+ * @param s Input one scalar value
436
+ * @returns Return this matrix
437
+ */
438
+ AcGeMatrix3d.prototype.multiplyScalar = function (s) {
439
+ var te = this.elements;
440
+ te[0] *= s;
441
+ te[4] *= s;
442
+ te[8] *= s;
443
+ te[12] *= s;
444
+ te[1] *= s;
445
+ te[5] *= s;
446
+ te[9] *= s;
447
+ te[13] *= s;
448
+ te[2] *= s;
449
+ te[6] *= s;
450
+ te[10] *= s;
451
+ te[14] *= s;
452
+ te[3] *= s;
453
+ te[7] *= s;
454
+ te[11] *= s;
455
+ te[15] *= s;
456
+ return this;
457
+ };
458
+ /**
459
+ * Compute and return the determinant of this matrix.
460
+ * @returns Return the determinant of this matrix.
461
+ */
462
+ AcGeMatrix3d.prototype.determinant = function () {
463
+ var te = this.elements;
464
+ var n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
465
+ var n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
466
+ var n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
467
+ var n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
468
+ //TODO: make this more efficient
469
+ //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
470
+ return (n41 *
471
+ (+n14 * n23 * n32 -
472
+ n13 * n24 * n32 -
473
+ n14 * n22 * n33 +
474
+ n12 * n24 * n33 +
475
+ n13 * n22 * n34 -
476
+ n12 * n23 * n34) +
477
+ n42 *
478
+ (+n11 * n23 * n34 -
479
+ n11 * n24 * n33 +
480
+ n14 * n21 * n33 -
481
+ n13 * n21 * n34 +
482
+ n13 * n24 * n31 -
483
+ n14 * n23 * n31) +
484
+ n43 *
485
+ (+n11 * n24 * n32 -
486
+ n11 * n22 * n34 -
487
+ n14 * n21 * n32 +
488
+ n12 * n21 * n34 +
489
+ n14 * n22 * n31 -
490
+ n12 * n24 * n31) +
491
+ n44 *
492
+ (-n13 * n22 * n31 -
493
+ n11 * n23 * n32 +
494
+ n11 * n22 * n33 +
495
+ n13 * n21 * n32 -
496
+ n12 * n21 * n33 +
497
+ n12 * n23 * n31));
498
+ };
499
+ /**
500
+ * Transposes this matrix.
501
+ * @returns Return this matrix
502
+ */
503
+ AcGeMatrix3d.prototype.transpose = function () {
504
+ var te = this.elements;
505
+ var tmp;
506
+ tmp = te[1];
507
+ te[1] = te[4];
508
+ te[4] = tmp;
509
+ tmp = te[2];
510
+ te[2] = te[8];
511
+ te[8] = tmp;
512
+ tmp = te[6];
513
+ te[6] = te[9];
514
+ te[9] = tmp;
515
+ tmp = te[3];
516
+ te[3] = te[12];
517
+ te[12] = tmp;
518
+ tmp = te[7];
519
+ te[7] = te[13];
520
+ te[13] = tmp;
521
+ tmp = te[11];
522
+ te[11] = te[14];
523
+ te[14] = tmp;
524
+ return this;
525
+ };
526
+ /**
527
+ * Set the position component for this matrix from vector v, without affecting the rest of the matrix.
528
+ * @param x Input one number or one vector
529
+ * @param y Input one number
530
+ * @param z Input one number
531
+ * @returns Return this matrix
532
+ */
533
+ AcGeMatrix3d.prototype.setPosition = function (x, y, z) {
534
+ var te = this.elements;
535
+ if (x instanceof AcGeVector3d) {
536
+ te[12] = x.x;
537
+ te[13] = x.y;
538
+ te[14] = x.z;
539
+ }
540
+ else {
541
+ te[12] = x;
542
+ te[13] = y;
543
+ te[14] = z;
544
+ }
545
+ return this;
546
+ };
547
+ /**
548
+ * Invert this matrix, using the analytic method. You can not invert with a determinant of zero.
549
+ * If you attempt this, the method produces a zero matrix instead.
550
+ * @returns Return this matrix
551
+ */
552
+ AcGeMatrix3d.prototype.invert = function () {
553
+ // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
554
+ var te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 -
555
+ n24 * n33 * n42 +
556
+ n24 * n32 * n43 -
557
+ n22 * n34 * n43 -
558
+ n23 * n32 * n44 +
559
+ n22 * n33 * n44, t12 = n14 * n33 * n42 -
560
+ n13 * n34 * n42 -
561
+ n14 * n32 * n43 +
562
+ n12 * n34 * n43 +
563
+ n13 * n32 * n44 -
564
+ n12 * n33 * n44, t13 = n13 * n24 * n42 -
565
+ n14 * n23 * n42 +
566
+ n14 * n22 * n43 -
567
+ n12 * n24 * n43 -
568
+ n13 * n22 * n44 +
569
+ n12 * n23 * n44, t14 = n14 * n23 * n32 -
570
+ n13 * n24 * n32 -
571
+ n14 * n22 * n33 +
572
+ n12 * n24 * n33 +
573
+ n13 * n22 * n34 -
574
+ n12 * n23 * n34;
575
+ var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
576
+ if (det === 0)
577
+ return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
578
+ var detInv = 1 / det;
579
+ te[0] = t11 * detInv;
580
+ te[1] =
581
+ (n24 * n33 * n41 -
582
+ n23 * n34 * n41 -
583
+ n24 * n31 * n43 +
584
+ n21 * n34 * n43 +
585
+ n23 * n31 * n44 -
586
+ n21 * n33 * n44) *
587
+ detInv;
588
+ te[2] =
589
+ (n22 * n34 * n41 -
590
+ n24 * n32 * n41 +
591
+ n24 * n31 * n42 -
592
+ n21 * n34 * n42 -
593
+ n22 * n31 * n44 +
594
+ n21 * n32 * n44) *
595
+ detInv;
596
+ te[3] =
597
+ (n23 * n32 * n41 -
598
+ n22 * n33 * n41 -
599
+ n23 * n31 * n42 +
600
+ n21 * n33 * n42 +
601
+ n22 * n31 * n43 -
602
+ n21 * n32 * n43) *
603
+ detInv;
604
+ te[4] = t12 * detInv;
605
+ te[5] =
606
+ (n13 * n34 * n41 -
607
+ n14 * n33 * n41 +
608
+ n14 * n31 * n43 -
609
+ n11 * n34 * n43 -
610
+ n13 * n31 * n44 +
611
+ n11 * n33 * n44) *
612
+ detInv;
613
+ te[6] =
614
+ (n14 * n32 * n41 -
615
+ n12 * n34 * n41 -
616
+ n14 * n31 * n42 +
617
+ n11 * n34 * n42 +
618
+ n12 * n31 * n44 -
619
+ n11 * n32 * n44) *
620
+ detInv;
621
+ te[7] =
622
+ (n12 * n33 * n41 -
623
+ n13 * n32 * n41 +
624
+ n13 * n31 * n42 -
625
+ n11 * n33 * n42 -
626
+ n12 * n31 * n43 +
627
+ n11 * n32 * n43) *
628
+ detInv;
629
+ te[8] = t13 * detInv;
630
+ te[9] =
631
+ (n14 * n23 * n41 -
632
+ n13 * n24 * n41 -
633
+ n14 * n21 * n43 +
634
+ n11 * n24 * n43 +
635
+ n13 * n21 * n44 -
636
+ n11 * n23 * n44) *
637
+ detInv;
638
+ te[10] =
639
+ (n12 * n24 * n41 -
640
+ n14 * n22 * n41 +
641
+ n14 * n21 * n42 -
642
+ n11 * n24 * n42 -
643
+ n12 * n21 * n44 +
644
+ n11 * n22 * n44) *
645
+ detInv;
646
+ te[11] =
647
+ (n13 * n22 * n41 -
648
+ n12 * n23 * n41 -
649
+ n13 * n21 * n42 +
650
+ n11 * n23 * n42 +
651
+ n12 * n21 * n43 -
652
+ n11 * n22 * n43) *
653
+ detInv;
654
+ te[12] = t14 * detInv;
655
+ te[13] =
656
+ (n13 * n24 * n31 -
657
+ n14 * n23 * n31 +
658
+ n14 * n21 * n33 -
659
+ n11 * n24 * n33 -
660
+ n13 * n21 * n34 +
661
+ n11 * n23 * n34) *
662
+ detInv;
663
+ te[14] =
664
+ (n14 * n22 * n31 -
665
+ n12 * n24 * n31 -
666
+ n14 * n21 * n32 +
667
+ n11 * n24 * n32 +
668
+ n12 * n21 * n34 -
669
+ n11 * n22 * n34) *
670
+ detInv;
671
+ te[15] =
672
+ (n12 * n23 * n31 -
673
+ n13 * n22 * n31 +
674
+ n13 * n21 * n32 -
675
+ n11 * n23 * n32 -
676
+ n12 * n21 * n33 +
677
+ n11 * n22 * n33) *
678
+ detInv;
679
+ return this;
680
+ };
681
+ /**
682
+ * Multiply the columns of this matrix by vector v.
683
+ * @param v Input one vector
684
+ * @returns Return this matrix
685
+ */
686
+ AcGeMatrix3d.prototype.scale = function (v) {
687
+ var te = this.elements;
688
+ var x = v.x, y = v.y, z = v.z;
689
+ te[0] *= x;
690
+ te[4] *= y;
691
+ te[8] *= z;
692
+ te[1] *= x;
693
+ te[5] *= y;
694
+ te[9] *= z;
695
+ te[2] *= x;
696
+ te[6] *= y;
697
+ te[10] *= z;
698
+ te[3] *= x;
699
+ te[7] *= y;
700
+ te[11] *= z;
701
+ return this;
702
+ };
703
+ /**
704
+ * Get the maximum scale value of the 3 axes.
705
+ * @returns Return the maximum scale value of the 3 axes.
706
+ */
707
+ AcGeMatrix3d.prototype.getMaxScaleOnAxis = function () {
708
+ var te = this.elements;
709
+ var scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
710
+ var scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
711
+ var scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
712
+ return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
713
+ };
714
+ /**
715
+ * Set this matrix as a translation transform from vector v, or numbers x, y and z.
716
+ * @param x Input one vector or one number
717
+ * @param y Input one number
718
+ * @param z Input one number
719
+ * @returns Return this matrix
720
+ */
721
+ AcGeMatrix3d.prototype.makeTranslation = function (x, y, z) {
722
+ if (x instanceof AcGeVector3d) {
723
+ this.set(1, 0, 0, x.x, 0, 1, 0, x.y, 0, 0, 1, x.z, 0, 0, 0, 1);
724
+ }
725
+ else {
726
+ this.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);
727
+ }
728
+ return this;
729
+ };
730
+ /**
731
+ * Set this matrix as a rotational transformation around the X axis by theta (θ) radians.
732
+ * @param theta Input rotation angle in radians.
733
+ * @returns Return this matrix
734
+ */
735
+ AcGeMatrix3d.prototype.makeRotationX = function (theta) {
736
+ var c = Math.cos(theta), s = Math.sin(theta);
737
+ this.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
738
+ return this;
739
+ };
740
+ /**
741
+ * Set this matrix as a rotational transformation around the Y axis by theta (θ) radians.
742
+ * @param theta Input rotation angle in radians.
743
+ * @returns Return this matrix
744
+ */
745
+ AcGeMatrix3d.prototype.makeRotationY = function (theta) {
746
+ var c = Math.cos(theta), s = Math.sin(theta);
747
+ this.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
748
+ return this;
749
+ };
750
+ /**
751
+ * Set this matrix as a rotational transformation around the Z axis by theta (θ) radians.
752
+ * @param theta Input rotation angle in radians.
753
+ * @returns Return this matrix
754
+ */
755
+ AcGeMatrix3d.prototype.makeRotationZ = function (theta) {
756
+ var c = Math.cos(theta), s = Math.sin(theta);
757
+ this.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
758
+ return this;
759
+ };
760
+ /**
761
+ * Set this matrix as rotation transform around axis by theta radians.
762
+ * @param axis Input rotation axis, should be normalized.
763
+ * @param angle Input rotation angle in radians.
764
+ * @returns Return this matrix
765
+ */
766
+ AcGeMatrix3d.prototype.makeRotationAxis = function (axis, angle) {
767
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
768
+ var c = Math.cos(angle);
769
+ var s = Math.sin(angle);
770
+ var t = 1 - c;
771
+ var x = axis.x, y = axis.y, z = axis.z;
772
+ var tx = t * x, ty = t * y;
773
+ this.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);
774
+ return this;
775
+ };
776
+ /**
777
+ * Set this matrix as scale transform.
778
+ * @param x Input x scale
779
+ * @param y Input y scale
780
+ * @param z Input z scale
781
+ * @returns Return this matrix
782
+ */
783
+ AcGeMatrix3d.prototype.makeScale = function (x, y, z) {
784
+ this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
785
+ return this;
786
+ };
787
+ /**
788
+ * Set this matrix as a shear transform.
789
+ * @param xy Input the amount to shear X by Y.
790
+ * @param xz Input the amount to shear X by Z.
791
+ * @param yx Input the amount to shear Y by X.
792
+ * @param yz Input the amount to shear Y by Z.
793
+ * @param zx Input the amount to shear Z by X.
794
+ * @param zy Input the amount to shear Z by Y.
795
+ * @returns Return this matrix
796
+ */
797
+ AcGeMatrix3d.prototype.makeShear = function (xy, xz, yx, yz, zx, zy) {
798
+ this.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1);
799
+ return this;
800
+ };
801
+ /**
802
+ * Set this matrix to the transformation composed of position, quaternion and scale.
803
+ * @param position Input position
804
+ * @param quaternion Input quaternion
805
+ * @param scale Input scale
806
+ * @returns Return this matrix
807
+ */
808
+ AcGeMatrix3d.prototype.compose = function (position, quaternion, scale) {
809
+ var te = this.elements;
810
+ var x = quaternion.x, y = quaternion.y, z = quaternion.z, w = quaternion.w;
811
+ var x2 = x + x, y2 = y + y, z2 = z + z;
812
+ var xx = x * x2, xy = x * y2, xz = x * z2;
813
+ var yy = y * y2, yz = y * z2, zz = z * z2;
814
+ var wx = w * x2, wy = w * y2, wz = w * z2;
815
+ var sx = scale.x, sy = scale.y, sz = scale.z;
816
+ te[0] = (1 - (yy + zz)) * sx;
817
+ te[1] = (xy + wz) * sx;
818
+ te[2] = (xz - wy) * sx;
819
+ te[3] = 0;
820
+ te[4] = (xy - wz) * sy;
821
+ te[5] = (1 - (xx + zz)) * sy;
822
+ te[6] = (yz + wx) * sy;
823
+ te[7] = 0;
824
+ te[8] = (xz + wy) * sz;
825
+ te[9] = (yz - wx) * sz;
826
+ te[10] = (1 - (xx + yy)) * sz;
827
+ te[11] = 0;
828
+ te[12] = position.x;
829
+ te[13] = position.y;
830
+ te[14] = position.z;
831
+ te[15] = 1;
832
+ return this;
833
+ };
834
+ /**
835
+ * Decompose this matrix into its position, quaternion and scale components.
836
+ *
837
+ * Note: Not all matrices are decomposable in this way. For example, if an object has a non-uniformly
838
+ * scaled parent, then the object's world matrix may not be decomposable, and this method may not be
839
+ * appropriate.
840
+ * @param position Input position to output
841
+ * @param quaternion Input quaternion to output
842
+ * @param scale Input scale to output
843
+ * @returns Return this matrix
844
+ */
845
+ AcGeMatrix3d.prototype.decompose = function (position, quaternion, scale) {
846
+ var te = this.elements;
847
+ var sx = _v1.set(te[0], te[1], te[2]).length();
848
+ var sy = _v1.set(te[4], te[5], te[6]).length();
849
+ var sz = _v1.set(te[8], te[9], te[10]).length();
850
+ // if determine is negative, we need to invert one scale
851
+ var det = this.determinant();
852
+ if (det < 0)
853
+ sx = -sx;
854
+ position.x = te[12];
855
+ position.y = te[13];
856
+ position.z = te[14];
857
+ // scale the rotation part
858
+ _m1.copy(this);
859
+ var invSX = 1 / sx;
860
+ var invSY = 1 / sy;
861
+ var invSZ = 1 / sz;
862
+ _m1.elements[0] *= invSX;
863
+ _m1.elements[1] *= invSX;
864
+ _m1.elements[2] *= invSX;
865
+ _m1.elements[4] *= invSY;
866
+ _m1.elements[5] *= invSY;
867
+ _m1.elements[6] *= invSY;
868
+ _m1.elements[8] *= invSZ;
869
+ _m1.elements[9] *= invSZ;
870
+ _m1.elements[10] *= invSZ;
871
+ quaternion.setFromRotationMatrix(_m1);
872
+ scale.x = sx;
873
+ scale.y = sy;
874
+ scale.z = sz;
875
+ return this;
876
+ };
877
+ // makePerspective(
878
+ // left,
879
+ // right,
880
+ // top,
881
+ // bottom,
882
+ // near,
883
+ // far,
884
+ // coordinateSystem = WebGLCoordinateSystem
885
+ // ) {
886
+ // const te = this.elements
887
+ // const x = (2 * near) / (right - left)
888
+ // const y = (2 * near) / (top - bottom)
889
+ // const a = (right + left) / (right - left)
890
+ // const b = (top + bottom) / (top - bottom)
891
+ // let c, d
892
+ // if (coordinateSystem === WebGLCoordinateSystem) {
893
+ // c = -(far + near) / (far - near)
894
+ // d = (-2 * far * near) / (far - near)
895
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
896
+ // c = -far / (far - near)
897
+ // d = (-far * near) / (far - near)
898
+ // } else {
899
+ // throw new Error(
900
+ // 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' +
901
+ // coordinateSystem
902
+ // )
903
+ // }
904
+ // te[0] = x
905
+ // te[4] = 0
906
+ // te[8] = a
907
+ // te[12] = 0
908
+ // te[1] = 0
909
+ // te[5] = y
910
+ // te[9] = b
911
+ // te[13] = 0
912
+ // te[2] = 0
913
+ // te[6] = 0
914
+ // te[10] = c
915
+ // te[14] = d
916
+ // te[3] = 0
917
+ // te[7] = 0
918
+ // te[11] = -1
919
+ // te[15] = 0
920
+ // return this
921
+ // }
922
+ // makeOrthographic(
923
+ // left,
924
+ // right,
925
+ // top,
926
+ // bottom,
927
+ // near,
928
+ // far,
929
+ // coordinateSystem = WebGLCoordinateSystem
930
+ // ) {
931
+ // const te = this.elements
932
+ // const w = 1.0 / (right - left)
933
+ // const h = 1.0 / (top - bottom)
934
+ // const p = 1.0 / (far - near)
935
+ // const x = (right + left) * w
936
+ // const y = (top + bottom) * h
937
+ // let z, zInv
938
+ // if (coordinateSystem === WebGLCoordinateSystem) {
939
+ // z = (far + near) * p
940
+ // zInv = -2 * p
941
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
942
+ // z = near * p
943
+ // zInv = -1 * p
944
+ // } else {
945
+ // throw new Error(
946
+ // 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' +
947
+ // coordinateSystem
948
+ // )
949
+ // }
950
+ // te[0] = 2 * w
951
+ // te[4] = 0
952
+ // te[8] = 0
953
+ // te[12] = -x
954
+ // te[1] = 0
955
+ // te[5] = 2 * h
956
+ // te[9] = 0
957
+ // te[13] = -y
958
+ // te[2] = 0
959
+ // te[6] = 0
960
+ // te[10] = zInv
961
+ // te[14] = -z
962
+ // te[3] = 0
963
+ // te[7] = 0
964
+ // te[11] = 0
965
+ // te[15] = 1
966
+ // return this
967
+ // }
968
+ /**
969
+ * Return true if this matrix and m are equal.
970
+ * @param matrix Input one matrix to compare
971
+ * @returns Return true if this matrix and m are equal.
972
+ */
973
+ AcGeMatrix3d.prototype.equals = function (matrix) {
974
+ var te = this.elements;
975
+ var me = matrix.elements;
976
+ for (var i = 0; i < 16; i++) {
977
+ if (te[i] !== me[i])
978
+ return false;
979
+ }
980
+ return true;
981
+ };
982
+ /**
983
+ * Set the elements of this matrix based on an array in column-major format.
984
+ * @param array Input the array to read the elements from.
985
+ * @param offset Input (optional) offset into the array. Default is 0.
986
+ * @returns
987
+ */
988
+ AcGeMatrix3d.prototype.fromArray = function (array, offset) {
989
+ if (offset === void 0) { offset = 0; }
990
+ for (var i = 0; i < 16; i++) {
991
+ this.elements[i] = array[i + offset];
992
+ }
993
+ return this;
994
+ };
995
+ /**
996
+ * Write the elements of this matrix to an array in column-major format.
997
+ * @param array Input (optional) array to store the resulting vector in.
998
+ * @param offset Input (optional) offset in the array at which to put the result.
999
+ * @returns Return an array in column-major format by writing the elements of this matrix to it
1000
+ */
1001
+ AcGeMatrix3d.prototype.toArray = function (array, offset) {
1002
+ if (array === void 0) { array = []; }
1003
+ if (offset === void 0) { offset = 0; }
1004
+ var te = this.elements;
1005
+ array[offset] = te[0];
1006
+ array[offset + 1] = te[1];
1007
+ array[offset + 2] = te[2];
1008
+ array[offset + 3] = te[3];
1009
+ array[offset + 4] = te[4];
1010
+ array[offset + 5] = te[5];
1011
+ array[offset + 6] = te[6];
1012
+ array[offset + 7] = te[7];
1013
+ array[offset + 8] = te[8];
1014
+ array[offset + 9] = te[9];
1015
+ array[offset + 10] = te[10];
1016
+ array[offset + 11] = te[11];
1017
+ array[offset + 12] = te[12];
1018
+ array[offset + 13] = te[13];
1019
+ array[offset + 14] = te[14];
1020
+ array[offset + 15] = te[15];
1021
+ return array;
1022
+ };
1023
+ /**
1024
+ * Identity matrix.
1025
+ */
1026
+ AcGeMatrix3d.IDENTITY = Object.freeze(new AcGeMatrix3d());
1027
+ return AcGeMatrix3d;
1028
+ }());
1029
+ export { AcGeMatrix3d };
1030
+ var _v1 = /*@__PURE__*/ new AcGeVector3d();
1031
+ var _m1 = /*@__PURE__*/ new AcGeMatrix3d();
1032
+ var _zero = /*@__PURE__*/ new AcGeVector3d(0, 0, 0);
1033
+ var _one = /*@__PURE__*/ new AcGeVector3d(1, 1, 1);
1034
+ var _x = /*@__PURE__*/ new AcGeVector3d();
1035
+ var _y = /*@__PURE__*/ new AcGeVector3d();
1036
+ var _z = /*@__PURE__*/ new AcGeVector3d();
1037
+ //# sourceMappingURL=AcGeMatrix3d.js.map