@itwin/core-geometry 4.0.0-dev.1 → 4.0.0-dev.11

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 (134) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/lib/cjs/Geometry.d.ts +3 -3
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +27 -11
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  7. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +19 -12
  8. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  9. package/lib/cjs/curve/CurveCurve.d.ts +11 -8
  10. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  11. package/lib/cjs/curve/CurveCurve.js +16 -12
  12. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  13. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts +5 -1
  14. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  15. package/lib/cjs/curve/CurveCurveIntersectXY.js +11 -10
  16. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
  17. package/lib/cjs/geometry3d/Angle.d.ts +19 -0
  18. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  19. package/lib/cjs/geometry3d/Angle.js +39 -0
  20. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  21. package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -0
  22. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  23. package/lib/cjs/geometry3d/AngleSweep.js +1 -0
  24. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  25. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  26. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  27. package/lib/cjs/geometry3d/CoincidentGeometryOps.js +3 -0
  28. package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
  29. package/lib/cjs/geometry3d/Matrix3d.d.ts +326 -208
  30. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  31. package/lib/cjs/geometry3d/Matrix3d.js +683 -613
  32. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  33. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +15 -13
  34. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  35. package/lib/cjs/geometry3d/Point3dVector3d.js +18 -13
  36. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  37. package/lib/cjs/geometry3d/Segment1d.d.ts +1 -1
  38. package/lib/cjs/geometry3d/Segment1d.js +1 -1
  39. package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
  40. package/lib/cjs/numerics/Polynomials.d.ts +12 -0
  41. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  42. package/lib/cjs/numerics/Polynomials.js +14 -0
  43. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  44. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -0
  45. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  46. package/lib/cjs/polyface/PolyfaceBuilder.js +46 -6
  47. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  48. package/lib/cjs/polyface/PolyfaceQuery.d.ts +54 -0
  49. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  50. package/lib/cjs/polyface/PolyfaceQuery.js +71 -1
  51. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  52. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +202 -0
  53. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -0
  54. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +1038 -0
  55. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -0
  56. package/lib/cjs/serialization/GeometrySamples.d.ts +4 -1
  57. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  58. package/lib/cjs/serialization/GeometrySamples.js +14 -6
  59. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  60. package/lib/cjs/topology/Graph.d.ts +113 -7
  61. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  62. package/lib/cjs/topology/Graph.js +185 -7
  63. package/lib/cjs/topology/Graph.js.map +1 -1
  64. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts +38 -0
  65. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts.map +1 -0
  66. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.js +82 -0
  67. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -0
  68. package/lib/esm/Geometry.d.ts +3 -3
  69. package/lib/esm/Geometry.d.ts.map +1 -1
  70. package/lib/esm/Geometry.js +27 -11
  71. package/lib/esm/Geometry.js.map +1 -1
  72. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  73. package/lib/esm/curve/CurveChainWithDistanceIndex.js +20 -13
  74. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  75. package/lib/esm/curve/CurveCurve.d.ts +11 -8
  76. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  77. package/lib/esm/curve/CurveCurve.js +16 -12
  78. package/lib/esm/curve/CurveCurve.js.map +1 -1
  79. package/lib/esm/curve/CurveCurveIntersectXY.d.ts +5 -1
  80. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  81. package/lib/esm/curve/CurveCurveIntersectXY.js +11 -10
  82. package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
  83. package/lib/esm/geometry3d/Angle.d.ts +19 -0
  84. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  85. package/lib/esm/geometry3d/Angle.js +39 -0
  86. package/lib/esm/geometry3d/Angle.js.map +1 -1
  87. package/lib/esm/geometry3d/AngleSweep.d.ts +1 -0
  88. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  89. package/lib/esm/geometry3d/AngleSweep.js +1 -0
  90. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  91. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  92. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  93. package/lib/esm/geometry3d/CoincidentGeometryOps.js +3 -0
  94. package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
  95. package/lib/esm/geometry3d/Matrix3d.d.ts +326 -208
  96. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  97. package/lib/esm/geometry3d/Matrix3d.js +683 -613
  98. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  99. package/lib/esm/geometry3d/Point3dVector3d.d.ts +15 -13
  100. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  101. package/lib/esm/geometry3d/Point3dVector3d.js +18 -13
  102. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  103. package/lib/esm/geometry3d/Segment1d.d.ts +1 -1
  104. package/lib/esm/geometry3d/Segment1d.js +1 -1
  105. package/lib/esm/geometry3d/Segment1d.js.map +1 -1
  106. package/lib/esm/numerics/Polynomials.d.ts +12 -0
  107. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  108. package/lib/esm/numerics/Polynomials.js +14 -0
  109. package/lib/esm/numerics/Polynomials.js.map +1 -1
  110. package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -0
  111. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  112. package/lib/esm/polyface/PolyfaceBuilder.js +46 -6
  113. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  114. package/lib/esm/polyface/PolyfaceQuery.d.ts +54 -0
  115. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  116. package/lib/esm/polyface/PolyfaceQuery.js +69 -0
  117. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  118. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +202 -0
  119. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -0
  120. package/lib/esm/polyface/multiclip/OffsetMeshContext.js +1032 -0
  121. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -0
  122. package/lib/esm/serialization/GeometrySamples.d.ts +4 -1
  123. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  124. package/lib/esm/serialization/GeometrySamples.js +14 -6
  125. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  126. package/lib/esm/topology/Graph.d.ts +113 -7
  127. package/lib/esm/topology/Graph.d.ts.map +1 -1
  128. package/lib/esm/topology/Graph.js +185 -7
  129. package/lib/esm/topology/Graph.js.map +1 -1
  130. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts +38 -0
  131. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts.map +1 -0
  132. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.js +78 -0
  133. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -0
  134. package/package.json +4 -4
@@ -136,7 +136,10 @@ export declare class Matrix3d implements BeJSONFunctions {
136
136
  inverseCoffs: Float64Array | undefined;
137
137
  /** Indicates if inverse is unknown, available, or known singular */
138
138
  inverseState: InverseMatrixState;
139
+ /** The identity matrix */
139
140
  private static _identity;
141
+ /** temporary buffer to store a matrix as a Float64Array (array of 9 floats) */
142
+ private static _productBuffer;
140
143
  /** The identity Matrix3d. Value is frozen and cannot be modified. */
141
144
  static get identity(): Matrix3d;
142
145
  /** Freeze this Matrix3d. */
@@ -234,9 +237,15 @@ export declare class Matrix3d implements BeJSONFunctions {
234
237
  */
235
238
  static createColumnsInAxisOrder(axisOrder: AxisOrder, columnA: Vector3d | undefined, columnB: Vector3d | undefined, columnC: Vector3d | undefined, result?: Matrix3d): Matrix3d;
236
239
  /**
237
- * Copy the transpose of the coffs to the inverseCoffs.
238
- * * Mark the matrix as inverseStored.
239
- */
240
+ * Create the inverseCoffs member (filled with zeros)
241
+ * This is for use by matrix * matrix multiplications which need to be sure the member is there to be
242
+ * filled with method-specific content.
243
+ */
244
+ private createInverseCoffsWithZeros;
245
+ /**
246
+ * Copy the transpose of the coffs to the inverseCoffs.
247
+ * * Mark the matrix as inverseStored.
248
+ */
240
249
  private setupInverseTranspose;
241
250
  /**
242
251
  * Set all entries in the matrix from call parameters appearing in row-major order.
@@ -336,13 +345,15 @@ export declare class Matrix3d implements BeJSONFunctions {
336
345
  */
337
346
  static createRigidFromColumns(vectorA: Vector3d, vectorB: Vector3d, axisOrder: AxisOrder, result?: Matrix3d): Matrix3d | undefined;
338
347
  /**
339
- * Construct a rigid matrix using vectorA and its 2 perpendicular.
348
+ * Construct a rigid matrix (orthogonal matrix with +1 determinant) using vectorA and its 2 perpendicular.
349
+ * * If axisOrder is not passed then `AxisOrder = AxisOrder.ZXY` is used as default.
340
350
  * * This function internally uses createPerpendicularVectorFavorXYPlane and createRigidFromColumns.
351
+ * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/2PerpendicularVectorsTo1Vector
341
352
  */
342
353
  static createRigidHeadsUp(vectorA: Vector3d, axisOrder?: AxisOrder, result?: Matrix3d): Matrix3d;
343
- /** Return the matrix for rotation of `angle` around `axis` */
354
+ /** Return the matrix for rotation of `angle` around desired `axis` */
344
355
  static createRotationAroundVector(axis: Vector3d, angle: Angle, result?: Matrix3d): Matrix3d | undefined;
345
- /** Returns a rotation of specified angle around an axis
356
+ /** Returns a rotation of specified angle around one of the main axis (X,Y,Z).
346
357
  * @param axisIndex index of axis (AxisIndex.X, AxisIndex.Y, AxisIndex.Z) kept fixed by the rotation.
347
358
  * @param angle angle of rotation
348
359
  * @param result optional result matrix.
@@ -350,22 +361,31 @@ export declare class Matrix3d implements BeJSONFunctions {
350
361
  */
351
362
  static createRotationAroundAxisIndex(axisIndex: AxisIndex, angle: Angle, result?: Matrix3d): Matrix3d;
352
363
  /**
353
- * Replace current columns Ui and Uj with (c*Ui - s*Uj) and (c*Uj + s*Ui).
354
- * * There is no checking for i,j being 0,1,2.
355
- * * This is used in compute intensive inner loops
356
- * @param i first row index. **must be 0,1,2** (unchecked)
357
- * @param j second row index. **must be 0,1,2** (unchecked)
358
- * @param c fist coefficient
359
- * @param s second coefficient
360
- */
364
+ * Replace current rows Ui and Uj with (c*Ui + s*Uj) and (c*Uj - s*Ui).
365
+ * * There is no checking for i,j being 0,1,2.
366
+ * @param i first row index. **must be 0,1,2** (unchecked)
367
+ * @param j second row index. **must be 0,1,2** (unchecked)
368
+ * @param c fist coefficient
369
+ * @param s second coefficient
370
+ */
371
+ private applyGivensRowOp;
372
+ /**
373
+ * Replace current columns Ui and Uj with (c*Ui + s*Uj) and (c*Uj - s*Ui).
374
+ * * There is no checking for i,j being 0,1,2.
375
+ * * This is used in compute intensive inner loops
376
+ * @param i first row index. **must be 0,1,2** (unchecked)
377
+ * @param j second row index. **must be 0,1,2** (unchecked)
378
+ * @param c fist coefficient
379
+ * @param s second coefficient
380
+ */
361
381
  applyGivensColumnOp(i: number, j: number, c: number, s: number): void;
362
382
  /**
363
- * Create a matrix from column vectors.
364
- * ```
365
- * equation
366
- * \begin{bmatrix}U_x & V_x & W_x \\ U_y & V_y & W_y \\ U_z & V_z & W_z \end{bmatrix}
367
- * ```
368
- */
383
+ * Create a matrix from column vectors.
384
+ * ```
385
+ * equation
386
+ * \begin{bmatrix}U_x & V_x & W_x \\ U_y & V_y & W_y \\ U_z & V_z & W_z \end{bmatrix}
387
+ * ```
388
+ */
369
389
  static createColumns(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, result?: Matrix3d): Matrix3d;
370
390
  /** Create a matrix with each column's _x,y_ parts given `XAndY` and separate numeric z values.
371
391
  * ```
@@ -378,8 +398,9 @@ export declare class Matrix3d implements BeJSONFunctions {
378
398
  * * ColumnX points in the rightVector direction
379
399
  * * ColumnY points in the upVector direction
380
400
  * * ColumnZ is a unit cross product of ColumnX and ColumnY.
381
- * * Optionally rotate the standard cube by 45 degrees ccw around Y to bring its left or right vertical edge to center.
382
- * * Optionally rotate the standard cube by 35.264 degrees ccw around X (isometric rotation).
401
+ * * Optionally rotate by 45 degrees around `upVector` to bring its left or right vertical edge to center.
402
+ * * Optionally rotate by arctan(1/sqrt(2)) ~ 35.264 degrees around `rightVector` to bring the top or bottom
403
+ * horizontal edge of the view to the center (for isometric views).
383
404
  * * This is expected to be used with various principal unit vectors that are perpendicular to each other.
384
405
  * * STANDARD TOP VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitY(), 0, 0)
385
406
  * * STANDARD FRONT VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitZ(), 0, 0)
@@ -387,16 +408,20 @@ export declare class Matrix3d implements BeJSONFunctions {
387
408
  * * STANDARD RIGHT VIEW: createViewedAxes(Vector3d.unitY(), Vector3d.unitZ(), 0, 0)
388
409
  * * STANDARD LEFT VIEW: createViewedAxes(Vector3d.unitY(-1), Vector3d.unitZ(), 0, 0)
389
410
  * * STANDARD BOTTOM VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitY(-1), 0, 0)
411
+ * * STANDARD ISO VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitZ(), -1, 1)
412
+ * * STANDARD RIGHT ISO VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitZ(), 1, 1)
413
+ * * Front, right, back, left, top, and bottom standard views are views from faces of the cube
414
+ * and iso and right iso standard views are views from corners of the cube.
390
415
  * * Note: createViewedAxes is column-based so always returns local to world
391
416
  *
392
417
  * @param rightVector ColumnX of the returned matrix. Expected to be perpendicular to upVector.
393
418
  * @param upVector ColumnY of the returned matrix. Expected to be perpendicular to rightVector.
394
- * @param leftNoneRight Specifies the ccw rotation around Y axis. Normally one of "-1", "0", and "1", where
395
- * "-1" indicates rotation by 45 degrees to bring the left vertical edge to center, "0" means no rotation,
419
+ * @param leftNoneRight Specifies the ccw rotation around `upVector` axis. Normally one of "-1", "0", and "1",
420
+ * where "-1" indicates rotation by 45 degrees to bring the left vertical edge to center, "0" means no rotation,
396
421
  * and "1" indicates rotation by 45 degrees to bring the right vertical edge to center. Other numbers are
397
422
  * used as multiplier for this 45 degree rotation.
398
- * @param topNoneBottom Specifies the ccw rotation around X axis. Normally one of "-1", "0", and "1", where
399
- * "-1" indicates isometric rotation (35.264 degrees) to bring the bottom upward, "0" means no rotation,
423
+ * @param topNoneBottom Specifies the ccw rotation around `rightVector` axis. Normally one of "-1", "0", and "1",
424
+ * where "-1" indicates isometric rotation (35.264 degrees) to bring the bottom upward, "0" means no rotation,
400
425
  * and "1" indicates isometric rotation (35.264 degrees) to bring the top downward. Other numbers are
401
426
  * used as multiplier for the 35.264 degree rotation.
402
427
  * @returns matrix = [rightVector, upVector, rightVector cross upVector] with the applied rotations specified
@@ -408,9 +433,11 @@ export declare class Matrix3d implements BeJSONFunctions {
408
433
  * * Default is TOP view (`local X = world X`, `local Y = world Y`, `local Z = world Z`).
409
434
  * * To change view from the TOP to one of the other 7 standard views, we need to multiply "world data" to
410
435
  * the corresponding matrix1 provided by `createStandardWorldToView(index, false)` and then
411
- * `matrix1.multiply(world data)` will returns "local data".
436
+ * `matrix1.multiply(world data)` will return "local data".
412
437
  * * To change view back to the TOP, we need to multiply "local data" to the corresponding matrix2 provided
413
438
  * by `createStandardWorldToView(index, true)` and then `matrix2.multiply(local data)` will returns "world data".
439
+ * * Note: No matter how you rotate the world axis, local X is always pointing right, local Y is always pointing up,
440
+ * and local Z is always pointing toward you.
414
441
  *
415
442
  * @param index standard view index `StandardViewIndex.Top, Bottom, Left, Right, Front, Back, Iso, RightIso`
416
443
  * @param invert if false (default), the return matrix is world to local (view) and if true, the the return
@@ -418,8 +445,27 @@ export declare class Matrix3d implements BeJSONFunctions {
418
445
  * @param result optional result.
419
446
  */
420
447
  static createStandardWorldToView(index: StandardViewIndex, invert?: boolean, result?: Matrix3d): Matrix3d;
448
+ /**
449
+ * Apply (in place) a jacobi update that zeros out this.at(i,j).
450
+ * @param i row index of zeroed member
451
+ * @param j column index of zeroed member
452
+ * @param k other row/column index (different from i and j)
453
+ * @param leftEigenVectors a matrix that its columns will be filled by eigenvectors of this Matrix3d
454
+ * (allocated by caller, computed and filled by this function)
455
+ */
456
+ private applyFastSymmetricJacobiUpdate;
457
+ /**
458
+ * Factor this (symmetrized) as a product U * lambda * UT where U is orthogonal, lambda is diagonal.
459
+ * The upper triangle is mirrored to lower triangle to enforce symmetry.
460
+ * @param leftEigenvectors a matrix that its columns will be filled by eigenvectors of this Matrix3d
461
+ * (allocated by caller, computed and filled by this function)
462
+ * @param lambda a vector that its entries will be filled by eigenvalues of this Matrix3d
463
+ * (allocated by caller, computed and filled by this function)
464
+ */
465
+ fastSymmetricEigenvalues(leftEigenvectors: Matrix3d, lambda: Vector3d): boolean;
421
466
  /**
422
467
  * Compute the (unit vector) axis and angle of rotation.
468
+ * * math details can be found at docs/learning/geometry/Angle.md
423
469
  * @returns Returns axis and angle of rotation with result.ok === true when the conversion succeeded.
424
470
  */
425
471
  getAxisAndAngleOfRotation(): {
@@ -427,25 +473,48 @@ export declare class Matrix3d implements BeJSONFunctions {
427
473
  angle: Angle;
428
474
  ok: boolean;
429
475
  };
476
+ /** Rotate so columns i and j become perpendicular */
477
+ private applyJacobiColumnRotation;
478
+ /**
479
+ * Factor this as a product C * U where C has mutually perpendicular columns and
480
+ * U is orthogonal.
481
+ * @param matrixC (allocate by caller, computed here)
482
+ * @param matrixU (allocate by caller, computed here)
483
+ */
484
+ factorPerpendicularColumns(matrixC: Matrix3d, matrixU: Matrix3d): boolean;
430
485
  /**
431
- * Returns a matrix that rotates from vectorA to vectorB.
486
+ * Factor this matrix M as a product M = V * D * U where V and U are orthogonal, and D is diagonal (scale matrix).
487
+ * @param matrixV left orthogonal factor (allocate by caller, computed here)
488
+ * @param scale diagonal entries of D (allocate by caller, computed here)
489
+ * @param matrixU right orthogonal factor (allocate by caller, computed here)
432
490
  */
433
- static createRotationVectorToVector(vectorA: Vector3d, vectorB: Vector3d, result?: Matrix3d): Matrix3d | undefined;
491
+ factorOrthogonalScaleOrthogonal(matrixV: Matrix3d, scale: Point3d, matrixU: Matrix3d): boolean;
492
+ /** Apply a jacobi step to lambda which evolves towards diagonal. */
493
+ private applySymmetricJacobi;
494
+ /**
495
+ * Factor this (symmetrized) as a product U * lambda * UT where U is orthogonal, lambda is diagonal.
496
+ * The upper triangle is mirrored to lower triangle to enforce symmetry.
497
+ * @param matrixC (allocate by caller, computed here)
498
+ * @param factor (allocate by caller, computed here)
499
+ */
500
+ symmetricEigenvalues(leftEigenvectors: Matrix3d, lambda: Vector3d): boolean;
434
501
  /**
435
502
  * Return a matrix that rotates a fraction of the angular sweep from vectorA to vectorB.
436
503
  * @param vectorA initial vector position
437
- * @param fraction fractional rotation. 1.0 is "all the way"
504
+ * @param fraction fractional rotation (1 means rotate all the way)
438
505
  * @param vectorB final vector position
439
506
  * @param result optional result matrix.
440
507
  */
441
508
  static createPartialRotationVectorToVector(vectorA: Vector3d, fraction: number, vectorB: Vector3d, result?: Matrix3d): Matrix3d | undefined;
509
+ /** Returns a matrix that rotates from vectorA to vectorB. */
510
+ static createRotationVectorToVector(vectorA: Vector3d, vectorB: Vector3d, result?: Matrix3d): Matrix3d | undefined;
442
511
  /** Create a 90 degree rotation around a principal axis */
443
512
  static create90DegreeRotationAroundAxis(axisIndex: number): Matrix3d;
444
513
  /** Return (a copy of) the X column */
445
514
  columnX(result?: Vector3d): Vector3d;
446
- /** Return (a copy of)the Y column */
515
+ /** Return (a copy of) the Y column */
447
516
  columnY(result?: Vector3d): Vector3d;
448
- /** Return (a copy of)the Z column */
517
+ /** Return (a copy of) the Z column */
449
518
  columnZ(result?: Vector3d): Vector3d;
450
519
  /** Return the X column magnitude squared */
451
520
  columnXMagnitudeSquared(): number;
@@ -461,18 +530,17 @@ export declare class Matrix3d implements BeJSONFunctions {
461
530
  columnZMagnitude(): number;
462
531
  /** Return magnitude of columnX cross columnY. */
463
532
  columnXYCrossProductMagnitude(): number;
464
- /** Return the X row magnitude d */
533
+ /** Return the X row magnitude */
465
534
  rowXMagnitude(): number;
466
535
  /** Return the Y row magnitude */
467
536
  rowYMagnitude(): number;
468
537
  /** Return the Z row magnitude */
469
538
  rowZMagnitude(): number;
470
539
  /** Return the dot product of column X with column Y */
471
- /** Return the dot product of column X with column Y */
472
540
  columnXDotColumnY(): number;
473
541
  /**
474
542
  * Dot product of an indexed column with a vector given as x,y,z
475
- * @param columnIndex index of column. Must be 0,1,2
543
+ * @param columnIndex index of column. Must be 0,1,2.
476
544
  * @param x x component of vector
477
545
  * @param y y component of vector
478
546
  * @param z z component of vector
@@ -502,59 +570,9 @@ export declare class Matrix3d implements BeJSONFunctions {
502
570
  dotRowYXYZ(x: number, y: number, z: number): number;
503
571
  /** Return the dot product of the x,y,z with the Z row. */
504
572
  dotRowZXYZ(x: number, y: number, z: number): number;
505
- /** Return the (vector) cross product of the Z column with the vector parameter. */
573
+ /** Return the cross product of the Z column with the vector parameter. */
506
574
  columnZCrossVector(vector: XYZ, result?: Vector3d): Vector3d;
507
- private applyGivensRowOp;
508
- /**
509
- * create a rigid coordinate frame column z parallel to (_x_,_y_,_z_) and column x in the xy plane.
510
- * * column z points from origin to x,y,z
511
- * * column x is perpendicular and in the xy plane
512
- * * column y is perpendicular to both. It is the "up" vector on the view plane.
513
- * * Multiplying a world vector times the transpose of this matrix transforms into the view xy
514
- * * Multiplying the matrix times the an in-view vector transforms the vector to world.
515
- * @param x eye x coordinate
516
- * @param y eye y coordinate
517
- * @param z eye z coordinate
518
- * @param result
519
- */
520
- static createRigidViewAxesZTowardsEye(x: number, y: number, z: number, result?: Matrix3d): Matrix3d;
521
- /** Rotate so columns i and j become perpendicular */
522
- private applyJacobiColumnRotation;
523
- /**
524
- * Factor this as a product C * U where C has mutually perpendicular columns and
525
- * U is orthogonal.
526
- * @param matrixC (allocate by caller, computed here)
527
- * @param matrixU (allocate by caller, computed here)
528
- */
529
- factorPerpendicularColumns(matrixC: Matrix3d, matrixU: Matrix3d): boolean;
530
- /**
531
- * Factor this matrix M as a product M = V * D * U where V and U are orthogonal, and D is diagonal (scale matrix).
532
- * @param matrixV left orthogonal factor (allocate by caller, computed here)
533
- * @param scale diagonal entries of D (allocate by caller, computed here)
534
- * @param matrixU right orthogonal factor (allocate by caller, computed here)
535
- */
536
- factorOrthogonalScaleOrthogonal(matrixV: Matrix3d, scale: Point3d, matrixU: Matrix3d): boolean;
537
- /** Apply a jacobi step to lambda which evolves towards diagonal. */
538
- private applySymmetricJacobi;
539
- /**
540
- * Factor this (symmetrized) as a product U * lambda * UT where U is orthogonal, lambda is diagonal.
541
- * The upper triangle is mirrored to lower triangle to enforce symmetry.
542
- * @param matrixC (allocate by caller, computed here)
543
- * @param factor (allocate by caller, computed here)
544
- */
545
- symmetricEigenvalues(leftEigenvectors: Matrix3d, lambda: Vector3d): boolean;
546
- /** Apply (in place a jacobi update that zeros out this.at(i,j).
547
- *
548
- */
549
- private applyFastSymmetricJacobiUpdate;
550
- /**
551
- * Factor this (symmetrized) as a product U * lambda * UT where U is orthogonal, lambda is diagonal.
552
- * The upper triangle is mirrored to lower triangle to enforce symmetry.
553
- * @param matrixC (allocate by caller, computed here)
554
- * @param factor (allocate by caller, computed here)
555
- */
556
- fastSymmetricEigenvalues(leftEigenvectors: Matrix3d, lambda: Vector3d): boolean;
557
- /** Install data from xyz parts of Point4d (w part of Point4d ignored) */
575
+ /** Set data from xyz parts of Point4d (w part of Point4d ignored) */
558
576
  setColumnsPoint4dXYZ(vectorU: Point4d, vectorV: Point4d, vectorW: Point4d): void;
559
577
  /**
560
578
  * Set entries in one column of the matrix.
@@ -562,40 +580,58 @@ export declare class Matrix3d implements BeJSONFunctions {
562
580
  * @param value x,yz, values for column. If undefined, zeros are installed.
563
581
  */
564
582
  setColumn(columnIndex: number, value: Vector3d | undefined): void;
565
- /** Set all columns of the matrix. Any undefined vector is zeros. */
566
- setColumns(vectorX: Vector3d | undefined, vectorY: Vector3d | undefined, vectorZ?: Vector3d | undefined): void;
567
583
  /**
568
- * set entries in one row of the matrix.
569
- * @param rowIndex row index. this is interpreted cyclically.
570
- * @param value x,yz, values for row. If undefined, zeros are installed.
584
+ * Set all columns of the matrix. Any undefined vector is zeros.
585
+ * @param vectorX values for column 0
586
+ * @param vectorY values for column 1
587
+ * @param vectorZ optional values for column 2 (it's optional in case column 2 is 000, which is a
588
+ * projection onto the xy-plane)
589
+ */
590
+ setColumns(vectorX: Vector3d | undefined, vectorY: Vector3d | undefined, vectorZ?: Vector3d): void;
591
+ /**
592
+ * Set entries in one row of the matrix.
593
+ * @param rowIndex row index. This is interpreted cyclically (using Geometry.cyclic3dAxis).
594
+ * @param value x,y,z values for row.
571
595
  */
572
596
  setRow(rowIndex: number, value: Vector3d): void;
573
- /** Return a (copy of) a column of the matrix.
574
- * @param i column index. This is corrected to 012 by Geometry.cyclic3dAxis.
597
+ /**
598
+ * Return (a copy of) a column of the matrix.
599
+ * @param i column index. This is interpreted cyclically (using Geometry.cyclic3dAxis).
600
+ * @param result optional preallocated result.
575
601
  */
576
602
  getColumn(columnIndex: number, result?: Vector3d): Vector3d;
577
- /** Return a (copy of) a row of the matrix.
578
- * @param i row index. This is corrected to 012 by Geometry.cyclic3dAxis.
603
+ /**
604
+ * Return a (copy of) a row of the matrix.
605
+ * @param i row index. This is interpreted cyclically (using Geometry.cyclic3dAxis).
606
+ * @param result optional preallocated result.
579
607
  */
580
608
  getRow(columnIndex: number, result?: Vector3d): Vector3d;
581
- /** Create a matrix from row vectors.
609
+ /**
610
+ * Create a matrix from row vectors.
582
611
  * ```
583
612
  * equation
584
613
  * \begin{bmatrix}U_x & U_y & U_z \\ V_x & V_y & V_z \\ W_x & W_y & W_z \end{bmatrix}
585
614
  * ```
586
615
  */
587
616
  static createRows(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, result?: Matrix3d): Matrix3d;
588
- /** Create a matrix that scales along a specified direction.
589
- * * The scale factor can be negative.
590
- * * A scale of -1.0 (negative one) is a mirror across the plane perpendicular to the vector.
617
+ /**
618
+ * Create a matrix that scales along a specified `direction`. This means if you multiply the returned matrix
619
+ * by a `vector`, you get `directional scale` of that `vector`. Suppose `plane` is the plane perpendicular
620
+ * to the `direction`. When scale = 0, `directional scale` is projection of the `vector` to the `plane`.
621
+ * When scale = 1, `directional scale` is the `vector` itself. When scale = -1, `directional scale` is
622
+ * mirror of the `vector` across the `plane`. In general, When scale != 0, the result is computed by first
623
+ * projecting the `vector` to the `plane`, then translating that projection along the `direction` (if scale > 0)
624
+ * or in opposite direction (if scale < 0).
591
625
  * ```
592
626
  * equation
593
- * \text{The matrix is } I - (s-1) U U^T
594
- * \\ \text{with }U\text{ being the unit vector in the direction of the input vector.}
627
+ * \text{The matrix is } I + (s-1) D D^T
628
+ * \\ \text{with }D\text{ being the normalized direction vector and }s\text{ being the scale.}
595
629
  * ```
630
+ * * Visualization can be found at itwinjs.org/sandbox/SaeedTorabi/DirectionalScale
596
631
  */
597
632
  static createDirectionalScale(direction: Vector3d, scale: number, result?: Matrix3d): Matrix3d;
598
- /** Multiply the matrix * vector, treating the vector is a column vector on the right.
633
+ /**
634
+ * Multiply `matrix * vector`, treating the vector is a column vector on the right.
599
635
  * ```
600
636
  * equation
601
637
  * \matrixXY{A}\columnSubXYZ{U}
@@ -603,58 +639,71 @@ export declare class Matrix3d implements BeJSONFunctions {
603
639
  * @return the vector result
604
640
  */
605
641
  multiplyVector(vectorU: XYAndZ, result?: Vector3d): Vector3d;
606
- /** Multiply matrix * vector for each array member, i.e. the vector is a column vector on the right.
607
- * @return the vector result
642
+ /**
643
+ * Multiply `matrix * vector` in place for vector in the array, i.e. treating the vector is a column
644
+ * vector on the right.
645
+ * * Each `vector` is updated to be `matrix * vector`
608
646
  */
609
647
  multiplyVectorArrayInPlace(data: XYZ[]): void;
610
- /** compute `origin - matrix * vector` */
648
+ /** Compute `origin - matrix * vector` */
611
649
  static xyzMinusMatrixTimesXYZ(origin: XYAndZ, matrix: Matrix3d, vector: XYAndZ, result?: Point3d): Point3d;
612
- /** compute `origin + matrix * vector` using only the xy parts of the inputs. */
650
+ /** Compute `origin + matrix * vector` using only the xy parts of the inputs. */
613
651
  static xyPlusMatrixTimesXY(origin: XAndY, matrix: Matrix3d, vector: XAndY, result?: Point2d): Point2d;
614
- /** compute `origin + matrix * vector` using all xyz parts of the inputs. */
652
+ /** Compute `origin + matrix * vector` using all xyz parts of the inputs. */
615
653
  static xyzPlusMatrixTimesXYZ(origin: XYZ, matrix: Matrix3d, vector: XYAndZ, result?: Point3d): Point3d;
616
- /** compute `origin + matrix * vector` using all xyz parts of the inputs. */
654
+ /** Updates vector to be `origin + matrix * vector` using all xyz parts of the inputs. */
617
655
  static xyzPlusMatrixTimesXYZInPlace(origin: XYZ, matrix: Matrix3d, vector: WritableXYAndZ): void;
618
- /** compute `origin + matrix * vector` where the final vector is given as direct x,y,z coordinates */
656
+ /** Compute `origin + matrix * vector` where the final vector is given as direct x,y,z coordinates */
619
657
  static xyzPlusMatrixTimesCoordinates(origin: XYZ, matrix: Matrix3d, x: number, y: number, z: number, result?: Point3d): Point3d;
620
658
  /**
621
659
  * Treat the 3x3 matrix and origin as upper 3x4 part of a 4x4 matrix, with 0001 as the final row.
622
- * Multiply times point with coordinates `[x,y,z,w]`
660
+ * Multiply the 4x4 matrix by `[x,y,z,w]`
661
+ * ```
662
+ * equation
663
+ * \begin{bmatrix}M_0 & M_1 & M_2 & Ox \\ M_3 & M_4 & M_5 & Oy \\ M_6 & M_7 & M_8 & Oz \\ 0 & 0 & 0 & 1\end{bmatrix} * \begin{bmatrix}x \\ y \\ z \\ w\end{bmatrix}
664
+ * ```
623
665
  * @param origin translation part (xyz in column 3)
624
666
  * @param matrix matrix part (leading 3x3)
625
667
  * @param x x part of multiplied point
626
668
  * @param y y part of multiplied point
627
669
  * @param z z part of multiplied point
628
670
  * @param w w part of multiplied point
629
- * @param result optional result.
671
+ * @param result optional preallocated result.
630
672
  */
631
673
  static xyzPlusMatrixTimesWeightedCoordinates(origin: XYZ, matrix: Matrix3d, x: number, y: number, z: number, w: number, result?: Point4d): Point4d;
632
674
  /**
633
675
  * Treat the 3x3 matrix and origin as upper 3x4 part of a 4x4 matrix, with 0001 as the final row.
634
- * Multiply times point with coordinates `[x,y,z,w]`
676
+ * Multiply the 4x4 matrix by `[x,y,z,w]`
677
+ * ```
678
+ * equation
679
+ * \begin{bmatrix}M_0 & M_1 & M_2 & Ox \\ M_3 & M_4 & M_5 & Oy \\ M_6 & M_7 & M_8 & Oz \\ 0 & 0 & 0 & 1\end{bmatrix} * \begin{bmatrix}x \\ y \\ z \\ w\end{bmatrix}
680
+ * ```
635
681
  * @param origin translation part (xyz in column 3)
636
682
  * @param matrix matrix part (leading 3x3)
637
683
  * @param x x part of multiplied point
638
684
  * @param y y part of multiplied point
639
685
  * @param z z part of multiplied point
640
686
  * @param w w part of multiplied point
641
- * @param result optional result.
687
+ * @param result optional preallocated result.
642
688
  */
643
689
  static xyzPlusMatrixTimesWeightedCoordinatesToFloat64Array(origin: XYZ, matrix: Matrix3d, x: number, y: number, z: number, w: number, result?: Float64Array): Float64Array;
644
690
  /**
645
- * Treat the 3x3 matrix and origin as upper 3x4 part of a 4x4 matrix, with 0001 as the final row.
646
- * Multiply times point with coordinates `[x,y,z,w]`
691
+ * Treat the 3x3 matrix and origin as a 3x4 matrix.
692
+ * * Multiply the 3x4 matrix by `[x,y,z,1]`
693
+ * ```
694
+ * equation
695
+ * \begin{bmatrix}M_0 & M_1 & M_2 & Ox \\ M_3 & M_4 & M_5 & Oy \\ M_6 & M_7 & M_8 & Oz\end{bmatrix} * \begin{bmatrix}x \\ y \\ z \\ 1\end{bmatrix}
696
+ * ```
647
697
  * @param origin translation part (xyz in column 3)
648
698
  * @param matrix matrix part (leading 3x3)
649
699
  * @param x x part of multiplied point
650
700
  * @param y y part of multiplied point
651
701
  * @param z z part of multiplied point
652
- * @param w w part of multiplied point
653
- * @param result optional result.
702
+ * @param result optional preallocated result.
654
703
  */
655
704
  static xyzPlusMatrixTimesCoordinatesToFloat64Array(origin: XYZ, matrix: Matrix3d, x: number, y: number, z: number, result?: Float64Array): Float64Array;
656
705
  /**
657
- * Multiply transpose of this matrix times a vector.
706
+ * Multiply the transpose matrix times a vector.
658
707
  * * This produces the same x,y,z as treating the vector as a row on the left of the (un-transposed) matrix.
659
708
  * ```
660
709
  * equation
@@ -663,161 +712,213 @@ export declare class Matrix3d implements BeJSONFunctions {
663
712
  * \text{Treating U as a row to the left of untransposed matrix\: return row}&\rowSubXYZ{V}&=&\rowSubXYZ{U}\matrixXY{A}
664
713
  * \end{matrix}
665
714
  * ```
666
- * @return the vector result
715
+ * @return the vector result (optional)
667
716
  */
668
717
  multiplyTransposeVector(vector: Vector3d, result?: Vector3d): Vector3d;
669
- /** Multiply the matrix * (x,y,z), i.e. the vector (x,y,z) is a column vector on the right.
670
- * @return the vector result
718
+ /**
719
+ * Multiply the matrix * [x,y,z], i.e. the vector [x,y,z] is a column vector on the right.
720
+ * @return the vector result (optional)
671
721
  */
672
722
  multiplyXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d;
673
- /** Multiply the matrix * xyz, place result in (required) return value.
674
- * @param xyz right side
675
- * @param result result.
723
+ /**
724
+ * Multiply the matrix * xyz, place result in (required) return value.
725
+ * @param xyz right side
726
+ * @param result the result.
676
727
  */
677
728
  multiplyXYZtoXYZ(xyz: XYZ, result: XYZ): XYZ;
678
- /** Multiply the matrix * (x,y,0), i.e. the vector (x,y,z) is a column vector on the right.
679
- * @return the vector result
729
+ /**
730
+ * Multiply the matrix * [x,y,0], i.e. the vector [x,y,0] is a column vector on the right.
731
+ * @return the vector result (optional)
680
732
  */
681
733
  multiplyXY(x: number, y: number, result?: Vector3d): Vector3d;
682
- /** compute `origin + this*[x,y,0]` */
734
+ /**
735
+ * Compute origin + the matrix * [x,y,0].
736
+ * @return the vector result (optional)
737
+ */
683
738
  originPlusMatrixTimesXY(origin: XYZ, x: number, y: number, result?: Point3d): Point3d;
684
- /** Multiply matrix * (x, y, z) using any 3d object given containing those members */
739
+ /**
740
+ * Multiply the matrix * (x,y,z) in place, i.e. the vector (x,y,z) is a column vector on the right and
741
+ * the multiplication updates the vector values.
742
+ * @param xyzData the vector data
743
+ */
685
744
  multiplyVectorInPlace(xyzData: XYZ): void;
686
- /** Multiply the transpose matrix times column using any 3d object with x,y,z members.
687
- * This is equivalent to `multiplyTransposeVector` but always returns the result directly in the input.
745
+ /**
746
+ * Multiply the transpose matrix times [x,y,z] in place, i.e. the vector [x,y,z] is a column vector on
747
+ * the right and the multiplication updates the vector values.
748
+ * * This is equivalent to `multiplyTransposeVector` but always returns the result directly in the input.
749
+ * @param xyzData the vector data
688
750
  */
689
751
  multiplyTransposeVectorInPlace(vectorU: XYZ): void;
690
- /** Multiply the transpose matrix times column using individual numeric inputs.
691
- * * This is equivalent to multiplying with the vector as a row to the left of the plain matrix.
752
+ /**
753
+ * Multiply the transpose matrix times column using individual numeric inputs.
754
+ * * This produces the same x,y,z as treating the vector as a row on the left of the (un-transposed) matrix.
692
755
  * ```
693
756
  * equation
694
757
  * \begin{matrix}
695
- * \text{treating the input as a column } \columnXYZ{x}{y}{z}\text{ compute }&\columnSubXYZ{V} &= &A^T \columnXYZ{x}{y}{z} \\
696
- * \text{or row vector } \rowXYZ{x}{y}{z} \text{ compute }&\rowSubXYZ{V} &= &\rowXYZ{x}{y}{z} A \\
758
+ * \text{treating the input as a column vector } \columnXYZ{x}{y}{z}\text{ compute }&\columnSubXYZ{V} &= &A^T \columnXYZ{x}{y}{z} \\
759
+ * \text{or as a row vector } \rowXYZ{x}{y}{z} \text{ compute }&\rowSubXYZ{V} &= &\rowXYZ{x}{y}{z} A \\
697
760
  * \phantom{8888}\text{and return V as a Vector3d} & & &
698
761
  * \end{matrix}
699
762
  * ````
700
- * @return the vector result
763
+ * @return the vector result (optional)
701
764
  */
702
765
  multiplyTransposeXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d;
703
- /** Solve `matrix * result = vector`.
704
- * * This is equivalent to multiplication `result = matrixInverse * vector`.
705
- * * Result is undefined if the matrix is singular (e.g. has parallel or zero length columns)
766
+ /**
767
+ * Solve `matrix * result = vector` for an unknown `result`.
768
+ * * This is equivalent to multiplication `result = inverse matrix * vector`.
769
+ * * Result is undefined if the matrix is singular (e.g. has parallel columns or a zero magnitude column)
706
770
  */
707
771
  multiplyInverse(vector: Vector3d, result?: Vector3d): Vector3d | undefined;
708
- /** Solve `matrixTranspose * result = vector`.
772
+ /**
773
+ * Solve `matrixTranspose * result = vector` for an unknown `result`.
709
774
  * * This is equivalent to multiplication `result = matrixInverseTranspose * vector`.
710
- * * Result is undefined if the matrix is singular (e.g. has parallel or zero length columns)
775
+ * * Result is undefined if the matrix is singular (e.g. has parallel columns or a zero magnitude column)
711
776
  */
712
777
  multiplyInverseTranspose(vector: Vector3d, result?: Vector3d): Vector3d | undefined;
713
778
  /**
714
- * multiply `matrixInverse * [x,y,z]`.
715
- * * This is equivalent to solving `matrix * result = [x,y,z]`
716
- * * return as a Vector3d, or undefined if the matrix is singular.
779
+ * Multiply `matrixInverse * [x,y,z]`.
780
+ * * This is equivalent to solving `matrix * result = [x,y,z]` for an unknown `result`.
781
+ * * Result is undefined if the matrix is singular (e.g. has parallel columns or a zero magnitude column)
782
+ * @return result as a Vector3d or undefined (if the matrix is singular).
717
783
  */
718
784
  multiplyInverseXYZAsVector3d(x: number, y: number, z: number, result?: Vector3d): Vector3d | undefined;
719
785
  /**
720
- * multiply `matrixInverse * [x,y,z]` and return packaged as `Point4d` with given weight.
721
- * * Equivalent to solving matrix * result = [x,y,z]
722
- * * return as a Point4d with the same weight.
723
- * * Called by Transform with x,y,z adjusted by subtraction ((xw) - w * origin.x, etc) where xw is the pre-weighted space point.
786
+ * Multiply `matrixInverse * [x,y,z]` and return result as `Point4d` with given weight.
787
+ * * Equivalent to solving `matrix * result = [x,y,z]` for an unknown `result`.
788
+ * * Result is undefined if the matrix is singular (e.g. has parallel columns or a zero magnitude column)
789
+ * @return result as a Point4d with the same weight.
724
790
  */
725
791
  multiplyInverseXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d | undefined;
726
792
  /**
727
- * multiply `matrixInverse * [x,y,z]` and return packaged as `Point3d`.
728
- * * multiply matrixInverse * [x,y,z]
729
- * * Equivalent to solving matrix * result = [x,y,z]
730
- * * return as a Point3d.
793
+ * Multiply `matrixInverse * [x,y,z]` and return result as `Point3d`.
794
+ * * Equivalent to solving `matrix * result = [x,y,z]` for an unknown `result`.
795
+ * @return result as a Point3d or undefined (if the matrix is singular).
731
796
  */
732
797
  multiplyInverseXYZAsPoint3d(x: number, y: number, z: number, result?: Point3d): Point3d | undefined;
733
798
  /**
734
- * * invoke a given matrix-matrix operation (product function) to compute this.inverseCOffs
735
- * * set this.inverseCoffs
736
- * * if either input cffA or coffB is undefined, set state to `InverseMatrixState.unknown` (but leave the inverseCoffs untouched)
799
+ * Invoke a given matrix*matrix operation to compute the inverse matrix and set this.inverseCoffs
800
+ * * If either input coffA or coffB is undefined, set state to `InverseMatrixState.unknown` but
801
+ * leave the inverseCoffs untouched.
802
+ * @param f the given matrix*matrix operation that is called by this function to compute the inverse.
803
+ * `f` must be a matrix*matrix operation. Otherwise, the function does not generate the inverse properly.
737
804
  */
738
805
  private finishInverseCoffs;
739
- /** Multiply the instance matrix A by the input matrix B.
740
- * @return the matrix product A * B
806
+ /**
807
+ * Multiply `this` matrix times `other` matrix
808
+ * @return the matrix result: this*other
741
809
  */
742
810
  multiplyMatrixMatrix(other: Matrix3d, result?: Matrix3d): Matrix3d;
743
- private static _productBuffer;
744
- /** Multiply this matrix times inverse of other
745
- * @return the matrix result
811
+ /**
812
+ * Multiply `this` matrix times `inverse of other` matrix
813
+ * @return the matrix result: this*otherInverse
746
814
  */
747
815
  multiplyMatrixMatrixInverse(other: Matrix3d, result?: Matrix3d): Matrix3d | undefined;
748
- /** Multiply this matrix times inverse of other
749
- * @return the matrix result
816
+ /**
817
+ * Multiply `inverse of this` matrix times `other` matrix
818
+ * @return the matrix result: thisInverse*other
750
819
  */
751
820
  multiplyMatrixInverseMatrix(other: Matrix3d, result?: Matrix3d): Matrix3d | undefined;
752
- /** Multiply `this` matrix times the transpose of `matrixB`.
821
+ /**
822
+ * Multiply `this` matrix times the transpose of `other` matrix
753
823
  * ```
754
824
  * equation
755
- * \text{for instance matrix }A\text{ and other matrix }B\text{ return matrix }C{\text where }\\\matrixXY{C}=\matrixXY{A}\matrixTransposeSubXY{B}
825
+ * \text{for instance matrix }A\text{ and matrix }B\text{ return matrix }C{\text where }\\\matrixXY{C}=\matrixXY{A}\matrixTransposeSubXY{B}
756
826
  * ```
757
- * @return the matrix result
827
+ * @return the matrix result: this*otherTranspose
758
828
  */
759
- multiplyMatrixMatrixTranspose(matrixB: Matrix3d, result?: Matrix3d): Matrix3d;
760
- /** Matrix multiplication `thisTranspose * other`.
829
+ multiplyMatrixMatrixTranspose(other: Matrix3d, result?: Matrix3d): Matrix3d;
830
+ /**
831
+ * Multiply the transpose of `this` matrix times `other` matrix
761
832
  * ```
762
833
  * equation
763
834
  * \matrixXY{result}=\matrixXY{\text{this}}\matrixTransposeSubXY{\text{other}}
764
835
  * ```
765
- * @return the matrix result
836
+ * @return the matrix result: thisTranspose*other
766
837
  */
767
838
  multiplyMatrixTransposeMatrix(other: Matrix3d, result?: Matrix3d): Matrix3d;
768
- /** multiply this Matrix3d (considered as a transform with 0 translation) times other Transform.
839
+ /**
840
+ * Multiply `this` Matrix3d (considered as a Transform with 0 translation) times `other` Transform.
769
841
  * ```
770
842
  * equation
771
843
  * \begin{matrix}
772
- * \text{This matrix }\bold{A}\text{ promoted to block transform} & \blockTransform{A}{0} \\
773
- * \text{other transform with matrix part }\bold{B}\text{ and translation }\bold{b} & \blockTransform{B}{b}\\
844
+ * \text{This matrix }\bold{A}\text{ promoted to block transform} & \blockTransform{A}{0} \\
845
+ * \text{other transform with matrix part }\bold{B}\text{ and translation }\bold{b} & \blockTransform{B}{b}\\
774
846
  * \text{product}& \blockTransform{A}{0}\blockTransform{B}{b}=\blockTransform{AB}{Ab}
775
847
  * \end{matrix}
776
848
  * ```
777
- * @param other right hand Matrix3d for multiplication.
778
- * @param result optional preallocated result to reuse.
849
+ * @param other Right hand Matrix3d for multiplication.
850
+ * @param result the Transform result (optional)
779
851
  */
780
852
  multiplyMatrixTransform(other: Transform, result?: Transform): Transform;
781
853
  /**
782
854
  * Return the transpose of `this` matrix.
783
- * If `result` is passed as argument, then the function copies the transpose of `this` into `result`
784
- * `this` is not changed unless also passed as the result, i.e., this.transpose(this) transposes `this` in place
855
+ * * If `result` is passed as argument, then the function copies the transpose of `this` into `result`.
856
+ * * `this` is not changed unless also passed as the result, i.e., `this.transpose(this)` transposes `this` in place.
785
857
  */
786
858
  transpose(result?: Matrix3d): Matrix3d;
787
859
  /**
788
860
  * Transpose this matrix in place.
789
861
  */
790
862
  transposeInPlace(): void;
791
- /** return the inverse matrix.
792
- * The return is undefined if the matrix is singular (has columns that are coplanar or colinear)
793
- * * Note that each Matrix3d object caches its own inverse, and has methods to multiply the inverse times matrices and vectors.
794
- * * Hence explicitly constructing this new inverse object is rarely necessary.
863
+ /**
864
+ * Return the inverse matrix.
865
+ * The return is undefined if the matrix is singular (e.g. has parallel columns or a zero magnitude column)
866
+ * * If `result == this`, then content of inverse of `this` matrix is copied into `this`. Otherwise, inverse
867
+ * of `this` is stored in `result`.
868
+ * * **Note:** Each Matrix3d object caches its own inverse (`this.inverseCoffs`) and has methods to multiply
869
+ * the inverse times matrices and vectors (e.g., `multiplyMatrixInverseMatrix`, `multiplyMatrixMatrixInverse`,
870
+ * `multiplyInverse`). Hence explicitly constructing this new inverse object is rarely necessary.
795
871
  */
796
872
  inverse(result?: Matrix3d): Matrix3d | undefined;
873
+ /**
874
+ * Take the dot product of a row (specified by `rowStartA`) of `coffA` and `columnStartB` of `coffB`.
875
+ * * **Note:** We don't validate row/column numbers. Pass 0/3/6 for row 0/1/2 and pass 0/1/2 for column 0/1/2.
876
+ */
877
+ private static rowColumnDot;
878
+ /**
879
+ * Take the cross product of 2 rows (specified by `rowStart0` and `rowStart1`) of `source` and store the result
880
+ * in `columnStart` of `dest`.
881
+ * * **Note:** We don't validate row/column numbers. Pass 0/3/6 for row 0/1/2 and pass 0/1/2 for column 0/1/2.
882
+ */
797
883
  private static indexedRowCrossProduct;
884
+ /**
885
+ * Take the cross product of 2 columns (i.e., `colStart0` and `colStart1`) of `this` matrix and store the
886
+ * result in `colStart2` of the same matrix.
887
+ * * **Note:** We don't validate column numbers. Pass 0/1/2 for column 0/1/2.
888
+ */
798
889
  private indexedColumnCrossProductInPlace;
799
- /** Form cross products among columns in axisOrder.
800
- * For axis order ABC,
801
- * * form cross product of column A and B, store in C
890
+ /**
891
+ * Form cross products among columns in axisOrder.
892
+ * For axis order ABC:
893
+ * * form cross product of column A and B, store in C.
802
894
  * * form cross product of column C and A, store in B.
895
+ * * [A B C] ===> [A B AxB] ===> [A (AxB)xA AxB]
896
+ *
803
897
  * This means that in the final matrix:
804
- * * column A is strictly parallel to original column A
805
- * * column B is linear combination of only original A and B
898
+ * * column A is same as original column A.
899
+ * * column B is linear combination of original A and B (i.e., is in the plane of original A and B).
806
900
  * * column C is perpendicular to A and B of both the original and final.
807
- * * original column C does not participate in the result.
901
+ * * original column C is overwritten and does not participate in the result.
808
902
  */
809
903
  axisOrderCrossProductsInPlace(axisOrder: AxisOrder): void;
810
- /** Normalize each column in place.
811
- * * For false return the magnitudes are stored in the originalMagnitudes vector but no columns are altered.
812
- * @returns Return true if all columns had nonzero lengths.
813
- * @param originalMagnitudes optional vector to receive original column magnitudes.
814
- */
815
- normalizeColumnsInPlace(originalMagnitudes?: Vector3d): boolean;
816
- /** Normalize each row in place */
817
- normalizeRowsInPlace(originalMagnitudes?: Vector3d): boolean;
818
- private static rowColumnDot;
819
904
  /**
820
- * Returns true if the matrix is singular (i.e. collapses data to a plane, line, or point)
905
+ * Normalize each column in place.
906
+ * @param originalRowMagnitudes optional vector to store original column magnitudes.
907
+ * @returns Return true if all columns have non-zero lengths. Otherwise, return false.
908
+ * * If false is returned, the magnitudes are stored in the `originalRowMagnitudes` vector but no columns
909
+ * are altered.
910
+ */
911
+ normalizeColumnsInPlace(originalRowMagnitudes?: Vector3d): boolean;
912
+ /**
913
+ * Normalize each row in place.
914
+ * @param originalColumnMagnitudes optional vector to store original row magnitudes.
915
+ * @returns Return true if all rows have non-zero lengths. Otherwise, return false.
916
+ * * If false is returned, the magnitudes are stored in the `originalColumnMagnitudes` vector but no rows
917
+ * are altered.
918
+ */
919
+ normalizeRowsInPlace(originalColumnMagnitudes?: Vector3d): boolean;
920
+ /**
921
+ * Returns true if the matrix is singular.
821
922
  */
822
923
  isSingular(): boolean;
823
924
  /**
@@ -825,20 +926,23 @@ export declare class Matrix3d implements BeJSONFunctions {
825
926
  */
826
927
  markSingular(): void;
827
928
  /**
828
- * Create the inverseCoffs member (filled with zeros)
829
- * This is for use by matrix * matrix multiplications which need to be sure the member is there to be
830
- * filled with method-specific content.
831
- */
832
- private createInverseCoffsWithZeros;
833
- /** compute the inverse of this Matrix3d. The inverse is stored for later use.
834
- * @returns Return true if the inverse computed. (False if the columns collapse to a point, line or plane.)
929
+ * Compute the inverse of `this` Matrix3d. The inverse is stored in `this.inverseCoffs` for later use.
930
+ * @param useCacheIfAvailable if `true`, use the previously computed inverse if available. If `false`,
931
+ * recompute the inverse.
932
+ * @returns Return `true` if the inverse is computed. Return `false` if matrix is singular.
835
933
  */
836
934
  computeCachedInverse(useCacheIfAvailable: boolean): boolean;
837
- /** convert a (row,column) index pair to the single index within flattened array of 9 numbers in row-major-order */
935
+ /**
936
+ * Convert a (row,column) index pair to the single index within flattened array of 9 numbers in row-major-order
937
+ * * **Note:** Out of range row/column is interpreted cyclically.
938
+ */
838
939
  static flatIndexOf(row: number, column: number): number;
839
- /** Get a column by index (0,1,2), packaged as a Point4d with given weight. Out of range index is interpreted cyclically. */
940
+ /**
941
+ * Get elements of column `index` packaged as a Point4d with given `weight`.
942
+ * * **Note:** Out of range index is interpreted cyclically.
943
+ */
840
944
  indexedColumnWithWeight(index: number, weight: number, result?: Point4d): Point4d;
841
- /** return the entry at specific row and column */
945
+ /** Return the entry at specific row and column */
842
946
  at(row: number, column: number): number;
843
947
  /** Set the entry at specific row and column */
844
948
  setAt(row: number, column: number, value: number): void;
@@ -846,7 +950,7 @@ export declare class Matrix3d implements BeJSONFunctions {
846
950
  * @param scaleX scale factor for column x
847
951
  * @param scaleY scale factor for column y
848
952
  * @param scaleZ scale factor for column z
849
- * @param result optional result.
953
+ * @param result optional preallocated result.
850
954
  */
851
955
  scaleColumns(scaleX: number, scaleY: number, scaleZ: number, result?: Matrix3d): Matrix3d;
852
956
  /** Scale the columns of this Matrix3d.
@@ -859,7 +963,7 @@ export declare class Matrix3d implements BeJSONFunctions {
859
963
  * @param scaleX scale factor for row x
860
964
  * @param scaleY scale factor for row y
861
965
  * @param scaleZ scale factor for row z
862
- * @param result optional result.
966
+ * @param result optional preallocated result.
863
967
  */
864
968
  scaleRows(scaleX: number, scaleY: number, scaleZ: number, result?: Matrix3d): Matrix3d;
865
969
  /**
@@ -886,10 +990,24 @@ export declare class Matrix3d implements BeJSONFunctions {
886
990
  addScaledOuterProductInPlace(vectorU: Vector3d, vectorV: Vector3d, scale: number): void;
887
991
  /** create a Matrix3d whose values are uniformly scaled from this.
888
992
  * @param scale scale factor to apply.
889
- * @param result optional result.
993
+ * @param result optional preallocated result.
890
994
  * @returns Return the new or repopulated matrix
891
995
  */
892
996
  scale(scale: number, result?: Matrix3d): Matrix3d;
997
+ /**
998
+ * Create a rigid matrix (columns and rows are unit length and pairwise perpendicular) for
999
+ * the given eye coordinate.
1000
+ * * column 2 is parallel to (x,y,z).
1001
+ * * column 0 is perpendicular to column 2 and is in the xy plane.
1002
+ * * column 1 is perpendicular to both. It is the "up" vector on the view plane.
1003
+ * * Multiplying the returned matrix times a local (view) vector gives the world vector.
1004
+ * * Multiplying transpose of the returned matrix times a world vector gives the local (view) vector.
1005
+ * @param x eye x coordinate
1006
+ * @param y eye y coordinate
1007
+ * @param z eye z coordinate
1008
+ * @param result optional preallocated result
1009
+ */
1010
+ static createRigidViewAxesZTowardsEye(x: number, y: number, z: number, result?: Matrix3d): Matrix3d;
893
1011
  /** Return the determinant of this matrix. */
894
1012
  determinant(): number;
895
1013
  /** Return an estimate of how independent the columns are. Near zero is bad. Near 1 is good