@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.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/geometry-engine.js +10186 -0
- package/dist/geometry-engine.umd.cjs +4 -0
- package/lib/geometry/AcGeArea2d.d.ts +61 -0
- package/lib/geometry/AcGeArea2d.d.ts.map +1 -0
- package/lib/geometry/AcGeArea2d.js +174 -0
- package/lib/geometry/AcGeArea2d.js.map +1 -0
- package/lib/geometry/AcGeCircArc2d.d.ts +108 -0
- package/lib/geometry/AcGeCircArc2d.d.ts.map +1 -0
- package/lib/geometry/AcGeCircArc2d.js +412 -0
- package/lib/geometry/AcGeCircArc2d.js.map +1 -0
- package/lib/geometry/AcGeCircArc3d.d.ts +138 -0
- package/lib/geometry/AcGeCircArc3d.d.ts.map +1 -0
- package/lib/geometry/AcGeCircArc3d.js +447 -0
- package/lib/geometry/AcGeCircArc3d.js.map +1 -0
- package/lib/geometry/AcGeCurve2d.d.ts +85 -0
- package/lib/geometry/AcGeCurve2d.d.ts.map +1 -0
- package/lib/geometry/AcGeCurve2d.js +213 -0
- package/lib/geometry/AcGeCurve2d.js.map +1 -0
- package/lib/geometry/AcGeCurve3d.d.ts +27 -0
- package/lib/geometry/AcGeCurve3d.d.ts.map +1 -0
- package/lib/geometry/AcGeCurve3d.js +29 -0
- package/lib/geometry/AcGeCurve3d.js.map +1 -0
- package/lib/geometry/AcGeEllipseArc2d.d.ts +105 -0
- package/lib/geometry/AcGeEllipseArc2d.d.ts.map +1 -0
- package/lib/geometry/AcGeEllipseArc2d.js +292 -0
- package/lib/geometry/AcGeEllipseArc2d.js.map +1 -0
- package/lib/geometry/AcGeEllipseArc3d.d.ts +141 -0
- package/lib/geometry/AcGeEllipseArc3d.d.ts.map +1 -0
- package/lib/geometry/AcGeEllipseArc3d.js +442 -0
- package/lib/geometry/AcGeEllipseArc3d.js.map +1 -0
- package/lib/geometry/AcGeLine2d.d.ts +56 -0
- package/lib/geometry/AcGeLine2d.d.ts.map +1 -0
- package/lib/geometry/AcGeLine2d.js +125 -0
- package/lib/geometry/AcGeLine2d.js.map +1 -0
- package/lib/geometry/AcGeLine3d.d.ts +134 -0
- package/lib/geometry/AcGeLine3d.d.ts.map +1 -0
- package/lib/geometry/AcGeLine3d.js +291 -0
- package/lib/geometry/AcGeLine3d.js.map +1 -0
- package/lib/geometry/AcGeLoop2d.d.ts +59 -0
- package/lib/geometry/AcGeLoop2d.d.ts.map +1 -0
- package/lib/geometry/AcGeLoop2d.js +141 -0
- package/lib/geometry/AcGeLoop2d.js.map +1 -0
- package/lib/geometry/AcGePolyline2d.d.ts +90 -0
- package/lib/geometry/AcGePolyline2d.d.ts.map +1 -0
- package/lib/geometry/AcGePolyline2d.js +224 -0
- package/lib/geometry/AcGePolyline2d.js.map +1 -0
- package/lib/geometry/AcGeShape.d.ts +12 -0
- package/lib/geometry/AcGeShape.d.ts.map +1 -0
- package/lib/geometry/AcGeShape.js +22 -0
- package/lib/geometry/AcGeShape.js.map +1 -0
- package/lib/geometry/AcGeShape2d.d.ts +31 -0
- package/lib/geometry/AcGeShape2d.d.ts.map +1 -0
- package/lib/geometry/AcGeShape2d.js +51 -0
- package/lib/geometry/AcGeShape2d.js.map +1 -0
- package/lib/geometry/AcGeShape3d.d.ts +33 -0
- package/lib/geometry/AcGeShape3d.d.ts.map +1 -0
- package/lib/geometry/AcGeShape3d.js +52 -0
- package/lib/geometry/AcGeShape3d.js.map +1 -0
- package/lib/geometry/AcGeSpline3d.d.ts +77 -0
- package/lib/geometry/AcGeSpline3d.d.ts.map +1 -0
- package/lib/geometry/AcGeSpline3d.js +221 -0
- package/lib/geometry/AcGeSpline3d.js.map +1 -0
- package/lib/geometry/index.d.ts +13 -0
- package/lib/geometry/index.d.ts.map +1 -0
- package/lib/geometry/index.js +13 -0
- package/lib/geometry/index.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/math/AcGeBox2d.d.ts +173 -0
- package/lib/math/AcGeBox2d.d.ts.map +1 -0
- package/lib/math/AcGeBox2d.js +289 -0
- package/lib/math/AcGeBox2d.js.map +1 -0
- package/lib/math/AcGeBox3d.d.ts +195 -0
- package/lib/math/AcGeBox3d.d.ts.map +1 -0
- package/lib/math/AcGeBox3d.js +378 -0
- package/lib/math/AcGeBox3d.js.map +1 -0
- package/lib/math/AcGeEuler.d.ts +133 -0
- package/lib/math/AcGeEuler.d.ts.map +1 -0
- package/lib/math/AcGeEuler.js +358 -0
- package/lib/math/AcGeEuler.js.map +1 -0
- package/lib/math/AcGeMatrix2d.d.ts +203 -0
- package/lib/math/AcGeMatrix2d.d.ts.map +1 -0
- package/lib/math/AcGeMatrix2d.js +393 -0
- package/lib/math/AcGeMatrix2d.js.map +1 -0
- package/lib/math/AcGeMatrix3d.d.ts +279 -0
- package/lib/math/AcGeMatrix3d.d.ts.map +1 -0
- package/lib/math/AcGeMatrix3d.js +1037 -0
- package/lib/math/AcGeMatrix3d.js.map +1 -0
- package/lib/math/AcGePlane.d.ts +131 -0
- package/lib/math/AcGePlane.d.ts.map +1 -0
- package/lib/math/AcGePlane.js +218 -0
- package/lib/math/AcGePlane.js.map +1 -0
- package/lib/math/AcGePoint.d.ts +4 -0
- package/lib/math/AcGePoint.d.ts.map +1 -0
- package/lib/math/AcGePoint.js +2 -0
- package/lib/math/AcGePoint.js.map +1 -0
- package/lib/math/AcGePoint2d.d.ts +17 -0
- package/lib/math/AcGePoint2d.d.ts.map +1 -0
- package/lib/math/AcGePoint2d.js +40 -0
- package/lib/math/AcGePoint2d.js.map +1 -0
- package/lib/math/AcGePoint3d.d.ts +18 -0
- package/lib/math/AcGePoint3d.d.ts.map +1 -0
- package/lib/math/AcGePoint3d.js +43 -0
- package/lib/math/AcGePoint3d.js.map +1 -0
- package/lib/math/AcGeQuaternion.d.ts +230 -0
- package/lib/math/AcGeQuaternion.d.ts.map +1 -0
- package/lib/math/AcGeQuaternion.js +666 -0
- package/lib/math/AcGeQuaternion.js.map +1 -0
- package/lib/math/AcGeVector.d.ts +9 -0
- package/lib/math/AcGeVector.d.ts.map +1 -0
- package/lib/math/AcGeVector.js +2 -0
- package/lib/math/AcGeVector.js.map +1 -0
- package/lib/math/AcGeVector2d.d.ts +361 -0
- package/lib/math/AcGeVector2d.d.ts.map +1 -0
- package/lib/math/AcGeVector2d.js +622 -0
- package/lib/math/AcGeVector2d.js.map +1 -0
- package/lib/math/AcGeVector3d.d.ts +493 -0
- package/lib/math/AcGeVector3d.d.ts.map +1 -0
- package/lib/math/AcGeVector3d.js +868 -0
- package/lib/math/AcGeVector3d.js.map +1 -0
- package/lib/math/index.d.ts +14 -0
- package/lib/math/index.d.ts.map +1 -0
- package/lib/math/index.js +14 -0
- package/lib/math/index.js.map +1 -0
- package/lib/util/AcGeConstants.d.ts +19 -0
- package/lib/util/AcGeConstants.d.ts.map +1 -0
- package/lib/util/AcGeConstants.js +25 -0
- package/lib/util/AcGeConstants.js.map +1 -0
- package/lib/util/AcGeGeometryUtil.d.ts +16 -0
- package/lib/util/AcGeGeometryUtil.d.ts.map +1 -0
- package/lib/util/AcGeGeometryUtil.js +56 -0
- package/lib/util/AcGeGeometryUtil.js.map +1 -0
- package/lib/util/AcGeMathUtil.d.ts +203 -0
- package/lib/util/AcGeMathUtil.d.ts.map +1 -0
- package/lib/util/AcGeMathUtil.js +585 -0
- package/lib/util/AcGeMathUtil.js.map +1 -0
- package/lib/util/AcGeTol.d.ts +91 -0
- package/lib/util/AcGeTol.d.ts.map +1 -0
- package/lib/util/AcGeTol.js +83 -0
- package/lib/util/AcGeTol.js.map +1 -0
- package/lib/util/index.d.ts +5 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +5 -0
- package/lib/util/index.js.map +1 -0
- package/package.json +42 -0
@@ -0,0 +1,378 @@
|
|
1
|
+
import { AcGeVector3d } from './AcGeVector3d';
|
2
|
+
/**
|
3
|
+
* The class representing an axis-aligned bounding box (AABB) in 3d space.
|
4
|
+
*/
|
5
|
+
var AcGeBox3d = /** @class */ (function () {
|
6
|
+
/**
|
7
|
+
* Create a 3d box bounded by min and max.
|
8
|
+
* @param min (optional) Input the lower (x, y, z) boundary of the box.
|
9
|
+
* Set it to ( + Infinity, + Infinity, + Infinity ) if undefined or null provided.
|
10
|
+
* @param max (optional) Input the upper (x, y, z) boundary of the box.
|
11
|
+
* Set it to ( - Infinity, - Infinity, - Infinity ) if undefined or null provided.
|
12
|
+
*/
|
13
|
+
function AcGeBox3d(min, max) {
|
14
|
+
if (min === void 0) { min = undefined; }
|
15
|
+
if (max === void 0) { max = undefined; }
|
16
|
+
this.min =
|
17
|
+
min == null
|
18
|
+
? new AcGeVector3d(+Infinity, +Infinity, +Infinity)
|
19
|
+
: new AcGeVector3d(min.x, min.y, min.z);
|
20
|
+
this.max =
|
21
|
+
max == null
|
22
|
+
? new AcGeVector3d(-Infinity, -Infinity, -Infinity)
|
23
|
+
: new AcGeVector3d(max.x, max.y, max.z);
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Set the lower and upper (x, y, z) boundaries of this box.
|
27
|
+
* Please note that this method only copies the values from the given objects.
|
28
|
+
* @param min Input the lower (x, y, z) boundary of the box.
|
29
|
+
* @param max Input the upper (x, y, z) boundary of the box.
|
30
|
+
* @returns Return this box.
|
31
|
+
*/
|
32
|
+
AcGeBox3d.prototype.set = function (min, max) {
|
33
|
+
this.min.copy(min);
|
34
|
+
this.max.copy(max);
|
35
|
+
return this;
|
36
|
+
};
|
37
|
+
/**
|
38
|
+
* Set the upper and lower bounds of this box to include all of the data in array.
|
39
|
+
* @param array Input an array of position data that the resulting box will envelop.
|
40
|
+
* @returns Return this box
|
41
|
+
*/
|
42
|
+
AcGeBox3d.prototype.setFromArray = function (array) {
|
43
|
+
this.makeEmpty();
|
44
|
+
for (var i = 0, il = array.length; i < il; i += 3) {
|
45
|
+
this.expandByPoint(_vector.fromArray(array, i));
|
46
|
+
}
|
47
|
+
return this;
|
48
|
+
};
|
49
|
+
/**
|
50
|
+
* Set the upper and lower bounds of this box to include all of the points in points.
|
51
|
+
* @param points Input an array of 3d point or 3d vector that the resulting box will contain.
|
52
|
+
* @returns Return this box
|
53
|
+
*/
|
54
|
+
AcGeBox3d.prototype.setFromPoints = function (points) {
|
55
|
+
this.makeEmpty();
|
56
|
+
for (var i = 0, il = points.length; i < il; i++) {
|
57
|
+
this.expandByPoint(points[i]);
|
58
|
+
}
|
59
|
+
return this;
|
60
|
+
};
|
61
|
+
/**
|
62
|
+
* Center this box on center and set this box's width, height and depth to the values specified in size
|
63
|
+
* @param center Input the desired center position of the box.
|
64
|
+
* @param size Input the desired x, y and z dimensions of the box.
|
65
|
+
* @returns Return this box
|
66
|
+
*/
|
67
|
+
AcGeBox3d.prototype.setFromCenterAndSize = function (center, size) {
|
68
|
+
var halfSize = _vector.copy(size).multiplyScalar(0.5);
|
69
|
+
this.min.copy(center).sub(halfSize);
|
70
|
+
this.max.copy(center).add(halfSize);
|
71
|
+
return this;
|
72
|
+
};
|
73
|
+
/**
|
74
|
+
* Return a new box with the same min and max as this one.
|
75
|
+
* @returns Return a new box with the same min and max as this one.
|
76
|
+
*/
|
77
|
+
AcGeBox3d.prototype.clone = function () {
|
78
|
+
return new AcGeBox3d().copy(this);
|
79
|
+
};
|
80
|
+
/**
|
81
|
+
* Copy the min and max from box to this box.
|
82
|
+
* @param box Input box to copy.
|
83
|
+
* @returns Return this box
|
84
|
+
*/
|
85
|
+
AcGeBox3d.prototype.copy = function (box) {
|
86
|
+
this.min.copy(box.min);
|
87
|
+
this.max.copy(box.max);
|
88
|
+
return this;
|
89
|
+
};
|
90
|
+
/**
|
91
|
+
* Make this box empty.
|
92
|
+
* @returns Return this box
|
93
|
+
*/
|
94
|
+
AcGeBox3d.prototype.makeEmpty = function () {
|
95
|
+
this.min.x = this.min.y = this.min.z = +Infinity;
|
96
|
+
this.max.x = this.max.y = this.max.z = -Infinity;
|
97
|
+
return this;
|
98
|
+
};
|
99
|
+
/**
|
100
|
+
* Return true if this box includes zero points within its bounds.
|
101
|
+
* Note that a box with equal lower and upper bounds still includes one point, the one both bounds share.
|
102
|
+
* @returns Return true if this box includes zero points within its bounds.
|
103
|
+
*/
|
104
|
+
AcGeBox3d.prototype.isEmpty = function () {
|
105
|
+
// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
|
106
|
+
return (this.max.x < this.min.x ||
|
107
|
+
this.max.y < this.min.y ||
|
108
|
+
this.max.z < this.min.z);
|
109
|
+
};
|
110
|
+
/**
|
111
|
+
* Return the center point of the box as a 3d vector.
|
112
|
+
* @param target Input the result copied into this 3d vector.
|
113
|
+
* @returns Return the center point of the box
|
114
|
+
*/
|
115
|
+
AcGeBox3d.prototype.getCenter = function (target) {
|
116
|
+
return this.isEmpty()
|
117
|
+
? target.set(0, 0, 0)
|
118
|
+
: target.addVectors(this.min, this.max).multiplyScalar(0.5);
|
119
|
+
};
|
120
|
+
/**
|
121
|
+
* Return the width, height and depth of this box.
|
122
|
+
* @param target Return the result copied into this 3d vector.
|
123
|
+
* @returns Return the width, height and depth of this box.
|
124
|
+
*/
|
125
|
+
AcGeBox3d.prototype.getSize = function (target) {
|
126
|
+
return this.isEmpty()
|
127
|
+
? target.set(0, 0, 0)
|
128
|
+
: target.subVectors(this.max, this.min);
|
129
|
+
};
|
130
|
+
Object.defineProperty(AcGeBox3d.prototype, "center", {
|
131
|
+
/**
|
132
|
+
* Center point of this box
|
133
|
+
*/
|
134
|
+
get: function () {
|
135
|
+
return this.isEmpty()
|
136
|
+
? new AcGeVector3d(0, 0, 0)
|
137
|
+
: new AcGeVector3d(0, 0, 0)
|
138
|
+
.addVectors(this.min, this.max)
|
139
|
+
.multiplyScalar(0.5);
|
140
|
+
},
|
141
|
+
enumerable: false,
|
142
|
+
configurable: true
|
143
|
+
});
|
144
|
+
Object.defineProperty(AcGeBox3d.prototype, "size", {
|
145
|
+
/**
|
146
|
+
* Return the width, height and depth of this box.
|
147
|
+
*/
|
148
|
+
get: function () {
|
149
|
+
return this.isEmpty()
|
150
|
+
? new AcGeVector3d(0, 0, 0)
|
151
|
+
: new AcGeVector3d(0, 0, 0).subVectors(this.max, this.min);
|
152
|
+
},
|
153
|
+
enumerable: false,
|
154
|
+
configurable: true
|
155
|
+
});
|
156
|
+
/**
|
157
|
+
* Expand the boundaries of this box to include point.
|
158
|
+
* @param point
|
159
|
+
* @returns
|
160
|
+
*/
|
161
|
+
AcGeBox3d.prototype.expandByPoint = function (point) {
|
162
|
+
this.min.min(point);
|
163
|
+
this.max.max(point);
|
164
|
+
return this;
|
165
|
+
};
|
166
|
+
/**
|
167
|
+
* Expand this box equilaterally by vector. The width of this box will be expanded by the x component
|
168
|
+
* of vector in both directions. The height of this box will be expanded by the y component of vector
|
169
|
+
* in both directions. The depth of this box will be expanded by the z component of vector in both
|
170
|
+
* directions.
|
171
|
+
* @param vector Input one 3d vector to expand the box by.
|
172
|
+
* @returns Return this box
|
173
|
+
*/
|
174
|
+
AcGeBox3d.prototype.expandByVector = function (vector) {
|
175
|
+
this.min.sub(vector);
|
176
|
+
this.max.add(vector);
|
177
|
+
return this;
|
178
|
+
};
|
179
|
+
/**
|
180
|
+
* Expand each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.
|
181
|
+
* @param scalar Input distance to expand the box by.
|
182
|
+
* @returns Return this box
|
183
|
+
*/
|
184
|
+
AcGeBox3d.prototype.expandByScalar = function (scalar) {
|
185
|
+
this.min.addScalar(-scalar);
|
186
|
+
this.max.addScalar(scalar);
|
187
|
+
return this;
|
188
|
+
};
|
189
|
+
/**
|
190
|
+
* Return true if the specified point lies within or on the boundaries of this box.
|
191
|
+
* @param point Input point to check for inclusion.
|
192
|
+
* @returns Return true if the specified point lies within or on the boundaries of this box.
|
193
|
+
*/
|
194
|
+
AcGeBox3d.prototype.containsPoint = function (point) {
|
195
|
+
return point.x < this.min.x ||
|
196
|
+
point.x > this.max.x ||
|
197
|
+
point.y < this.min.y ||
|
198
|
+
point.y > this.max.y ||
|
199
|
+
point.z < this.min.z ||
|
200
|
+
point.z > this.max.z
|
201
|
+
? false
|
202
|
+
: true;
|
203
|
+
};
|
204
|
+
/**
|
205
|
+
* Return true if this box includes the entirety of box. If this and box are identical,
|
206
|
+
* this function also returns true.
|
207
|
+
* @param box Input 3d box to test for inclusion.
|
208
|
+
* @returns Return true if this box includes the entirety of box.
|
209
|
+
*/
|
210
|
+
AcGeBox3d.prototype.containsBox = function (box) {
|
211
|
+
return (this.min.x <= box.min.x &&
|
212
|
+
box.max.x <= this.max.x &&
|
213
|
+
this.min.y <= box.min.y &&
|
214
|
+
box.max.y <= this.max.y &&
|
215
|
+
this.min.z <= box.min.z &&
|
216
|
+
box.max.z <= this.max.z);
|
217
|
+
};
|
218
|
+
/**
|
219
|
+
* Return a point as a proportion of this box's width, height and depth.
|
220
|
+
* @param point Input one point
|
221
|
+
* @param target Input the result will be copied into this Vector3.
|
222
|
+
* @returns Return one point
|
223
|
+
*/
|
224
|
+
AcGeBox3d.prototype.getParameter = function (point, target) {
|
225
|
+
// This can potentially have a divide by zero if the box
|
226
|
+
// has a size dimension of 0.
|
227
|
+
return target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y), (point.z - this.min.z) / (this.max.z - this.min.z));
|
228
|
+
};
|
229
|
+
/**
|
230
|
+
* Determine whether or not this box intersects box.
|
231
|
+
* @param box Input 3d box to check for intersection against.
|
232
|
+
* @returns Return true if this box intersects the specified box.
|
233
|
+
*/
|
234
|
+
AcGeBox3d.prototype.intersectsBox = function (box) {
|
235
|
+
// using 6 splitting planes to rule out intersections.
|
236
|
+
return box.max.x < this.min.x ||
|
237
|
+
box.min.x > this.max.x ||
|
238
|
+
box.max.y < this.min.y ||
|
239
|
+
box.min.y > this.max.y ||
|
240
|
+
box.max.z < this.min.z ||
|
241
|
+
box.min.z > this.max.z
|
242
|
+
? false
|
243
|
+
: true;
|
244
|
+
};
|
245
|
+
/**
|
246
|
+
* Determine whether or not this box intersects plane.
|
247
|
+
* @param plane Input the plane to check for intersection against.
|
248
|
+
* @returns Return true if this box intersects the specified plane.
|
249
|
+
*/
|
250
|
+
AcGeBox3d.prototype.intersectsPlane = function (plane) {
|
251
|
+
// We compute the minimum and maximum dot product values. If those values
|
252
|
+
// are on the same side (back or front) of the plane, then there is no intersection.
|
253
|
+
var min, max;
|
254
|
+
if (plane.normal.x > 0) {
|
255
|
+
min = plane.normal.x * this.min.x;
|
256
|
+
max = plane.normal.x * this.max.x;
|
257
|
+
}
|
258
|
+
else {
|
259
|
+
min = plane.normal.x * this.max.x;
|
260
|
+
max = plane.normal.x * this.min.x;
|
261
|
+
}
|
262
|
+
if (plane.normal.y > 0) {
|
263
|
+
min += plane.normal.y * this.min.y;
|
264
|
+
max += plane.normal.y * this.max.y;
|
265
|
+
}
|
266
|
+
else {
|
267
|
+
min += plane.normal.y * this.max.y;
|
268
|
+
max += plane.normal.y * this.min.y;
|
269
|
+
}
|
270
|
+
if (plane.normal.z > 0) {
|
271
|
+
min += plane.normal.z * this.min.z;
|
272
|
+
max += plane.normal.z * this.max.z;
|
273
|
+
}
|
274
|
+
else {
|
275
|
+
min += plane.normal.z * this.max.z;
|
276
|
+
max += plane.normal.z * this.min.z;
|
277
|
+
}
|
278
|
+
return min <= -plane.constant && max >= -plane.constant;
|
279
|
+
};
|
280
|
+
/**
|
281
|
+
* Clamp the point within the bounds of this box.
|
282
|
+
* @param point Input the point to clamp.
|
283
|
+
* @param target Input the result will be copied into this 3d vector.
|
284
|
+
* @returns Return the target
|
285
|
+
*/
|
286
|
+
AcGeBox3d.prototype.clampPoint = function (point, target) {
|
287
|
+
return target.copy(point).clamp(this.min, this.max);
|
288
|
+
};
|
289
|
+
/**
|
290
|
+
* Returns the distance from any edge of this box to the specified point. If the point lies inside of
|
291
|
+
* this box, the distance will be 0.
|
292
|
+
* @param point Input one 3d point to measure distance to.
|
293
|
+
* @returns Return the distance from any edge of this box to the specified point.
|
294
|
+
*/
|
295
|
+
AcGeBox3d.prototype.distanceToPoint = function (point) {
|
296
|
+
return this.clampPoint(point, _vector).distanceTo(point);
|
297
|
+
};
|
298
|
+
/**
|
299
|
+
* Compute the intersection of this and box, setting the upper bound of this box to the lesser of the
|
300
|
+
* two boxes' upper bounds and the lower bound of this box to the greater of the two boxes' lower bounds.
|
301
|
+
* If there's no overlap, makes this box empty.
|
302
|
+
* @param box Input 3d box to intersect with.
|
303
|
+
* @returns Return this box
|
304
|
+
*/
|
305
|
+
AcGeBox3d.prototype.intersect = function (box) {
|
306
|
+
this.min.max(box.min);
|
307
|
+
this.max.min(box.max);
|
308
|
+
// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
|
309
|
+
if (this.isEmpty())
|
310
|
+
this.makeEmpty();
|
311
|
+
return this;
|
312
|
+
};
|
313
|
+
/**
|
314
|
+
* Compute the union of this box and box, setting the upper bound of this box to the greater of the two
|
315
|
+
* boxes' upper bounds and the lower bound of this box to the lesser of the two boxes' lower bounds.
|
316
|
+
* @param box Input the 3d box that will be unioned with this box.
|
317
|
+
* @returns Return this box
|
318
|
+
*/
|
319
|
+
AcGeBox3d.prototype.union = function (box) {
|
320
|
+
this.min.min(box.min);
|
321
|
+
this.max.max(box.max);
|
322
|
+
return this;
|
323
|
+
};
|
324
|
+
/**
|
325
|
+
* Transform this box with the supplied matrix.
|
326
|
+
* @param matrix Input 4x4 matrix to apply
|
327
|
+
* @returns Return this box
|
328
|
+
*/
|
329
|
+
AcGeBox3d.prototype.applyMatrix4 = function (matrix) {
|
330
|
+
// transform of empty box is an empty box.
|
331
|
+
if (this.isEmpty())
|
332
|
+
return this;
|
333
|
+
// NOTE: I am using a binary pattern to specify all 2^3 combinations below
|
334
|
+
_points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix3d(matrix); // 000
|
335
|
+
_points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix3d(matrix); // 001
|
336
|
+
_points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix3d(matrix); // 010
|
337
|
+
_points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix3d(matrix); // 011
|
338
|
+
_points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix3d(matrix); // 100
|
339
|
+
_points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix3d(matrix); // 101
|
340
|
+
_points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix3d(matrix); // 110
|
341
|
+
_points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix3d(matrix); // 111
|
342
|
+
this.setFromPoints(_points);
|
343
|
+
return this;
|
344
|
+
};
|
345
|
+
/**
|
346
|
+
* Add offset to both the upper and lower bounds of this box, effectively moving this box offset units
|
347
|
+
* in 3d space.
|
348
|
+
* @param offset Input direction and distance of offset.
|
349
|
+
* @returns Return this box
|
350
|
+
*/
|
351
|
+
AcGeBox3d.prototype.translate = function (offset) {
|
352
|
+
this.min.add(offset);
|
353
|
+
this.max.add(offset);
|
354
|
+
return this;
|
355
|
+
};
|
356
|
+
/**
|
357
|
+
* Return true if this box and box share the same lower and upper bounds.
|
358
|
+
* @param box Input box to compare with this one.
|
359
|
+
* @returns Return true if this box and box share the same lower and upper bounds.
|
360
|
+
*/
|
361
|
+
AcGeBox3d.prototype.equals = function (box) {
|
362
|
+
return box.min.equals(this.min) && box.max.equals(this.max);
|
363
|
+
};
|
364
|
+
return AcGeBox3d;
|
365
|
+
}());
|
366
|
+
export { AcGeBox3d };
|
367
|
+
var _points = [
|
368
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
369
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
370
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
371
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
372
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
373
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
374
|
+
/*@__PURE__*/ new AcGeVector3d(),
|
375
|
+
/*@__PURE__*/ new AcGeVector3d()
|
376
|
+
];
|
377
|
+
var _vector = /*@__PURE__*/ new AcGeVector3d();
|
378
|
+
//# sourceMappingURL=AcGeBox3d.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeBox3d.js","sourceRoot":"","sources":["../../src/math/AcGeBox3d.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAA;AAE/D;;GAEG;AACH;IAUE;;;;;;OAMG;IACH,mBACE,GAA6C,EAC7C,GAA6C;QAD7C,oBAAA,EAAA,eAA6C;QAC7C,oBAAA,EAAA,eAA6C;QAE7C,IAAI,CAAC,GAAG;YACN,GAAG,IAAI,IAAI;gBACT,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBACnD,CAAC,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;QAC3C,IAAI,CAAC,GAAG;YACN,GAAG,IAAI,IAAI;gBACT,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBACnD,CAAC,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,uBAAG,GAAH,UAAI,GAAqB,EAAE,GAAqB;QAC9C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAElB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,gCAAY,GAAZ,UAAa,KAAe;QAC1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AAI,YAAY,EAAE;CACjC,CAAA;AAED,IAAM,OAAO,GAAG,aAAa,CAAC,IAAI,YAAY,EAAE,CAAA"}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import { AcGeMatrix3d } from './AcGeMatrix3d';
|
2
|
+
import { AcGeQuaternion } from './AcGeQuaternion';
|
3
|
+
import { AcGeVector3d } from './AcGeVector3d';
|
4
|
+
export declare class AcGeEuler {
|
5
|
+
static DEFAULT_ORDER: string;
|
6
|
+
private _x;
|
7
|
+
private _y;
|
8
|
+
private _z;
|
9
|
+
private _order;
|
10
|
+
/**
|
11
|
+
* Create one instance of this class
|
12
|
+
* @param x (optional) the angle of the x axis in radians. Default is 0.
|
13
|
+
* @param y (optional) the angle of the y axis in radians. Default is 0.
|
14
|
+
* @param z (optional) the angle of the z axis in radians. Default is 0.
|
15
|
+
* @param order (optional) a string representing the order that the rotations are applied,
|
16
|
+
* defaults to 'XYZ' (must be upper case).
|
17
|
+
*/
|
18
|
+
constructor(x?: number, y?: number, z?: number, order?: string);
|
19
|
+
/**
|
20
|
+
* The current value of the x component.
|
21
|
+
*/
|
22
|
+
get x(): number;
|
23
|
+
set x(value: number);
|
24
|
+
/**
|
25
|
+
* The current value of the y component.
|
26
|
+
*/
|
27
|
+
get y(): number;
|
28
|
+
set y(value: number);
|
29
|
+
/**
|
30
|
+
* The current value of the z component.
|
31
|
+
*/
|
32
|
+
get z(): number;
|
33
|
+
set z(value: number);
|
34
|
+
/**
|
35
|
+
* The order in which to apply rotations. Default is 'XYZ', which means that the object will first be
|
36
|
+
* rotated around its X axis, then its Y axis and finally its Z axis. Other possibilities are: 'YZX',
|
37
|
+
* 'ZXY', 'XZY', 'YXZ' and 'ZYX'. These must be in upper case.
|
38
|
+
*
|
39
|
+
* It uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the
|
40
|
+
* local coordinate system. That is, for order 'XYZ', the rotation is first around the local-X axis
|
41
|
+
* (which is the same as the world-X axis), then around local-Y (which may now be different from the
|
42
|
+
* world Y-axis), then local-Z (which may be different from the world Z-axis).
|
43
|
+
*/
|
44
|
+
get order(): string;
|
45
|
+
set order(value: string);
|
46
|
+
/**
|
47
|
+
* Set the angles of this euler transform and optionally the order.
|
48
|
+
* @param x (optional) the angle of the x axis in radians. Default is 0.
|
49
|
+
* @param y (optional) the angle of the y axis in radians. Default is 0.
|
50
|
+
* @param z (optional) the angle of the z axis in radians. Default is 0.
|
51
|
+
* @param order (optional) a string representing the order that the rotations are applied,
|
52
|
+
* defaults to 'XYZ' (must be upper case).
|
53
|
+
* @returns Return this euler
|
54
|
+
*/
|
55
|
+
set(x: number, y: number, z: number, order?: string): this;
|
56
|
+
/**
|
57
|
+
* Return a new Euler with the same parameters as this one.
|
58
|
+
* @returns Return a new Euler with the same parameters as this one.
|
59
|
+
*/
|
60
|
+
clone(): AcGeEuler;
|
61
|
+
/**
|
62
|
+
* Copy value of euler to this euler.
|
63
|
+
* @param euler Input the eurler copied from
|
64
|
+
* @returns Return this euler
|
65
|
+
*/
|
66
|
+
copy(euler: AcGeEuler): this;
|
67
|
+
/**
|
68
|
+
* Set this euler by exatracting rotation information from the specified matrix.
|
69
|
+
* @param m Input a Matrix4 of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
|
70
|
+
* @param order (optional) a string representing the order that the rotations are applied. Sets the
|
71
|
+
* angles of this euler transform from a pure rotation matrix based on the orientation specified by
|
72
|
+
* order.
|
73
|
+
* @param update Input one flag to indicate whether to trigger change callback function
|
74
|
+
* @returns Return this euler
|
75
|
+
*/
|
76
|
+
setFromRotationMatrix(m: AcGeMatrix3d, order?: string, update?: boolean): this;
|
77
|
+
/**
|
78
|
+
* Set this urler from the specified quaternion.
|
79
|
+
* @param q Input a normalized quaternion.
|
80
|
+
* @param order (optional) a string representing the order that the rotations are applied. Sets the
|
81
|
+
* angles of this euler transform from a pure rotation matrix based on the orientation specified by
|
82
|
+
* order.
|
83
|
+
* @param update Input one flag to indicate whether to trigger change callback function
|
84
|
+
* @returns Return this euler
|
85
|
+
*/
|
86
|
+
setFromQuaternion(q: AcGeQuaternion, order: string, update?: boolean): this;
|
87
|
+
/**
|
88
|
+
* Set the x, y and z, and optionally update the order.
|
89
|
+
* @param v Input one 3d vector
|
90
|
+
* @param order Input a optional string representing the order that the rotations are applied.
|
91
|
+
* @returns Return this euler
|
92
|
+
*/
|
93
|
+
setFromVector3(v: AcGeVector3d, order?: string): this;
|
94
|
+
/**
|
95
|
+
* Resets the euler angle with a new order by creating a quaternion from this euler angle and then
|
96
|
+
* setting this euler angle with the quaternion and the new order.
|
97
|
+
* @param newOrder Input the new order that the rotations are applied.
|
98
|
+
* @returns Return this euler
|
99
|
+
*/
|
100
|
+
reorder(newOrder: string): this;
|
101
|
+
/**
|
102
|
+
* Check for strict equality of this euler and euler.
|
103
|
+
* @param euler Input the euler to compare
|
104
|
+
* @returns Return true if the specified euler and this euler represent the same rotation.
|
105
|
+
*/
|
106
|
+
equals(euler: AcGeEuler): boolean;
|
107
|
+
/**
|
108
|
+
* Set this euler from the specified array.
|
109
|
+
* @param array Input an array of length 3 or 4. The optional 4th argument corresponds to the order.
|
110
|
+
* - Assign this euler's x angle to array[0].
|
111
|
+
* - Assign this euler's y angle to array[1].
|
112
|
+
* - Assign this euler's z angle to array[2].
|
113
|
+
* - Optionally assign this euler's order to array[3].
|
114
|
+
* @returns
|
115
|
+
*/
|
116
|
+
fromArray(array: (number | string)[]): this;
|
117
|
+
/**
|
118
|
+
* Return an array of the form [x, y, z, order ].
|
119
|
+
* @param array Input an optional array to store the euler in.
|
120
|
+
* @param offset Input an optional offset in the array.
|
121
|
+
* @returns Return an array of the form [x, y, z, order].
|
122
|
+
*/
|
123
|
+
toArray(array?: (number | string)[], offset?: number): (string | number)[];
|
124
|
+
/**
|
125
|
+
* Trigger the specified callback function once this euler changes
|
126
|
+
* @param callback
|
127
|
+
* @returns
|
128
|
+
*/
|
129
|
+
_onChange(callback: () => void): this;
|
130
|
+
_onChangeCallback(): void;
|
131
|
+
[Symbol.iterator](): Generator<string | number, void, unknown>;
|
132
|
+
}
|
133
|
+
//# sourceMappingURL=AcGeEuler.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AcGeEuler.d.ts","sourceRoot":"","sources":["../../src/math/AcGeEuler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK7C,qBAAa,SAAS;IACpB,MAAM,CAAC,aAAa,SAAQ;IAC5B,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,EAAE,CAAQ;IAClB,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;;;;;OAOG;gBACS,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,KAAK,SAA0B;IAOhE;;OAEG;IACH,IAAI,CAAC,IAGQ,MAAM,CADlB;IACD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAGlB;IAED;;OAEG;IACH,IAAI,CAAC,IAGQ,MAAM,CADlB;IACD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAGlB;IAED;;OAEG;IACH,IAAI,CAAC,IAGQ,MAAM,CADlB;IACD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAGlB;IAED;;;;;;;;;OASG;IACH,IAAI,KAAK,IAGQ,MAAM,CADtB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,SAAc;IAWxD;;;OAGG;IACH,KAAK;IAIL;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,SAAS;IAUrB;;;;;;;;OAQG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