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