@itwin/core-geometry 3.6.0-dev.8 → 4.0.0-dev.1

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 (99) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/Geometry.d.ts +25 -14
  4. package/lib/cjs/Geometry.d.ts.map +1 -1
  5. package/lib/cjs/Geometry.js +25 -14
  6. package/lib/cjs/Geometry.js.map +1 -1
  7. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +10 -6
  8. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  9. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +10 -19
  10. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  11. package/lib/cjs/geometry3d/Angle.d.ts +1 -0
  12. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  13. package/lib/cjs/geometry3d/Angle.js +1 -0
  14. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  15. package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -0
  16. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  17. package/lib/cjs/geometry3d/AngleSweep.js +1 -0
  18. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  19. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
  20. package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
  21. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  22. package/lib/cjs/geometry3d/Matrix3d.d.ts +221 -159
  23. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  24. package/lib/cjs/geometry3d/Matrix3d.js +365 -249
  25. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  26. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +71 -14
  27. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  28. package/lib/cjs/geometry3d/OrderedRotationAngles.js +204 -114
  29. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  30. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +1 -0
  31. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  32. package/lib/cjs/geometry3d/Point2dVector2d.js +1 -0
  33. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  34. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +4 -3
  35. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  36. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
  37. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  38. package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts +49 -25
  39. package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
  40. package/lib/cjs/geometry3d/YawPitchRollAngles.js +146 -50
  41. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  42. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +4 -4
  43. package/lib/cjs/polyface/PolyfaceBuilder.js +4 -4
  44. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  45. package/lib/cjs/polyface/PolyfaceQuery.d.ts +28 -0
  46. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  47. package/lib/cjs/polyface/PolyfaceQuery.js +79 -0
  48. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  49. package/lib/cjs/serialization/IModelJsonSchema.d.ts +1 -1
  50. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  51. package/lib/esm/Geometry.d.ts +25 -14
  52. package/lib/esm/Geometry.d.ts.map +1 -1
  53. package/lib/esm/Geometry.js +25 -14
  54. package/lib/esm/Geometry.js.map +1 -1
  55. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +10 -6
  56. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  57. package/lib/esm/curve/CurveChainWithDistanceIndex.js +10 -19
  58. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  59. package/lib/esm/geometry3d/Angle.d.ts +1 -0
  60. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  61. package/lib/esm/geometry3d/Angle.js +1 -0
  62. package/lib/esm/geometry3d/Angle.js.map +1 -1
  63. package/lib/esm/geometry3d/AngleSweep.d.ts +1 -0
  64. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  65. package/lib/esm/geometry3d/AngleSweep.js +1 -0
  66. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  67. package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
  68. package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
  69. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  70. package/lib/esm/geometry3d/Matrix3d.d.ts +221 -159
  71. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  72. package/lib/esm/geometry3d/Matrix3d.js +365 -249
  73. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  74. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +71 -14
  75. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  76. package/lib/esm/geometry3d/OrderedRotationAngles.js +205 -115
  77. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  78. package/lib/esm/geometry3d/Point2dVector2d.d.ts +1 -0
  79. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  80. package/lib/esm/geometry3d/Point2dVector2d.js +1 -0
  81. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  82. package/lib/esm/geometry3d/Point3dVector3d.d.ts +4 -3
  83. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  84. package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
  85. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  86. package/lib/esm/geometry3d/YawPitchRollAngles.d.ts +49 -25
  87. package/lib/esm/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
  88. package/lib/esm/geometry3d/YawPitchRollAngles.js +146 -50
  89. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  90. package/lib/esm/polyface/PolyfaceBuilder.d.ts +4 -4
  91. package/lib/esm/polyface/PolyfaceBuilder.js +4 -4
  92. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  93. package/lib/esm/polyface/PolyfaceQuery.d.ts +28 -0
  94. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  95. package/lib/esm/polyface/PolyfaceQuery.js +79 -0
  96. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  97. package/lib/esm/serialization/IModelJsonSchema.d.ts +1 -1
  98. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  99. package/package.json +4 -4
@@ -33,54 +33,60 @@ export declare class PackedMatrix3dOps {
33
33
  */
34
34
  static loadMatrix(dest: Float64Array, a00: number, a01: number, a02: number, a10: number, a11: number, a12: number, a20: number, a21: number, a22: number): void;
35
35
  /**
36
- * * multiply 3x3 matrix `a*b`, store in c.
36
+ * Multiply 3x3 matrix `a*b`, store in `result`.
37
37
  * * All params assumed length 9, allocated by caller.
38
38
  * * c may alias either input.
39
39
  */
40
40
  static multiplyMatrixMatrix(a: Float64Array, b: Float64Array, result?: Float64Array): Float64Array;
41
41
  /**
42
- * * multiply 3x3 matrix `a*bTranspose`, store in c.
42
+ * Multiply 3x3 matrix `a*bTranspose`, store in `result`.
43
43
  * * All params assumed length 9, allocated by caller.
44
44
  * * c may alias either input.
45
45
  */
46
46
  static multiplyMatrixMatrixTranspose(a: Float64Array, b: Float64Array, result?: Float64Array): Float64Array;
47
47
  /**
48
- * * multiply 3x3 matrix `a*bTranspose`, store in c.
48
+ * Multiply 3x3 matrix `aTranspose*b`, store in `result`.
49
49
  * * All params assumed length 9, allocated by caller.
50
50
  * * c may alias either input.
51
51
  */
52
52
  static multiplyMatrixTransposeMatrix(a: Float64Array, b: Float64Array, result?: Float64Array): Float64Array;
53
- /** transpose 3x3 coefficients in place */
53
+ /** Transpose 3x3 matrix `a` in place */
54
54
  static transposeInPlace(a: Float64Array): void;
55
- /** transpose 3x3 coefficients in place */
55
+ /**
56
+ * Returns the transpose of 3x3 matrix `a`
57
+ * * If `dest` is passed as argument, then the function copies the transpose of 3x3 matrix `a` into `dest`
58
+ * * `a` is not changed unless also passed as the dest, i.e., copyTransposed(a,a) transposes `a` in place
59
+ */
56
60
  static copyTransposed(a: Float64Array, dest?: Float64Array): Float64Array;
57
- /** transpose 3x3 coefficients in place */
61
+ /** Copy matrix `a` entries into `dest` */
58
62
  static copy(a: Float64Array, dest: Float64Array): Float64Array;
59
63
  }
60
64
  /** A Matrix3d is tagged indicating one of the following states:
61
65
  * * unknown: it is not know if the matrix is invertible.
62
- * * inverseStored: the matrix has its inverse stored
66
+ * * inverseStored: the matrix has its inverse stored.
63
67
  * * singular: the matrix is known to be singular.
64
68
  * @public
65
69
  */
66
70
  export declare enum InverseMatrixState {
67
71
  /**
68
- * * The invertibility of the `coffs` array has not been determined.
69
- * * Any `inverseCoffs` contents are random.
72
+ * The invertibility of the `coffs` array has not been determined.
73
+ * Any `inverseCoffs` contents are random.
70
74
  */
71
75
  unknown = 0,
72
- /** An inverse was computed and stored as the `inverseCoffs` */
76
+ /**
77
+ * An inverse was computed and stored as the `inverseCoffs`
78
+ */
73
79
  inverseStored = 1,
74
80
  /**
75
- * * The `coffs` array is known to be singular.
76
- * * Any `inverseCoffs` contents are random.
81
+ * The `coffs` array is known to be singular.
82
+ * Any `inverseCoffs` contents are random.
77
83
  */
78
84
  singular = 2
79
85
  }
80
86
  /** A Matrix3d is a 3x3 matrix.
81
87
  * * A very common use is to hold a rigid body rotation (which has no scaling or skew), but the 3x3 contents can
82
88
  * also hold scaling and skewing.
83
- * * The matrix with 2-dimensional layout
89
+ * * The matrix with 2-dimensional layout (note: a 2d array can be shown by a matrix)
84
90
  * ```
85
91
  * equation
86
92
  * \matrixXY{A}
@@ -92,42 +98,43 @@ export declare enum InverseMatrixState {
92
98
  * ```
93
99
  * * If the matrix inverse is known it is stored in the inverseCoffs array.
94
100
  * * The inverse status (`unknown`, `inverseStored`, `singular`) status is indicated by the `inverseState` property.
95
- * * construction methods that are able to trivially construct the inverse store it immediately and note that in the inverseState.
96
- * * constructions (e.g. createRowValues) for which the inverse is not immediately known mark the
97
- * inverseState as unknown.
98
- * * Later queries for the inverse trigger full computation if needed at that time.
101
+ * * Construction methods that are able to trivially construct the inverse, store it immediately and note that in
102
+ * the inverseState.
103
+ * * Constructions (e.g. createRowValues) for which the inverse is not immediately known mark the inverseState as
104
+ * unknown.
105
+ * * Later queries for the inverse, trigger full computation if needed at that time.
99
106
  * * Most matrix queries are present with both "column" and "row" variants.
100
- * * Usage elsewhere in the library is typically "column" based. For example, in a Transform
101
- * that carries a coordinate frame the matrix columns are the unit vectors for the axes.
107
+ * * Usage elsewhere in the library is typically "column" based. For example, in a Transform that carries a
108
+ * coordinate frame, the matrix columns are the unit vectors for the axes.
102
109
  * @public
103
110
  */
104
111
  export declare class Matrix3d implements BeJSONFunctions {
105
112
  /** Control flag for whether this class uses cached inverse of matrices. */
106
113
  static useCachedInverse: boolean;
107
- /** total number of times a cached inverse was used to avoid recompute */
114
+ /** Total number of times a cached inverse was used to avoid recompute */
108
115
  static numUseCache: number;
109
- /** total number of times a cached inverse was computed. */
116
+ /** Total number of times a cached inverse was computed. */
110
117
  static numComputeCache: number;
111
- /** Matrix contents as a flat array of numbers in row-major order.
118
+ /**
119
+ * Matrix contents as a flat array of numbers in row-major order.
112
120
  * ```
113
121
  * equation
114
122
  * \mxy{B}
115
123
  * \mij{B}
116
124
  * ```
117
- * * DO NOT directly modify this array. It will destroy safety of the cached inverse state.
125
+ * * DO NOT directly modify this array. It will destroy safety of the cached inverse state.
118
126
  */
119
127
  coffs: Float64Array;
120
- /** matrix inverse contents.
121
- * * DO NOT directly modify this array. It will destroy integrity of the cached inverse state.
128
+ /**
129
+ * Matrix inverse contents.
122
130
  * ```
123
131
  * equation
124
132
  * \mxy{A}
125
133
  * ```
126
- *
127
- *
134
+ * * DO NOT directly modify this array. It will destroy integrity of the cached inverse state.
128
135
  */
129
136
  inverseCoffs: Float64Array | undefined;
130
- /** indicates if inverse is unknown, available, or known singular */
137
+ /** Indicates if inverse is unknown, available, or known singular */
131
138
  inverseState: InverseMatrixState;
132
139
  private static _identity;
133
140
  /** The identity Matrix3d. Value is frozen and cannot be modified. */
@@ -135,40 +142,61 @@ export declare class Matrix3d implements BeJSONFunctions {
135
142
  /** Freeze this Matrix3d. */
136
143
  freeze(): Readonly<this>;
137
144
  /**
138
- *
139
- * @param coffs optional coefficient array. This is captured.
145
+ * Constructor
146
+ * @param coffs optional coefficient array.
147
+ * * **WARNING:** coffs is captured (i.e., is now owned by the Matrix3d object and can be modified by it).
140
148
  */
141
149
  constructor(coffs?: Float64Array);
142
- /** Return a json object containing the 9 numeric entries as a single array in row major order,
150
+ /**
151
+ * Return a json object containing the 9 numeric entries as a single array in row major order,
143
152
  * `[ [1, 2, 3],[ 4, 5, 6], [7, 8, 9] ]`
144
153
  */
145
154
  toJSON(): Matrix3dProps;
146
- /** copy data from various input forms to this matrix.
155
+ /**
156
+ * Copy data from various input forms to this matrix.
147
157
  * The source can be:
148
158
  * * Another `Matrix3d`
149
159
  * * An array of 3 arrays, each of which has the 3 numbers for a row of the matrix.
150
- * * An array of 9 numbers in row major order.
160
+ * * An array of 4 or 9 numbers in row major order.
161
+ * * **WARNING:** if json is an array of numbers but size is not 4 or 9, the matrix is set to zeros.
151
162
  */
152
163
  setFromJSON(json?: Matrix3dProps | Matrix3d): void;
153
- /** Return a new Matrix3d constructed from contents of the json value. Se `setFromJSON` for layout rules */
164
+ /** Return a new Matrix3d constructed from contents of the json value. See `setFromJSON` for layout rules */
154
165
  static fromJSON(json?: Matrix3dProps): Matrix3d;
155
- /** Test if this Matrix3d and other are within tolerance in all numeric entries.
166
+ /**
167
+ * Test if `this` and `other` are within tolerance in all numeric entries.
156
168
  * @param tol optional tolerance for comparisons by Geometry.isDistanceWithinTol
157
169
  */
158
170
  isAlmostEqual(other: Matrix3d, tol?: number): boolean;
159
- /** Test if `this` and `other` have almost equal Z column and have X and Y columns differing only by a rotation around that Z.
171
+ /**
172
+ * Test if `this` and `other` are within tolerance in the column entries specified by `columnIndex`.
160
173
  * @param tol optional tolerance for comparisons by Geometry.isDistanceWithinTol
161
174
  */
162
- isAlmostEqualAllowZRotation(other: Matrix3d, tol?: number): boolean;
163
175
  isAlmostEqualColumn(columnIndex: AxisIndex, other: Matrix3d, tol?: number): boolean;
176
+ /**
177
+ * Test if column (specified by `columnIndex`) entries of `this` and [ax,ay,az] are within tolerance.
178
+ * @param tol optional tolerance for comparisons by Geometry.isDistanceWithinTol
179
+ */
164
180
  isAlmostEqualColumnXYZ(columnIndex: AxisIndex, ax: number, ay: number, az: number, tol?: number): boolean;
181
+ /**
182
+ * Test if `this` and `other` have almost equal Z column and have X and Y columns differing only by a
183
+ * rotation of the same angle around that Z.
184
+ * * **WARNING:** X and Y columns have to be perpendicular to Z column in both `this` and `other`.
185
+ * @param tol optional tolerance for comparisons by Geometry.isDistanceWithinTol
186
+ */
187
+ isAlmostEqualAllowZRotation(other: Matrix3d, tol?: number): boolean;
165
188
  /** Test for exact (bitwise) equality with other. */
166
189
  isExactEqual(other: Matrix3d): boolean;
167
190
  /** test if all entries in the z row and column are exact 001, i.e. the matrix only acts in 2d */
168
191
  get isXY(): boolean;
192
+ /**
193
+ * If result is not provided, then the method returns a new (zeroed) matrix; otherwise the result is
194
+ * not zeroed first and is just returned as-is.
195
+ */
169
196
  private static _create;
170
- /** Returns a Matrix3d populated by numeric values given in row-major order.
171
- * set all entries in the matrix from call parameters appearing in row - major order, i.e.
197
+ /**
198
+ * Returns a Matrix3d populated by numeric values given in row-major order.
199
+ * Sets all entries in the matrix from call parameters appearing in row-major order, i.e.
172
200
  * ```
173
201
  * equation
174
202
  * \begin{bmatrix}a_{xx}\ a_{xy}\ a_{xz}\\ a_{yx}\ a_{yy}\ a_{yz}\\ a_{zx}\ a_{zy}\ a_{zz}\end{bmatrix}
@@ -186,7 +214,7 @@ export declare class Matrix3d implements BeJSONFunctions {
186
214
  static createRowValues(axx: number, axy: number, axz: number, ayx: number, ayy: number, ayz: number, azx: number, azy: number, azz: number, result?: Matrix3d): Matrix3d;
187
215
  /**
188
216
  * Create a Matrix3d with caller-supplied coefficients and optional inverse coefficients.
189
- * * The inputs are captured into the new Matrix3d.
217
+ * * The inputs are captured into (i.e., owned by) the new Matrix3d.
190
218
  * * The caller is responsible for validity of the inverse coefficients.
191
219
  * @param coffs (required) array of 9 coefficients.
192
220
  * @param inverseCoffs (optional) array of 9 coefficients.
@@ -194,16 +222,24 @@ export declare class Matrix3d implements BeJSONFunctions {
194
222
  */
195
223
  static createCapture(coffs: Float64Array, inverseCoffs?: Float64Array): Matrix3d;
196
224
  /**
197
- * create a matrix by distributing vectors to columns in one of 6 orders.
225
+ * Create a matrix by distributing vectors to columns in one of 6 orders.
198
226
  * @param axisOrder identifies where the columns are placed.
199
- * @param columnA vector to place in the first column named by the axis order.
200
- * @param columnB vector to place in the second column named by the axis order.
201
- * @param columnC vector to place in the third column named by the axis order.
202
- * @param result
203
- */
204
- static createColumnsInAxisOrder(axisOrder: AxisOrder, columnA: Vector3d, columnB: Vector3d, columnC: Vector3d | undefined, result?: Matrix3d): Matrix3d;
227
+ * @param columnA vector to place in the column specified by first letter in the AxisOrder name.
228
+ * @param columnB vector to place in the column specified by second letter in the AxisOrder name.
229
+ * @param columnC vector to place in the column specified by third letter in the AxisOrder name.
230
+ * @param result optional result matrix3d
231
+ * * Example: If you pass AxisOrder.YZX, then result will be [columnC, columnA, columnB] because
232
+ * first letter Y means columnA should go to the second column, second letter Z means columnB should
233
+ * go to the third column, and third letter X means columnC should go to the first column.
234
+ */
235
+ static createColumnsInAxisOrder(axisOrder: AxisOrder, columnA: Vector3d | undefined, columnB: Vector3d | undefined, columnC: Vector3d | undefined, result?: Matrix3d): Matrix3d;
236
+ /**
237
+ * Copy the transpose of the coffs to the inverseCoffs.
238
+ * * Mark the matrix as inverseStored.
239
+ */
240
+ private setupInverseTranspose;
205
241
  /**
206
- * set all entries in the matrix from call parameters appearing in row-major order.
242
+ * Set all entries in the matrix from call parameters appearing in row-major order.
207
243
  * @param axx Row x, column x (0,0) entry
208
244
  * @param axy Row x, column y (0,1) entry
209
245
  * @param axz Row x, column z (0,2) entry
@@ -219,38 +255,47 @@ export declare class Matrix3d implements BeJSONFunctions {
219
255
  setIdentity(): void;
220
256
  /** Set the matrix to all zeros. */
221
257
  setZero(): void;
222
- /** copy contents from another matrix. */
258
+ /** Copy contents from another matrix. */
223
259
  setFrom(other: Matrix3d | undefined): void;
224
- /** return a clone of this matrix.
225
- * * coefficients are copied.
226
- * * inverse coefficients are NOT copied.
227
- * * inverse status is set to unknown
260
+ /**
261
+ * Return a clone of this matrix.
262
+ * * Coefficients are copied.
263
+ * * Inverse coefficients and inverse status are copied if stored by `this`.
228
264
  */
229
265
  clone(result?: Matrix3d): Matrix3d;
230
- /** create a matrix with all zeros.
266
+ /**
267
+ * Create a matrix with all zeros.
231
268
  * * Note that for geometry transformations "all zeros" is not a useful default state.
232
- * * Hence almost always use `createIdentity` for graphics transformations.
233
- * * "all zeros" is appropriate for summing moment data.
269
+ * * Hence, almost always use `createIdentity` for graphics transformations.
270
+ * * "All zeros" is appropriate for summing moment data.
234
271
  * ```
235
272
  * equation
236
- * \begin{bmatrix}0 0 0 \\ 0 0 0 \\ 0 0 0\end{bmatrix}
273
+ * \begin{bmatrix}0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0\end{bmatrix}
237
274
  * ```
238
275
  */
239
276
  static createZero(): Matrix3d;
240
- /** create an identity matrix.
241
- * * all diagonal entries (xx,yy,zz) are one
242
- * * all others are zero.
243
- * * This (rather than all zeros) is the useful state for most graphics transformations.
277
+ /**
278
+ * Create an identity matrix.
279
+ * * All diagonal entries (xx,yy,zz) are one
280
+ * * All others are zero.
281
+ * * This (rather than "all zeros") is the useful state for most graphics transformations.
244
282
  * ```
245
283
  * equation
246
- * \begin{bmatrix}1 0 0 \\ 0 1 0 \\ 0 0 1\end{bmatrix}
284
+ * \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix}
247
285
  * ```
248
286
  *
249
287
  */
250
288
  static createIdentity(result?: Matrix3d): Matrix3d;
251
289
  /**
252
- * Create a matrix with uniform scale factors.
253
- * For scale factor _s_,
290
+ * Create a matrix with distinct x,y,z diagonal (scale) entries.
291
+ * ```
292
+ * equation
293
+ * \begin{bmatrix}s_x & 0 & 0 \\ 0 & s_y & 0\\ 0 & 0 & s_z\end{bmatrix}
294
+ * ```
295
+ */
296
+ static createScale(scaleFactorX: number, scaleFactorY: number, scaleFactorZ: number, result?: Matrix3d): Matrix3d;
297
+ /**
298
+ * Create a matrix with uniform scale factors for scale factor "s"
254
299
  * ```
255
300
  * equation
256
301
  * \begin{bmatrix}s & 0 & 0 \\ 0 & s & 0\\ 0 & 0 & s\end{bmatrix}
@@ -258,71 +303,124 @@ export declare class Matrix3d implements BeJSONFunctions {
258
303
  */
259
304
  static createUniformScale(scaleFactor: number): Matrix3d;
260
305
  /**
261
- * Construct a rigid matrix using createPerpendicularVectorFavorXYPlane to generate a vector perpendicular to vectorA.
262
- * *
306
+ * Return a vector that is perpendicular to the input `vectorA`.
307
+ * * Among the infinite number of perpendiculars possible, this method favors having one in the xy plane.
308
+ * * Hence, when `vectorA` is close to the Z axis, the returned vector is `vectorA cross -unitY`
309
+ * but when `vectorA` is NOT close to the Z axis, the returned vector is `unitZ cross vectorA`.
263
310
  */
264
- static createRigidHeadsUp(vectorA: Vector3d, axisOrder?: AxisOrder, result?: Matrix3d): Matrix3d;
311
+ static createPerpendicularVectorFavorXYPlane(vectorA: Vector3d, result?: Vector3d): Vector3d;
265
312
  /**
266
- * return a vector that is perpendicular to the input direction.
267
- * * Among the infinite number of perpendiculars possible, this method
268
- * favors having one in the xy plane.
269
- * * Hence, when vectorA is NOT close to the Z axis, the returned vector is Z cross vectorA.
270
- * * But vectorA is close to the Z axis, the returned vector is unitY cross vectorA.
313
+ * Return a vector that is perpendicular to the input `vectorA`.
314
+ * * Among the infinite number of perpendiculars possible, this method favors having one near the plane
315
+ * containing Z.
316
+ * That is achieved by cross product of `this` vector with the result of createPerpendicularVectorFavorXYPlane.
271
317
  */
272
- static createPerpendicularVectorFavorXYPlane(vector: Vector3d, result?: Vector3d): Vector3d;
318
+ static createPerpendicularVectorFavorPlaneContainingZ(vectorA: Vector3d, result?: Vector3d): Vector3d;
273
319
  /**
274
- * return a vector that is perpendicular to the input direction.
275
- * * Among the infinite number of perpendiculars possible, this method
276
- * favors having one near the Z.
277
- * That is achieved by crossing "this" vector with the result of createPerpendicularVectorFavorXYPlane.
320
+ * Create a matrix from column vectors, shuffled into place per axisOrder
321
+ * For example, if axisOrder = XYZ then it returns [vectorU, vectorV, vectorW]
322
+ * Another example, if axisOrder = YZX then it returns [vectorW, vectorU, vectorV] because
323
+ * Y is at index 0 so vectorU goes to the column Y (column 2), Z is at index 1 so vectorV goes
324
+ * to the column Z (column 3), and X is at index 2 so vectorW goes to the column X (column 1)
278
325
  */
279
- static createPerpendicularVectorFavorPlaneContainingZ(vector: Vector3d, result?: Vector3d): Vector3d;
280
- /** Create a matrix with distinct x,y,z diagonal (scale) entries.
281
- * ```
282
- * equation
283
- * \begin{bmatrix}s_x & 0 & 0 \\ 0 & s_y & 0\\ 0 & 0 & s_z\end{bmatrix}
284
- * ```
326
+ static createShuffledColumns(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, axisOrder: AxisOrder, result?: Matrix3d): Matrix3d;
327
+ /**
328
+ * Create a new orthogonal matrix (perpendicular columns, unit length, transpose is inverse).
329
+ * * `vectorA1 = Normalized vectorA` is placed in the column specified by **first** letter in
330
+ * the AxisOrder name.
331
+ * * Normalized `vectorC1 = vectorA1 cross vectorB` is placed in the column specified by **third**
332
+ * letter in the AxisOrder name.
333
+ * * Normalized `vectorC1 cross vectorA` is placed in the column specified by **second**
334
+ * letter in the AxisOrder name.
335
+ * * This function internally uses createShuffledColumns.
285
336
  */
286
- static createScale(scaleFactorX: number, scaleFactorY: number, scaleFactorZ: number, result?: Matrix3d): Matrix3d;
287
- /** return a rotation of specified angle around an axis */
337
+ static createRigidFromColumns(vectorA: Vector3d, vectorB: Vector3d, axisOrder: AxisOrder, result?: Matrix3d): Matrix3d | undefined;
338
+ /**
339
+ * Construct a rigid matrix using vectorA and its 2 perpendicular.
340
+ * * This function internally uses createPerpendicularVectorFavorXYPlane and createRigidFromColumns.
341
+ */
342
+ static createRigidHeadsUp(vectorA: Vector3d, axisOrder?: AxisOrder, result?: Matrix3d): Matrix3d;
343
+ /** Return the matrix for rotation of `angle` around `axis` */
288
344
  static createRotationAroundVector(axis: Vector3d, angle: Angle, result?: Matrix3d): Matrix3d | undefined;
289
345
  /** Returns a rotation of specified angle around an axis
290
346
  * @param axisIndex index of axis (AxisIndex.X, AxisIndex.Y, AxisIndex.Z) kept fixed by the rotation.
291
347
  * @param angle angle of rotation
292
348
  * @param result optional result matrix.
349
+ * * Math details of 3d rotation matrices derivation can be found at docs/learning/geometry/Angle.md
293
350
  */
294
351
  static createRotationAroundAxisIndex(axisIndex: AxisIndex, angle: Angle, result?: Matrix3d): Matrix3d;
352
+ /**
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
+ */
361
+ applyGivensColumnOp(i: number, j: number, c: number, s: number): void;
362
+ /**
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
+ */
369
+ static createColumns(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, result?: Matrix3d): Matrix3d;
370
+ /** Create a matrix with each column's _x,y_ parts given `XAndY` and separate numeric z values.
371
+ * ```
372
+ * equation
373
+ * \begin{bmatrix}U_x & V_x & W_x \\ U_y & V_y & W_y \\ u & v & w \end{bmatrix}
374
+ * ```
375
+ */
376
+ static createColumnsXYW(vectorU: XAndY, u: number, vectorV: XAndY, v: number, vectorW: XAndY, w: number, result?: Matrix3d): Matrix3d;
295
377
  /** Create a matrix from "as viewed" right and up vectors.
296
378
  * * ColumnX points in the rightVector direction
297
- * * ColumnY points in in the upVectorDirection
298
- * * ColumnZ is a unit cross product.
299
- * Optionally rotate the standard cube by 45 to bring its left or right vertical edge to center
300
- * * leftNoneRight = [-1,0,1] respectively for left edge, no rotation, or right edge
301
- * * bottomNoneTop = [-1,0,1] respectively for isometric rotation to view the bottom, no isometric rotation, and isometric rotation to view the top
302
- * This is expected to be used with various principal unit vectors that are perpendicular to each other.
303
- * * STANDARD TOP VIEW: (Vector3d.UnitX (), Vector3d.UnitY (), 0, 0)
304
- * * STANDARD FRONT VIEW: (Vector3d.UnitX (), Vector3d.UnitZ (), 0, 0)
305
- * * STANDARD BACK VIEW: (Vector3d.UnitX (-1), Vector3d.UnitZ (), 0, 0)
306
- * * STANDARD RIGHT VIEW: (Vector3d.UnitY (1), Vector3d.UnitZ (), 0, 0)
307
- * * STANDARD LEFT VIEW: (Vector3d.UnitY (-1), Vector3d.UnitZ (), 0, 0)
308
- * * STANDARD BOTTOM VIEW: (Vector3d.UnitX (1), Vector3d.UnitY (-1), 0, 0)
309
- * @param leftNoneRight Normally one of {-1,0,1}, where (-1) indicates the left vertical is rotated to center and (1) for right. Other numbers are used as multiplier for this 45 degree rotation
310
- * @returns undefined if columnX, columnY are coplanar.
379
+ * * ColumnY points in the upVector direction
380
+ * * 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).
383
+ * * This is expected to be used with various principal unit vectors that are perpendicular to each other.
384
+ * * STANDARD TOP VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitY(), 0, 0)
385
+ * * STANDARD FRONT VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitZ(), 0, 0)
386
+ * * STANDARD BACK VIEW: createViewedAxes(Vector3d.unitX(-1), Vector3d.unitZ(), 0, 0)
387
+ * * STANDARD RIGHT VIEW: createViewedAxes(Vector3d.unitY(), Vector3d.unitZ(), 0, 0)
388
+ * * STANDARD LEFT VIEW: createViewedAxes(Vector3d.unitY(-1), Vector3d.unitZ(), 0, 0)
389
+ * * STANDARD BOTTOM VIEW: createViewedAxes(Vector3d.unitX(), Vector3d.unitY(-1), 0, 0)
390
+ * * Note: createViewedAxes is column-based so always returns local to world
391
+ *
392
+ * @param rightVector ColumnX of the returned matrix. Expected to be perpendicular to upVector.
393
+ * @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,
396
+ * and "1" indicates rotation by 45 degrees to bring the right vertical edge to center. Other numbers are
397
+ * 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,
400
+ * and "1" indicates isometric rotation (35.264 degrees) to bring the top downward. Other numbers are
401
+ * used as multiplier for the 35.264 degree rotation.
402
+ * @returns matrix = [rightVector, upVector, rightVector cross upVector] with the applied rotations specified
403
+ * by leftNoneRight and topNoneBottom. Returns undefined if rightVector and upVector are parallel.
311
404
  */
312
405
  static createViewedAxes(rightVector: Vector3d, upVector: Vector3d, leftNoneRight?: number, topNoneBottom?: number): Matrix3d | undefined;
313
406
  /**
314
407
  * Create a rotation matrix for one of the 8 standard views.
315
- * * With `invert === false` the return is such that `matrix.multiply(worldVector)` returns the vector as seen in the xy (projected) coordinates of the view.
316
- * * With invert === true the matrix is transposed so that `matrix.multiply(viewVector` maps the "in view" vector to a world vector.
408
+ * * Default is TOP view (`local X = world X`, `local Y = world Y`, `local Z = world Z`).
409
+ * * To change view from the TOP to one of the other 7 standard views, we need to multiply "world data" to
410
+ * the corresponding matrix1 provided by `createStandardWorldToView(index, false)` and then
411
+ * `matrix1.multiply(world data)` will returns "local data".
412
+ * * To change view back to the TOP, we need to multiply "local data" to the corresponding matrix2 provided
413
+ * by `createStandardWorldToView(index, true)` and then `matrix2.multiply(local data)` will returns "world data".
317
414
  *
318
- * @param index standard view index `StandardViewIndex.Top, Bottom, LEft, Right, Front, Back, Iso, LeftIso`
319
- * @param invert if false (default), the returned Matrix3d "projects" world vectors into XY view vectors. If true, it is inverted to map view vectors to world.
415
+ * @param index standard view index `StandardViewIndex.Top, Bottom, Left, Right, Front, Back, Iso, RightIso`
416
+ * @param invert if false (default), the return matrix is world to local (view) and if true, the the return
417
+ * matrix is local (view) to world.
320
418
  * @param result optional result.
321
419
  */
322
420
  static createStandardWorldToView(index: StandardViewIndex, invert?: boolean, result?: Matrix3d): Matrix3d;
323
421
  /**
324
422
  * Compute the (unit vector) axis and angle of rotation.
325
- * @returns Returns with result.ok === true when the conversion succeeded.
423
+ * @returns Returns axis and angle of rotation with result.ok === true when the conversion succeeded.
326
424
  */
327
425
  getAxisAndAngleOfRotation(): {
328
426
  axis: Vector3d;
@@ -406,23 +504,7 @@ export declare class Matrix3d implements BeJSONFunctions {
406
504
  dotRowZXYZ(x: number, y: number, z: number): number;
407
505
  /** Return the (vector) cross product of the Z column with the vector parameter. */
408
506
  columnZCrossVector(vector: XYZ, result?: Vector3d): Vector3d;
409
- /**
410
- * Replace current rows Ui Uj with (c*Ui - s*Uj) and (c*Uj + s*Ui).
411
- * @param i first row index. must be 0,1,2 (unchecked)
412
- * @param j second row index. must be 0,1,2 (unchecked)
413
- * @param c fist coefficient
414
- * @param s second coefficient
415
- */
416
507
  private applyGivensRowOp;
417
- /**
418
- * Replace current columns Ui Uj with (c*Ui - s*Uj) and (c*Uj + s*Ui).
419
- * * This is used in compute intensive inner loops -- there is no checking for i,j being 0,1,2.
420
- * @param i first row index. must be 0,1,2 (unchecked)
421
- * @param j second row index. must be 0,1,2 (unchecked)
422
- * @param c fist coefficient
423
- * @param s second coefficient
424
- */
425
- applyGivensColumnOp(i: number, j: number, c: number, s: number): void;
426
508
  /**
427
509
  * create a rigid coordinate frame column z parallel to (_x_,_y_,_z_) and column x in the xy plane.
428
510
  * * column z points from origin to x,y,z
@@ -472,26 +554,11 @@ export declare class Matrix3d implements BeJSONFunctions {
472
554
  * @param factor (allocate by caller, computed here)
473
555
  */
474
556
  fastSymmetricEigenvalues(leftEigenvectors: Matrix3d, lambda: Vector3d): boolean;
475
- /**
476
- * Create a matrix from column vectors.
477
- * ```
478
- * equation
479
- * \begin{bmatrix}U_x & V_x & W_x \\ U_y & V_y & W_y \\ U_z & V_z & W_z \end{bmatrix}
480
- * ```
481
- */
482
- static createColumns(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, result?: Matrix3d): Matrix3d;
483
- /** Create a matrix with each column's _x,y_ parts given `XAndY` and separate numeric z values.
484
- * ```
485
- * equation
486
- * \begin{bmatrix}U_x & V_x & W_x \\ U_y & V_y & W_y \\ u & v & w \end{bmatrix}
487
- * ```
488
- */
489
- static createColumnsXYW(vectorU: XAndY, u: number, vectorV: XAndY, v: number, vectorW: XAndY, w: number, result?: Matrix3d): Matrix3d;
490
557
  /** Install data from xyz parts of Point4d (w part of Point4d ignored) */
491
558
  setColumnsPoint4dXYZ(vectorU: Point4d, vectorV: Point4d, vectorW: Point4d): void;
492
559
  /**
493
- * set entries in one column of the matrix.
494
- * @param columnIndex column index. this is interpreted cyclically.
560
+ * Set entries in one column of the matrix.
561
+ * @param columnIndex column index (this is interpreted cyclically. See Geometry.cyclic3dAxis for more info).
495
562
  * @param value x,yz, values for column. If undefined, zeros are installed.
496
563
  */
497
564
  setColumn(columnIndex: number, value: Vector3d | undefined): void;
@@ -511,8 +578,6 @@ export declare class Matrix3d implements BeJSONFunctions {
511
578
  * @param i row index. This is corrected to 012 by Geometry.cyclic3dAxis.
512
579
  */
513
580
  getRow(columnIndex: number, result?: Vector3d): Vector3d;
514
- /** Create a matrix from column vectors, shuffled into place per AxisTriple */
515
- static createShuffledColumns(vectorU: Vector3d, vectorV: Vector3d, vectorW: Vector3d, axisOrder: AxisOrder, result?: Matrix3d): Matrix3d;
516
581
  /** Create a matrix from row vectors.
517
582
  * ```
518
583
  * equation
@@ -713,10 +778,14 @@ export declare class Matrix3d implements BeJSONFunctions {
713
778
  * @param result optional preallocated result to reuse.
714
779
  */
715
780
  multiplyMatrixTransform(other: Transform, result?: Transform): Transform;
716
- /** return a transposed matrix. `this` is not changed unless also passed as the result. */
781
+ /**
782
+ * 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
785
+ */
717
786
  transpose(result?: Matrix3d): Matrix3d;
718
- /** transpose this matrix in place.
719
- *
787
+ /**
788
+ * Transpose this matrix in place.
720
789
  */
721
790
  transposeInPlace(): void;
722
791
  /** return the inverse matrix.
@@ -725,10 +794,6 @@ export declare class Matrix3d implements BeJSONFunctions {
725
794
  * * Hence explicitly constructing this new inverse object is rarely necessary.
726
795
  */
727
796
  inverse(result?: Matrix3d): Matrix3d | undefined;
728
- /** copy the transpose of the coffs to the inverseCoffs.
729
- * * mark the matrix as inverseStored.
730
- */
731
- private setupInverseTranspose;
732
797
  private static indexedRowCrossProduct;
733
798
  private indexedColumnCrossProductInPlace;
734
799
  /** Form cross products among columns in axisOrder.
@@ -759,8 +824,10 @@ export declare class Matrix3d implements BeJSONFunctions {
759
824
  * Mark this matrix as singular.
760
825
  */
761
826
  markSingular(): void;
762
- /** Create the inverseCoffs member (filled with zeros)
763
- * This is for use by matrix * matrix multiplications which need to be sure the member is there to be filled with method-specific content.
827
+ /**
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.
764
831
  */
765
832
  private createInverseCoffsWithZeros;
766
833
  /** compute the inverse of this Matrix3d. The inverse is stored for later use.
@@ -798,7 +865,7 @@ export declare class Matrix3d implements BeJSONFunctions {
798
865
  /**
799
866
  * add scaled values from other Matrix3d to this Matrix3d
800
867
  * @param other Matrix3d with values to be added
801
- * @param scale scale factor to apply to th eadded values.
868
+ * @param scale scale factor to apply to the added values.
802
869
  */
803
870
  addScaledInPlace(other: Matrix3d, scale: number): void;
804
871
  /**
@@ -836,7 +903,7 @@ export declare class Matrix3d implements BeJSONFunctions {
836
903
  sumDiagonal(): number;
837
904
  /** Return the Maximum absolute value of any single entry */
838
905
  maxAbs(): number;
839
- /** Return the maximum absolute difference between corresponding entries */
906
+ /** Return the maximum absolute difference between corresponding entries of `this` and `other` */
840
907
  maxDiff(other: Matrix3d): number;
841
908
  /** Test if the matrix is (very near to) an identity */
842
909
  get isIdentity(): boolean;
@@ -868,11 +935,6 @@ export declare class Matrix3d implements BeJSONFunctions {
868
935
  get isSignedPermutation(): boolean;
869
936
  /** Test if all rows and columns are length 1 and are perpendicular to each other. (I.e. the matrix is either a pure rotation with uniform scale factor of 1 or -1) */
870
937
  testPerpendicularUnitRowsAndColumns(): boolean;
871
- /** create a new orthogonal matrix (perpendicular columns, unit length, transpose is inverse).
872
- * vectorA is placed in the first column of the axis order.
873
- * vectorB is projected perpendicular to vectorA within their plane and placed in the second column.
874
- */
875
- static createRigidFromColumns(vectorA: Vector3d, vectorB: Vector3d, axisOrder: AxisOrder, result?: Matrix3d): Matrix3d | undefined;
876
938
  /** Adjust the matrix in place so that:
877
939
  * * columns are perpendicular and have unit length
878
940
  * * transpose equals inverse
@@ -888,14 +950,14 @@ export declare class Matrix3d implements BeJSONFunctions {
888
950
  static createRigidFromMatrix3d(source: Matrix3d, axisOrder?: AxisOrder, result?: Matrix3d): Matrix3d | undefined;
889
951
  private static computeQuatTerm;
890
952
  /** create a matrix from a quaternion.
891
- * WARNING: There is frequent confusion over whether a "from quaternion" matrix is organized by rows and columns.
892
- * WARNING: If you find that the matrix seems to rotate by the opposite angle expect it, transpose it.
953
+ * **WARNING:** There is frequent confusion over whether a "from quaternion" matrix is organized by rows and columns.
954
+ * **WARNING:** If you find that the matrix seems to rotate by the opposite angle expect it, transpose it.
893
955
  */
894
956
  static createFromQuaternion(quat: Point4d): Matrix3d;
895
957
  /** convert the matrix to a quaternion.
896
958
  * @note This calculation requires the matrix to have unit length rows and columns.
897
- * WARNING: There is frequent confusion over whether a "from quaternion" matrix is organized by rows and columns.
898
- * WARNING: If you find that the matrix seems to rotate by the opposite angle expect it, transpose it.
959
+ * **WARNING:** There is frequent confusion over whether a "from quaternion" matrix is organized by rows and columns.
960
+ * **WARNING:** If you find that the matrix seems to rotate by the opposite angle expect it, transpose it.
899
961
  */
900
962
  toQuaternion(): Point4d;
901
963
  }