@itwin/core-geometry 4.0.0-dev.55 → 4.0.0-dev.56
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/lib/cjs/Geometry.d.ts +5 -1
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +5 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +29 -34
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js +31 -36
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +48 -43
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +48 -43
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +5 -8
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +5 -8
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +3 -3
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.js +3 -3
- package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +8 -10
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js +8 -10
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts +37 -34
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +38 -35
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +17 -21
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js +16 -20
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +84 -67
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +84 -67
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +76 -66
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +88 -77
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts +15 -16
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js +14 -15
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts +72 -58
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +132 -108
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/Geometry.d.ts +5 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +5 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +29 -34
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js +31 -36
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +48 -43
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +48 -43
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +5 -8
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +5 -8
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +3 -3
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.js +3 -3
- package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +8 -10
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.js +8 -10
- package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.d.ts +37 -34
- package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +38 -35
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +17 -21
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js +16 -20
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +84 -67
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +84 -67
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +76 -66
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +88 -77
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts +15 -16
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js +14 -15
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts +72 -58
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +132 -108
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/package.json +3 -3
|
@@ -145,7 +145,7 @@ class Transform {
|
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* Return a modified copy of `this` Transform so that its `matrix` part is rigid (`origin` part is untouched).
|
|
148
|
-
* *
|
|
148
|
+
* * @see [[Matrix3d.axisOrderCrossProductsInPlace]] documentation for details of how the matrix is modified to rigid.
|
|
149
149
|
*/
|
|
150
150
|
cloneRigid(axisOrder = Geometry_1.AxisOrder.XYZ) {
|
|
151
151
|
const modifiedMatrix = Matrix3d_1.Matrix3d.createRigidFromMatrix3d(this.matrix, axisOrder);
|
|
@@ -153,7 +153,7 @@ class Transform {
|
|
|
153
153
|
return undefined;
|
|
154
154
|
return new Transform(this.origin.cloneAsPoint3d(), modifiedMatrix);
|
|
155
155
|
}
|
|
156
|
-
/** Create a Transform with the given `origin` and `matrix`. */
|
|
156
|
+
/** Create a Transform with the given `origin` and `matrix`. Inputs are captured, not cloned. */
|
|
157
157
|
static createRefs(origin, matrix, result) {
|
|
158
158
|
if (!origin)
|
|
159
159
|
origin = Point3dVector3d_1.Point3d.createZero();
|
|
@@ -164,7 +164,7 @@ class Transform {
|
|
|
164
164
|
}
|
|
165
165
|
return new Transform(origin, matrix);
|
|
166
166
|
}
|
|
167
|
-
/** Create a Transform with complete contents given */
|
|
167
|
+
/** Create a Transform with complete contents given. `q` inputs make the matrix and `a` inputs make the origin */
|
|
168
168
|
static createRowValues(qxx, qxy, qxz, ax, qyx, qyy, qyz, ay, qzx, qzy, qzz, az, result) {
|
|
169
169
|
if (result) {
|
|
170
170
|
result._origin.set(ax, ay, az);
|
|
@@ -179,6 +179,8 @@ class Transform {
|
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* Create a Transform with translation provided by x,y,z parts.
|
|
182
|
+
* * Translation Transform maps any vector `v` to `v + p` where `p = (x,y,z)`
|
|
183
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/MoveCube
|
|
182
184
|
* @param x x part of translation
|
|
183
185
|
* @param y y part of translation
|
|
184
186
|
* @param z z part of translation
|
|
@@ -190,6 +192,8 @@ class Transform {
|
|
|
190
192
|
}
|
|
191
193
|
/**
|
|
192
194
|
* Create a Transform with specified `translation` part.
|
|
195
|
+
* * Translation Transform maps any vector `v` to `v + translation`
|
|
196
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/MoveCube
|
|
193
197
|
* @param translation x,y,z parts of the translation
|
|
194
198
|
* @param result optional pre-allocated Transform
|
|
195
199
|
* @returns new or updated transform
|
|
@@ -236,6 +240,7 @@ class Transform {
|
|
|
236
240
|
* local-to-world mapping.
|
|
237
241
|
* * This function is a closely related to `createFixedPointAndMatrix` whose point input is the fixed point
|
|
238
242
|
* of the world-to-world transformation.
|
|
243
|
+
* * If origin is `undefined`, (0,0,0) is used. If matrix is `undefined` the identity matrix is used.
|
|
239
244
|
*/
|
|
240
245
|
static createOriginAndMatrix(origin, matrix, result) {
|
|
241
246
|
if (result) {
|
|
@@ -261,7 +266,7 @@ class Transform {
|
|
|
261
266
|
}
|
|
262
267
|
/**
|
|
263
268
|
* Create a Transform such that its `matrix` part is rigid.
|
|
264
|
-
*
|
|
269
|
+
* @see [[Matrix3d.createRigidFromColumns]] for details of how the matrix is created to be rigid.
|
|
265
270
|
*/
|
|
266
271
|
static createRigidFromOriginAndColumns(origin, vectorX, vectorY, axisOrder, result) {
|
|
267
272
|
const matrix = Matrix3d_1.Matrix3d.createRigidFromColumns(vectorX, vectorY, axisOrder, result ? result._matrix : undefined);
|
|
@@ -273,10 +278,10 @@ class Transform {
|
|
|
273
278
|
return result;
|
|
274
279
|
}
|
|
275
280
|
/**
|
|
276
|
-
* We don't want to pass "origin" to createRefs because createRefs does not clone "origin"
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
281
|
+
* We don't want to pass "origin" to createRefs because createRefs does not clone "origin". That means if "origin"
|
|
282
|
+
* is changed via Transform at any point, the initial "origin" passed by the user is also changed. To avoid that,
|
|
283
|
+
* we pass "undefined" to createRefs so that it allocates a new point which then we set it to the "origin" which
|
|
284
|
+
* is passed by user in the next line.
|
|
280
285
|
*/
|
|
281
286
|
result = Transform.createRefs(undefined, matrix);
|
|
282
287
|
result._origin.setFromPoint3d(origin);
|
|
@@ -299,18 +304,19 @@ class Transform {
|
|
|
299
304
|
return Transform.createRefs(undefined, matrix.clone());
|
|
300
305
|
}
|
|
301
306
|
/**
|
|
302
|
-
* Create a transform with the specified `matrix` and points `a` and `b`. The returned Transform
|
|
303
|
-
* point `p` to `M*(p-a) + b` (i.e., `Tp = M*(p-a) + b`) so
|
|
307
|
+
* Create a transform with the specified `matrix` and points `a` and `b`. The returned Transform maps
|
|
308
|
+
* point `p` to `M*(p-a) + b` (i.e., `Tp = M*(p-a) + b`), so maps `a` to 'b'.
|
|
304
309
|
*/
|
|
305
310
|
static createMatrixPickupPutdown(matrix, a, b, result) {
|
|
306
|
-
// we define the origin o = b - M*a so Tp = M*p + o = M*p + (b - M*a) = M*(
|
|
311
|
+
// we define the origin o = b - M*a so Tp = M*p + o = M*p + (b - M*a) = M*(p-a) + b
|
|
307
312
|
const origin = Matrix3d_1.Matrix3d.xyzMinusMatrixTimesXYZ(b, matrix, a);
|
|
308
313
|
return Transform.createRefs(origin, matrix.clone(), result);
|
|
309
314
|
}
|
|
310
315
|
/**
|
|
311
316
|
* Create a Transform which leaves the fixedPoint unchanged and scales everything else around it by
|
|
312
|
-
* a single scale factor. The returned Transform
|
|
317
|
+
* a single scale factor. The returned Transform maps a point `p` to `M*p + (f - M*f)`
|
|
313
318
|
* where `f` is the fixedPoint and M is the scale matrix (i.e., `Tp = M*(p-f) + f`).
|
|
319
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ScaleCube
|
|
314
320
|
*/
|
|
315
321
|
static createScaleAboutPoint(fixedPoint, scale, result) {
|
|
316
322
|
const matrix = Matrix3d_1.Matrix3d.createScale(scale, scale, scale);
|
|
@@ -352,8 +358,7 @@ class Transform {
|
|
|
352
358
|
return Matrix3d_1.Matrix3d.xyzPlusMatrixTimesCoordinates(this._origin, this._matrix, x, y, z, result);
|
|
353
359
|
}
|
|
354
360
|
/**
|
|
355
|
-
* Multiply a specific row (component) of the
|
|
356
|
-
* at the same row. Return the result.
|
|
361
|
+
* Multiply a specific row (component) of the 3x4 instance times (x,y,z,1). Return the result.
|
|
357
362
|
*/
|
|
358
363
|
multiplyComponentXYZ(componentIndex, x, y, z = 0) {
|
|
359
364
|
const coffs = this._matrix.coffs;
|
|
@@ -361,8 +366,7 @@ class Transform {
|
|
|
361
366
|
return this.origin.at(componentIndex) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);
|
|
362
367
|
}
|
|
363
368
|
/**
|
|
364
|
-
* Multiply a specific row (component) of the
|
|
365
|
-
* at the same row times w. Return the result.
|
|
369
|
+
* Multiply a specific row (component) of the 3x4 instance times (x,y,z,w). Return the result.
|
|
366
370
|
*/
|
|
367
371
|
multiplyComponentXYZW(componentIndex, x, y, z, w) {
|
|
368
372
|
const coffs = this._matrix.coffs;
|
|
@@ -370,31 +374,38 @@ class Transform {
|
|
|
370
374
|
return (this.origin.at(componentIndex) * w) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);
|
|
371
375
|
}
|
|
372
376
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
377
|
+
* Transform the homogeneous point. Return as a new `Point4d`, or in the pre-allocated result (if result is given).
|
|
378
|
+
* * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Point4d` formed by `Tp` in the
|
|
379
|
+
* first three coordinates, and `w` in the fourth.
|
|
380
|
+
* * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.
|
|
375
381
|
*/
|
|
376
382
|
multiplyXYZW(x, y, z, w, result) {
|
|
377
383
|
return Matrix3d_1.Matrix3d.xyzPlusMatrixTimesWeightedCoordinates(this._origin, this._matrix, x, y, z, w, result);
|
|
378
384
|
}
|
|
379
385
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* (
|
|
386
|
+
* Transform the homogeneous point. Return as new `Float64Array` with size 4, or in the pre-allocated result (if
|
|
387
|
+
* result is given).
|
|
388
|
+
* * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Float64Array` formed by `Tp`
|
|
389
|
+
* in the first 3 numbers of the array and `w` as the fourth.
|
|
390
|
+
* * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.
|
|
383
391
|
*/
|
|
384
392
|
multiplyXYZWToFloat64Array(x, y, z, w, result) {
|
|
385
393
|
return Matrix3d_1.Matrix3d.xyzPlusMatrixTimesWeightedCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, w, result);
|
|
386
394
|
}
|
|
387
395
|
/**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
396
|
+
* * Transform the point. Return as new `Float64Array` with size 3, or in the pre-allocated result (if result is given).
|
|
397
|
+
* * If `p = (x,y,z)` then this method computes `Tp = M*p + o` and returns it as the first 3 elements of the array.
|
|
390
398
|
*/
|
|
391
399
|
multiplyXYZToFloat64Array(x, y, z, result) {
|
|
392
400
|
return Matrix3d_1.Matrix3d.xyzPlusMatrixTimesCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, result);
|
|
393
401
|
}
|
|
394
402
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
403
|
+
* Multiply the homogeneous point by the transpose of `this` Transform. Return as a new `Point4d` or in the
|
|
404
|
+
* pre-allocated result (if result is given).
|
|
405
|
+
* * If `p = (x,y,z)` then this method computes `M^t*p` and returns it in the first three coordinates of the `Point4d`,
|
|
406
|
+
* and `o*p + w` in the fourth.
|
|
407
|
+
* * Logically, this is multiplication by the transpose of the 4x4 matrix formed from the 3x4 instance augmented with
|
|
408
|
+
* fourth row 0001.
|
|
398
409
|
*/
|
|
399
410
|
multiplyTransposeXYZW(x, y, z, w, result) {
|
|
400
411
|
const coffs = this._matrix.coffs;
|
|
@@ -413,9 +424,9 @@ class Transform {
|
|
|
413
424
|
this.multiplyPoint3dArrayInPlace(chain);
|
|
414
425
|
}
|
|
415
426
|
/**
|
|
416
|
-
*
|
|
417
|
-
* `p = MInverse
|
|
418
|
-
*
|
|
427
|
+
* Multiply the point by the inverse Transform.
|
|
428
|
+
* * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse`
|
|
429
|
+
* Transform has matrix part `MInverse` and origin part `-MInverse*o`.
|
|
419
430
|
* * Return as a new point or in the optional `result`.
|
|
420
431
|
* * Returns `undefined` if the `matrix` part if this Transform is singular.
|
|
421
432
|
*/
|
|
@@ -423,9 +434,13 @@ class Transform {
|
|
|
423
434
|
return this._matrix.multiplyInverseXYZAsPoint3d(point.x - this._origin.x, point.y - this._origin.y, point.z - this._origin.z, result);
|
|
424
435
|
}
|
|
425
436
|
/**
|
|
426
|
-
*
|
|
427
|
-
* `p =
|
|
428
|
-
*
|
|
437
|
+
* Multiply the homogenous point by the inverse Transform.
|
|
438
|
+
* * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform
|
|
439
|
+
* has matrix part `MInverse` and origin part `-MInverse*o`.
|
|
440
|
+
* * This method computes `TInverse p = MInverse*p - w*MInverse*o` and returns the `Point4d` formed by `TInverse*p`
|
|
441
|
+
* in the first three coordinates, and `w` in the fourth.
|
|
442
|
+
* * Logically, this is multiplication by the inverse of the 4x4 matrix formed from the 3x4 instance augmented with
|
|
443
|
+
* fourth row 0001. This is equivalent to the 4x4 matrix formed in similar fashion from the inverse of this instance.
|
|
429
444
|
* * Return as a new point or in the optional `result`.
|
|
430
445
|
* * Returns `undefined` if the `matrix` part if this Transform is singular.
|
|
431
446
|
*/
|
|
@@ -434,9 +449,9 @@ class Transform {
|
|
|
434
449
|
return this._matrix.multiplyInverseXYZW(weightedPoint.x - w * this.origin.x, weightedPoint.y - w * this.origin.y, weightedPoint.z - w * this.origin.z, w, result);
|
|
435
450
|
}
|
|
436
451
|
/**
|
|
437
|
-
*
|
|
438
|
-
* `p = MInverse
|
|
439
|
-
*
|
|
452
|
+
* Multiply the point by the inverse Transform.
|
|
453
|
+
* * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform
|
|
454
|
+
* has matrix part `MInverse` and origin part `-MInverse*o`.
|
|
440
455
|
* * Return as a new point or in the optional `result`.
|
|
441
456
|
* * Returns `undefined` if the `matrix` part if this Transform is singular.
|
|
442
457
|
*/
|
|
@@ -475,35 +490,35 @@ class Transform {
|
|
|
475
490
|
return numSource;
|
|
476
491
|
}
|
|
477
492
|
/**
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* * If `
|
|
482
|
-
* * If `
|
|
493
|
+
* Multiply each point in the array by the inverse of `this` Transform.
|
|
494
|
+
* * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse
|
|
495
|
+
* `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`
|
|
496
|
+
* * If `result` is given, resize it to match the input `points` array and update it with original points `p[]`.
|
|
497
|
+
* * If `result` is not given, return a new array.
|
|
483
498
|
* * Returns `undefined` if the `matrix` part if this Transform is singular.
|
|
484
499
|
*/
|
|
485
|
-
multiplyInversePoint3dArray(points,
|
|
500
|
+
multiplyInversePoint3dArray(points, result) {
|
|
486
501
|
if (!this._matrix.computeCachedInverse(true))
|
|
487
502
|
return undefined;
|
|
488
503
|
const originX = this.origin.x;
|
|
489
504
|
const originY = this.origin.y;
|
|
490
505
|
const originZ = this.origin.z;
|
|
491
|
-
if (
|
|
492
|
-
const n = Transform.matchArrayLengths(points,
|
|
506
|
+
if (result) {
|
|
507
|
+
const n = Transform.matchArrayLengths(points, result, Point3dVector3d_1.Point3d.createZero);
|
|
493
508
|
for (let i = 0; i < n; i++)
|
|
494
|
-
this._matrix.multiplyInverseXYZAsPoint3d(points[i].x - originX, points[i].y - originY, points[i].z - originZ,
|
|
509
|
+
this._matrix.multiplyInverseXYZAsPoint3d(points[i].x - originX, points[i].y - originY, points[i].z - originZ, result[i]);
|
|
510
|
+
return result;
|
|
495
511
|
}
|
|
496
|
-
|
|
512
|
+
result = [];
|
|
497
513
|
for (const point of points)
|
|
498
|
-
|
|
499
|
-
return
|
|
514
|
+
result.push(this._matrix.multiplyInverseXYZAsPoint3d(point.x - originX, point.y - originY, point.z - originZ));
|
|
515
|
+
return result;
|
|
500
516
|
}
|
|
501
517
|
/**
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* * Returns `true` if the `matrix` part if this Transform is invertible and `false if singular.
|
|
518
|
+
* Multiply each point in the array by the inverse of `this` Transform in place.
|
|
519
|
+
* * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse
|
|
520
|
+
* `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`
|
|
521
|
+
* * Returns `true` if the `matrix` part if this Transform is invertible and `false` if singular.
|
|
507
522
|
*/
|
|
508
523
|
multiplyInversePoint3dArrayInPlace(points) {
|
|
509
524
|
if (!this._matrix.computeCachedInverse(true))
|
|
@@ -572,7 +587,8 @@ class Transform {
|
|
|
572
587
|
/**
|
|
573
588
|
* Calculate `transformA * transformB` and store it into the calling instance (`this`).
|
|
574
589
|
* * **Note:** If `transformA = [A a]` and `transformB = [B b]` then `transformA * transformB` is defined as
|
|
575
|
-
* `[A*B Ab+a]`.
|
|
590
|
+
* `[A*B Ab+a]`.
|
|
591
|
+
* * @see [[multiplyTransformTransform]] documentation for math details.
|
|
576
592
|
* @param transformA first operand
|
|
577
593
|
* @param transformB second operand
|
|
578
594
|
*/
|
|
@@ -582,19 +598,17 @@ class Transform {
|
|
|
582
598
|
}
|
|
583
599
|
/**
|
|
584
600
|
* Multiply `this` Transform times `other` Transform.
|
|
585
|
-
* **Note:** If `this = [A a]` and `other = [B b]` then `this * other` is defined as [A*B Ab+a]
|
|
586
|
-
* That's because we create a 4x4 matrix for each Transform with the 3x3 `matrix` and `origin`
|
|
587
|
-
* as upper 3x4 part of a 4x4 matrix and 0001 as the final row. Then we multiply those two 4x4 matrixes:
|
|
601
|
+
* * **Note:** If `this = [A a]` and `other = [B b]` then `this * other` is defined as [A*B Ab+a] because:
|
|
588
602
|
* ```
|
|
589
603
|
* equation
|
|
590
604
|
* \begin{matrix}
|
|
591
|
-
* \text{
|
|
592
|
-
* \text{
|
|
605
|
+
* \text{this Transform with matrix part }\bold{A}\text{ and origin part }\bold{a} & \blockTransform{A}{a}\\
|
|
606
|
+
* \text{other Transform with matrix part }\bold{B}\text{ and origin part }\bold{b} & \blockTransform{B}{b} \\
|
|
593
607
|
* \text{product}& \blockTransform{A}{a}\blockTransform{B}{b}=\blockTransform{AB}{Ab + a}
|
|
594
608
|
* \end{matrix}
|
|
595
609
|
* ```
|
|
596
610
|
* @param other the 'other` Transform to be multiplied to `this` Transform.
|
|
597
|
-
* @param result optional preallocated result to reuse.
|
|
611
|
+
* @param result optional preallocated `result` to reuse.
|
|
598
612
|
*/
|
|
599
613
|
multiplyTransformTransform(other, result) {
|
|
600
614
|
if (!result)
|
|
@@ -604,20 +618,17 @@ class Transform {
|
|
|
604
618
|
}
|
|
605
619
|
/**
|
|
606
620
|
* Multiply `this` Transform times `other` Matrix3d (considered to be a Transform with 0 `origin`).
|
|
607
|
-
* **Note:** If `this = [A a]`, then
|
|
608
|
-
* Then `this * other` is defined as [A*B a]. That's because we create a 4x4 matrix for each Transform
|
|
609
|
-
* with the 3x3 `matrix` and `origin` as upper 3x4 part of a 4x4 matrix and 0001 as the final row. Then we
|
|
610
|
-
* multiply those two 4x4 matrixes:
|
|
621
|
+
* * **Note:** If `this = [A a]` and `other = [B 0]`, then `this * other` is defined as [A*B a] because:
|
|
611
622
|
* ```
|
|
612
623
|
* equation
|
|
613
624
|
* \begin{matrix}
|
|
614
|
-
* \text{
|
|
615
|
-
* \text{
|
|
625
|
+
* \text{this Transform with matrix part }\bold{A}\text{ and origin part }\bold{a} & \blockTransform{A}{a}\\
|
|
626
|
+
* \text{other matrix }\bold{B}\text{ promoted to block Transform} & \blockTransform{B}{0} \\
|
|
616
627
|
* \text{product}& \blockTransform{A}{a}\blockTransform{B}{0}=\blockTransform{AB}{a}
|
|
617
628
|
* \end{matrix}
|
|
618
629
|
* ```
|
|
619
630
|
* @param other the `other` Matrix3d to be multiplied to `this` Transform.
|
|
620
|
-
* @param result optional preallocated result to reuse.
|
|
631
|
+
* @param result optional preallocated `result` to reuse.
|
|
621
632
|
*/
|
|
622
633
|
multiplyTransformMatrix3d(other, result) {
|
|
623
634
|
if (!result)
|
|
@@ -627,13 +638,13 @@ class Transform {
|
|
|
627
638
|
return result;
|
|
628
639
|
}
|
|
629
640
|
/**
|
|
630
|
-
* Return the
|
|
641
|
+
* Return the range of the transformed corners.
|
|
631
642
|
* * The 8 corners are transformed individually.
|
|
632
643
|
* * **Note:** Suppose you have a geometry, a range box around that geometry, and your Transform is a rotation.
|
|
633
644
|
* If you rotate the range box and recompute a new range box around the rotated range box, then the new range
|
|
634
645
|
* box will have a larger volume than the original range box. However, if you rotate the geometry itself and
|
|
635
646
|
* then recompute the range box, it will be a tighter range box around the rotated geometry. `multiplyRange`
|
|
636
|
-
* function creates the larger range box because it only has access to the range box and the geometry itself.
|
|
647
|
+
* function creates the larger range box because it only has access to the range box and not the geometry itself.
|
|
637
648
|
*/
|
|
638
649
|
multiplyRange(range, result) {
|
|
639
650
|
if (range.isNull)
|
|
@@ -657,7 +668,7 @@ class Transform {
|
|
|
657
668
|
}
|
|
658
669
|
/**
|
|
659
670
|
* Return a Transform which is the inverse of `this` Transform.
|
|
660
|
-
* * If `transform = [M o]` then `transformInverse = [MInverse MInverse
|
|
671
|
+
* * If `transform = [M o]` then `transformInverse = [MInverse -MInverse*o]`
|
|
661
672
|
* * Return `undefined` if this Transform's matrix is singular.
|
|
662
673
|
*/
|
|
663
674
|
inverse(result) {
|
|
@@ -672,14 +683,14 @@ class Transform {
|
|
|
672
683
|
return Transform.createRefs(matrixInverse.multiplyXYZ(-this._origin.x, -this._origin.y, -this._origin.z), matrixInverse);
|
|
673
684
|
}
|
|
674
685
|
/**
|
|
675
|
-
* Initialize 2 Transforms
|
|
676
|
-
*
|
|
677
|
-
* @param min the min corner of the box
|
|
678
|
-
* @param max the max corner of the box
|
|
679
|
-
* @param npcToGlobal maps
|
|
680
|
-
*
|
|
681
|
-
* @param globalToNpc maps
|
|
682
|
-
*
|
|
686
|
+
* Initialize 2 Transforms that map between the unit box (specified by 000 and 111) and the range box specified
|
|
687
|
+
* by the input points.
|
|
688
|
+
* @param min the min corner of the range box
|
|
689
|
+
* @param max the max corner of the range box
|
|
690
|
+
* @param npcToGlobal maps NPC coordinates into range box coordinates. Specifically, maps 000 to `min` and maps
|
|
691
|
+
* 111 to `max`. This Transform is the inverse of `globalToNpc`. Object created by caller, re-initialized here.
|
|
692
|
+
* @param globalToNpc maps range box coordinates into NPC coordinates. Specifically, maps `min` to 000 and maps
|
|
693
|
+
* `max` to 111. This Transform is the inverse of `npcToGlobal`. Object created by caller, re-initialized here.
|
|
683
694
|
* * NPC stands for `Normalized Projection Coordinate`
|
|
684
695
|
*/
|
|
685
696
|
static initFromRange(min, max, npcToGlobal, globalToNpc) {
|