@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.
Files changed (97) hide show
  1. package/lib/cjs/Geometry.d.ts +5 -1
  2. package/lib/cjs/Geometry.d.ts.map +1 -1
  3. package/lib/cjs/Geometry.js +5 -1
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/geometry3d/Angle.d.ts +29 -34
  6. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  7. package/lib/cjs/geometry3d/Angle.js +31 -36
  8. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  9. package/lib/cjs/geometry3d/AngleSweep.d.ts +48 -43
  10. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  11. package/lib/cjs/geometry3d/AngleSweep.js +48 -43
  12. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  13. package/lib/cjs/geometry3d/Matrix3d.d.ts +5 -8
  14. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  15. package/lib/cjs/geometry3d/Matrix3d.js +5 -8
  16. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  17. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +3 -3
  18. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  19. package/lib/cjs/geometry3d/OrderedRotationAngles.js +3 -3
  20. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  21. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +8 -10
  22. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  23. package/lib/cjs/geometry3d/Point2dArrayCarrier.js +8 -10
  24. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  25. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +37 -34
  26. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  27. package/lib/cjs/geometry3d/Point2dVector2d.js +38 -35
  28. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  29. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +17 -21
  30. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  31. package/lib/cjs/geometry3d/Point3dArrayCarrier.js +16 -20
  32. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  33. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +84 -67
  34. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  35. package/lib/cjs/geometry3d/Point3dVector3d.js +84 -67
  36. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  37. package/lib/cjs/geometry3d/Transform.d.ts +76 -66
  38. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  39. package/lib/cjs/geometry3d/Transform.js +88 -77
  40. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  41. package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts +15 -16
  42. package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
  43. package/lib/cjs/geometry3d/YawPitchRollAngles.js +14 -15
  44. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  45. package/lib/cjs/serialization/GeometrySamples.d.ts +72 -58
  46. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  47. package/lib/cjs/serialization/GeometrySamples.js +132 -108
  48. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  49. package/lib/esm/Geometry.d.ts +5 -1
  50. package/lib/esm/Geometry.d.ts.map +1 -1
  51. package/lib/esm/Geometry.js +5 -1
  52. package/lib/esm/Geometry.js.map +1 -1
  53. package/lib/esm/geometry3d/Angle.d.ts +29 -34
  54. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  55. package/lib/esm/geometry3d/Angle.js +31 -36
  56. package/lib/esm/geometry3d/Angle.js.map +1 -1
  57. package/lib/esm/geometry3d/AngleSweep.d.ts +48 -43
  58. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  59. package/lib/esm/geometry3d/AngleSweep.js +48 -43
  60. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  61. package/lib/esm/geometry3d/Matrix3d.d.ts +5 -8
  62. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  63. package/lib/esm/geometry3d/Matrix3d.js +5 -8
  64. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  65. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +3 -3
  66. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  67. package/lib/esm/geometry3d/OrderedRotationAngles.js +3 -3
  68. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  69. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +8 -10
  70. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  71. package/lib/esm/geometry3d/Point2dArrayCarrier.js +8 -10
  72. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  73. package/lib/esm/geometry3d/Point2dVector2d.d.ts +37 -34
  74. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  75. package/lib/esm/geometry3d/Point2dVector2d.js +38 -35
  76. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  77. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +17 -21
  78. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  79. package/lib/esm/geometry3d/Point3dArrayCarrier.js +16 -20
  80. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  81. package/lib/esm/geometry3d/Point3dVector3d.d.ts +84 -67
  82. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  83. package/lib/esm/geometry3d/Point3dVector3d.js +84 -67
  84. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  85. package/lib/esm/geometry3d/Transform.d.ts +76 -66
  86. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  87. package/lib/esm/geometry3d/Transform.js +88 -77
  88. package/lib/esm/geometry3d/Transform.js.map +1 -1
  89. package/lib/esm/geometry3d/YawPitchRollAngles.d.ts +15 -16
  90. package/lib/esm/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
  91. package/lib/esm/geometry3d/YawPitchRollAngles.js +14 -15
  92. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  93. package/lib/esm/serialization/GeometrySamples.d.ts +72 -58
  94. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  95. package/lib/esm/serialization/GeometrySamples.js +132 -108
  96. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  97. 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
- * * For details of how the matrix is modified to rigid, see documentation of `Matrix3d.axisOrderCrossProductsInPlace`
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
- * * For details of how the matrix is created to be rigid, see documentation of `Matrix3d.createRigidFromColumns`
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" and use its reference.
277
- * That means if "origin" is changed via Transform at any point, the initial "origin" passed by the user is also
278
- * changed. To avoid that, we pass undefined to createRefs. This would cause createRefs to create a new "origin"
279
- * equals (0,0,0) which then we set it to the "origin" passed by user in the next line.
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, transforms
303
- * point `p` to `M*(p-a) + b` (i.e., `Tp = M*(p-a) + b`) so transforms point `a` to 'b'.
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*(x-a) + b
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, transforms a point `p` to `M*p + (f - M*f)`
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 transform matrix times xyz and add it to the origin element
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 transform matrix times xyz and add it to the origin element
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
- * If `p = (x,y,z)` then transform is `Tp = M*p + o*w`. This function returns the transformed point as a new
374
- * point4d (`Tp` as first 3 elements and `w` as last element) or in the pre-allocated result (if result is given).
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
- * If `p = (x,y,z)` then transform is `Tp = M*p + o*w`. This function returns the transformed point as a new
381
- * Float64Array with size 4 (`Tp` as first 3 elements and `w` as last element) or in the pre-allocated result
382
- * (if result is given).
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
- * If `p = (x,y,z)` then transform is `Tp = M*p + o`. This function returns the transformed point as a new
389
- * Float64Array with size 3 (`Tp` as 3 elements) or in the pre-allocated result (if result is given).
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
- * Treat the 3x3 `matrix` and `origin` as upper 3x4 part of a 4x4 matrix, with 0001 as the final row. Now multiply
396
- * the transposed of this 4x4 matrix by Point4d given as xyzw. Return as a new point4d (`M*p` as first 3 elements
397
- * and `o*p + w` as last element where `p = (x,y,z)`) or in the pre-allocated result (if result is given).
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
- * If for a point `p` we have `Tp = M*p + o = point` (where `point` is the transformed point), then
417
- * `p = MInverse * (point - o)`. This function returns the original point `p` if `point` is the
418
- * transformed point (`Tp = point`).
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
- * If for a point `p` we have `Tp = M*p + w*o = weightedPoint` (where `weightedPoint` is the transformed point), then
427
- * `p = MInverse * (weightedPoint - w*o)`. This function returns a Point4d where first 3 elements are the original
428
- * point `p` if `weightedPoint` is the transformed point (`Tp = weightedPoint`) and the last element is `w`.
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
- * If for a point `p = (x,y,z)` we have `Tp = M*p + o = point` (where `point` is the transformed point), then
438
- * `p = MInverse * (point - o)`. This function returns the original point `p` if `point` is the transformed
439
- * point (`Tp = point`).
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
- * If for each point `p` we have `Tp = M*p + o = point` (where `point` is the transformed point), then
479
- * `p = MInverse * (point - o)`. This function returns the array of original points `p[]` if `points`
480
- * is the array of transformed point (`Tp = point` for each `p` and `point`).
481
- * * If `results` is given, resize it to match the input `points` array and update it with original points `p[]`.
482
- * * If `results` is not given, return a new array.
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, results) {
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 (results) {
492
- const n = Transform.matchArrayLengths(points, results, Point3dVector3d_1.Point3d.createZero);
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, results[i]);
509
+ this._matrix.multiplyInverseXYZAsPoint3d(points[i].x - originX, points[i].y - originY, points[i].z - originZ, result[i]);
510
+ return result;
495
511
  }
496
- results = [];
512
+ result = [];
497
513
  for (const point of points)
498
- results.push(this._matrix.multiplyInverseXYZAsPoint3d(point.x - originX, point.y - originY, point.z - originZ));
499
- return results;
514
+ result.push(this._matrix.multiplyInverseXYZAsPoint3d(point.x - originX, point.y - originY, point.z - originZ));
515
+ return result;
500
516
  }
501
517
  /**
502
- * If for each point `p` we have `Tp = M*p + o = point` (where `point` is the transformed point), then
503
- * `p = MInverse * (point - o)`. This function calculates the array of original points `p[]` if `points`
504
- * is the array of transformed point (`Tp = point` for each `p` and `point`) and replaces `points`
505
- * with the array of original points.
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]`. See `multiplyTransformTransform` doc for math details.
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{`this` Transform with `matrix` part }\bold{A}\text{ and `origin` part }\bold{a} & \blockTransform{A}{a}\\
592
- * \text{`other` Transform with `matrix` part }\bold{B}\text{ and `origin` part }\bold{b} & \blockTransform{B}{b} \\
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 we promote `other` matrix to be a Transform [B 0].
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{`this` Transform with `matrix` part }\bold{A}\text{ and `origin` part }\bold{a} & \blockTransform{A}{a}\\
615
- * \text{`other` matrix }\bold{B}\text{ promoted to block Transform} & \blockTransform{B}{0} \\
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 Range of the transformed corners.
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*-o]`
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: First Transform maps a box (axis aligned) specified by `min` and `max` to
676
- * the unit box specified by 000 and 111 and inverse of it. Second Transform is the reverse of first.
677
- * @param min the min corner of the box
678
- * @param max the max corner of the box
679
- * @param npcToGlobal maps global (the unit box specified by 000 and 111) to NPC (a box specified by `min`
680
- * and `max`). Object created by caller, re-initialized here.
681
- * @param globalToNpc maps NPC (a box specified by `min` and `max`) to global (the unit box specified by
682
- * 000 and 111). Object created by caller, re-initialized here.
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) {