@itwin/core-geometry 3.5.0-dev.35 → 3.5.0-dev.41

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 (173) hide show
  1. package/lib/cjs/Geometry.d.ts +13 -0
  2. package/lib/cjs/Geometry.d.ts.map +1 -1
  3. package/lib/cjs/Geometry.js.map +1 -1
  4. package/lib/cjs/bspline/BSplineCurve.d.ts +1 -1
  5. package/lib/cjs/bspline/BSplineCurve.js +1 -1
  6. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  7. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  8. package/lib/cjs/bspline/KnotVector.js +3 -0
  9. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  10. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +7 -5
  11. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  12. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +37 -29
  13. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  14. package/lib/cjs/curve/CurveCollection.d.ts +4 -2
  15. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  16. package/lib/cjs/curve/CurveCollection.js +14 -2
  17. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  18. package/lib/cjs/curve/CurvePrimitive.d.ts +13 -17
  19. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  20. package/lib/cjs/curve/CurvePrimitive.js +51 -340
  21. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  22. package/lib/cjs/curve/LineString3d.d.ts +11 -1
  23. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  24. package/lib/cjs/curve/LineString3d.js +30 -23
  25. package/lib/cjs/curve/LineString3d.js.map +1 -1
  26. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +55 -0
  27. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -0
  28. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +143 -0
  29. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -0
  30. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +43 -0
  31. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -0
  32. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +146 -0
  33. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -0
  34. package/lib/cjs/curve/internalContexts/CurveLengthContext.d.ts +33 -0
  35. package/lib/cjs/curve/internalContexts/CurveLengthContext.d.ts.map +1 -0
  36. package/lib/cjs/curve/internalContexts/CurveLengthContext.js +91 -0
  37. package/lib/cjs/curve/internalContexts/CurveLengthContext.js.map +1 -0
  38. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +21 -0
  39. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -0
  40. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js +34 -0
  41. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -0
  42. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +2 -2
  43. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  44. package/lib/cjs/curve/spiral/DirectSpiral3d.js +15 -8
  45. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  46. package/lib/cjs/geometry3d/Angle.d.ts +20 -10
  47. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  48. package/lib/cjs/geometry3d/Angle.js +30 -15
  49. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  50. package/lib/cjs/geometry3d/Matrix3d.d.ts +25 -8
  51. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  52. package/lib/cjs/geometry3d/Matrix3d.js +67 -15
  53. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  54. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +23 -8
  55. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  56. package/lib/cjs/geometry3d/Point2dVector2d.js +40 -13
  57. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  58. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +90 -55
  59. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  60. package/lib/cjs/geometry3d/Point3dVector3d.js +254 -123
  61. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  62. package/lib/cjs/geometry3d/Range.d.ts +0 -1
  63. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/Range.js +0 -1
  65. package/lib/cjs/geometry3d/Range.js.map +1 -1
  66. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  67. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  68. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  69. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  70. package/lib/cjs/serialization/IModelJsonSchema.d.ts +1 -1
  71. package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
  72. package/lib/cjs/serialization/IModelJsonSchema.js +4 -3
  73. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  74. package/lib/cjs/solid/Sphere.d.ts +1 -1
  75. package/lib/cjs/solid/Sphere.js +3 -3
  76. package/lib/cjs/solid/Sphere.js.map +1 -1
  77. package/lib/cjs/solid/TorusPipe.d.ts +17 -13
  78. package/lib/cjs/solid/TorusPipe.d.ts.map +1 -1
  79. package/lib/cjs/solid/TorusPipe.js +67 -38
  80. package/lib/cjs/solid/TorusPipe.js.map +1 -1
  81. package/lib/cjs/topology/Graph.d.ts +1 -1
  82. package/lib/cjs/topology/Graph.js +1 -1
  83. package/lib/cjs/topology/Graph.js.map +1 -1
  84. package/lib/cjs/topology/Triangulation.d.ts +1 -1
  85. package/lib/cjs/topology/Triangulation.js +1 -1
  86. package/lib/cjs/topology/Triangulation.js.map +1 -1
  87. package/lib/esm/Geometry.d.ts +13 -0
  88. package/lib/esm/Geometry.d.ts.map +1 -1
  89. package/lib/esm/Geometry.js.map +1 -1
  90. package/lib/esm/bspline/BSplineCurve.d.ts +1 -1
  91. package/lib/esm/bspline/BSplineCurve.js +1 -1
  92. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  93. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  94. package/lib/esm/bspline/KnotVector.js +3 -0
  95. package/lib/esm/bspline/KnotVector.js.map +1 -1
  96. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +7 -5
  97. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  98. package/lib/esm/curve/CurveChainWithDistanceIndex.js +37 -29
  99. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  100. package/lib/esm/curve/CurveCollection.d.ts +4 -2
  101. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  102. package/lib/esm/curve/CurveCollection.js +14 -2
  103. package/lib/esm/curve/CurveCollection.js.map +1 -1
  104. package/lib/esm/curve/CurvePrimitive.d.ts +13 -17
  105. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  106. package/lib/esm/curve/CurvePrimitive.js +46 -335
  107. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  108. package/lib/esm/curve/LineString3d.d.ts +11 -1
  109. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  110. package/lib/esm/curve/LineString3d.js +30 -23
  111. package/lib/esm/curve/LineString3d.js.map +1 -1
  112. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +55 -0
  113. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -0
  114. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +139 -0
  115. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -0
  116. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +43 -0
  117. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -0
  118. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +142 -0
  119. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -0
  120. package/lib/esm/curve/internalContexts/CurveLengthContext.d.ts +33 -0
  121. package/lib/esm/curve/internalContexts/CurveLengthContext.d.ts.map +1 -0
  122. package/lib/esm/curve/internalContexts/CurveLengthContext.js +87 -0
  123. package/lib/esm/curve/internalContexts/CurveLengthContext.js.map +1 -0
  124. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +21 -0
  125. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -0
  126. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js +30 -0
  127. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -0
  128. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +2 -2
  129. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  130. package/lib/esm/curve/spiral/DirectSpiral3d.js +15 -8
  131. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  132. package/lib/esm/geometry3d/Angle.d.ts +20 -10
  133. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  134. package/lib/esm/geometry3d/Angle.js +30 -15
  135. package/lib/esm/geometry3d/Angle.js.map +1 -1
  136. package/lib/esm/geometry3d/Matrix3d.d.ts +25 -8
  137. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  138. package/lib/esm/geometry3d/Matrix3d.js +67 -15
  139. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  140. package/lib/esm/geometry3d/Point2dVector2d.d.ts +23 -8
  141. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  142. package/lib/esm/geometry3d/Point2dVector2d.js +40 -13
  143. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  144. package/lib/esm/geometry3d/Point3dVector3d.d.ts +90 -55
  145. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  146. package/lib/esm/geometry3d/Point3dVector3d.js +254 -123
  147. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  148. package/lib/esm/geometry3d/Range.d.ts +0 -1
  149. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  150. package/lib/esm/geometry3d/Range.js +0 -1
  151. package/lib/esm/geometry3d/Range.js.map +1 -1
  152. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  153. package/lib/esm/geometry3d/Transform.js.map +1 -1
  154. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  155. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  156. package/lib/esm/serialization/IModelJsonSchema.d.ts +1 -1
  157. package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
  158. package/lib/esm/serialization/IModelJsonSchema.js +4 -3
  159. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  160. package/lib/esm/solid/Sphere.d.ts +1 -1
  161. package/lib/esm/solid/Sphere.js +3 -3
  162. package/lib/esm/solid/Sphere.js.map +1 -1
  163. package/lib/esm/solid/TorusPipe.d.ts +17 -13
  164. package/lib/esm/solid/TorusPipe.d.ts.map +1 -1
  165. package/lib/esm/solid/TorusPipe.js +67 -38
  166. package/lib/esm/solid/TorusPipe.js.map +1 -1
  167. package/lib/esm/topology/Graph.d.ts +1 -1
  168. package/lib/esm/topology/Graph.js +1 -1
  169. package/lib/esm/topology/Graph.js.map +1 -1
  170. package/lib/esm/topology/Triangulation.d.ts +1 -1
  171. package/lib/esm/topology/Triangulation.js +1 -1
  172. package/lib/esm/topology/Triangulation.js.map +1 -1
  173. package/package.json +4 -4
@@ -20,24 +20,42 @@ const XYZProps_1 = require("./XYZProps");
20
20
  * @public
21
21
  */
22
22
  class XYZ {
23
- constructor(x = 0, y = 0, z = 0) { this.x = x; this.y = y; this.z = z; }
23
+ constructor(x = 0, y = 0, z = 0) {
24
+ this.x = x;
25
+ this.y = y;
26
+ this.z = z;
27
+ }
24
28
  /**
25
29
  * Set the x,y,z parts.
26
30
  * @param x (optional) x part
27
31
  * @param y (optional) y part
28
32
  * @param z (optional) z part
29
33
  */
30
- set(x = 0, y = 0, z = 0) { this.x = x; this.y = y; this.z = z; }
34
+ set(x = 0, y = 0, z = 0) {
35
+ this.x = x;
36
+ this.y = y;
37
+ this.z = z;
38
+ }
31
39
  /** Set the x,y,z parts to zero. */
32
- setZero() { this.x = 0; this.y = 0; this.z = 0; }
40
+ setZero() {
41
+ this.x = 0;
42
+ this.y = 0;
43
+ this.z = 0;
44
+ }
33
45
  /** Type guard for XAndY.
34
46
  * @note this will return true for an XYAndZ. If you wish to distinguish between the two, call isXYAndZ first.
35
47
  */
36
- static isXAndY(arg) { return arg.x !== undefined && arg.y !== undefined; }
48
+ static isXAndY(arg) {
49
+ return arg.x !== undefined && arg.y !== undefined;
50
+ }
37
51
  /** Type guard to determine whether an object has a member called "z" */
38
- static hasZ(arg) { return arg.z !== undefined; }
52
+ static hasZ(arg) {
53
+ return arg.z !== undefined;
54
+ }
39
55
  /** Type guard for XYAndZ. */
40
- static isXYAndZ(arg) { return this.isXAndY(arg) && this.hasZ(arg); }
56
+ static isXYAndZ(arg) {
57
+ return this.isXAndY(arg) && this.hasZ(arg);
58
+ }
41
59
  /** Test if arg is any of:
42
60
  * * XAndY
43
61
  * * XYAndZ
@@ -120,6 +138,7 @@ class XYZ {
120
138
  /**
121
139
  * Set the x,y,z parts from a Vector3d
122
140
  * This is the same effect as `setFrom(other)` with no pretesting of variant input type
141
+ * * Set to zeros if `other` is undefined.
123
142
  */
124
143
  setFromVector3d(other) {
125
144
  if (other) {
@@ -150,13 +169,21 @@ class XYZ {
150
169
  && Geometry_1.Geometry.isSameCoordinate(this.y, other.y, tol);
151
170
  }
152
171
  /** Return a JSON object as array `[x,y,z]` */
153
- toJSON() { return this.toArray(); }
172
+ toJSON() {
173
+ return this.toArray();
174
+ }
154
175
  /** Return as an array `[x,y,z]` */
155
- toArray() { return [this.x, this.y, this.z]; }
176
+ toArray() {
177
+ return [this.x, this.y, this.z];
178
+ }
156
179
  /** Return a JSON object as key value pairs `{x: value, y: value, z: value}` */
157
- toJSONXYZ() { return { x: this.x, y: this.y, z: this.z }; }
180
+ toJSONXYZ() {
181
+ return { x: this.x, y: this.y, z: this.z };
182
+ }
158
183
  /** Pack the x,y,z values in a Float64Array. */
159
- toFloat64Array() { return Float64Array.of(this.x, this.y, this.z); }
184
+ toFloat64Array() {
185
+ return Float64Array.of(this.x, this.y, this.z);
186
+ }
160
187
  /**
161
188
  * Set the x,y,z properties from one of several json forms:
162
189
  *
@@ -242,28 +269,54 @@ class XYZ {
242
269
  }
243
270
  /** Return true if the x,y,z components are all nearly zero to tolerance Geometry.smallMetricDistance */
244
271
  get isAlmostZero() {
245
- return Geometry_1.Geometry.isSmallMetricDistance(this.x) && Geometry_1.Geometry.isSmallMetricDistance(this.y) && Geometry_1.Geometry.isSmallMetricDistance(this.z);
272
+ return Geometry_1.Geometry.isSmallMetricDistance(this.x) &&
273
+ Geometry_1.Geometry.isSmallMetricDistance(this.y) &&
274
+ Geometry_1.Geometry.isSmallMetricDistance(this.z);
246
275
  }
247
276
  /** Return true if the x,y,z components are all exactly zero */
248
- get isZero() { return this.x === 0.0 && this.y === 0.0 && this.z === 0.0; }
277
+ get isZero() {
278
+ return this.x === 0.0 && this.y === 0.0 && this.z === 0.0;
279
+ }
249
280
  /** Return the largest absolute value of any component */
250
- maxAbs() { return Math.max(Math.abs(this.x), Math.abs(this.y), Math.abs(this.z)); }
281
+ maxAbs() {
282
+ return Math.max(Math.abs(this.x), Math.abs(this.y), Math.abs(this.z));
283
+ }
251
284
  /** Return the sqrt of the sum of squared x,y,z parts */
252
- magnitude() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); }
285
+ magnitude() {
286
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
287
+ }
253
288
  /** Return the sum of squared x,y,z parts */
254
- magnitudeSquared() { return this.x * this.x + this.y * this.y + this.z * this.z; }
289
+ magnitudeSquared() {
290
+ return this.x * this.x + this.y * this.y + this.z * this.z;
291
+ }
255
292
  /** Return sqrt of the sum of squared x,y parts */
256
- magnitudeXY() { return Math.sqrt(this.x * this.x + this.y * this.y); }
293
+ magnitudeXY() {
294
+ return Math.sqrt(this.x * this.x + this.y * this.y);
295
+ }
257
296
  /** Return the sum of squared x,y parts */
258
- magnitudeSquaredXY() { return this.x * this.x + this.y * this.y; }
297
+ magnitudeSquaredXY() {
298
+ return this.x * this.x + this.y * this.y;
299
+ }
259
300
  /** exact equality test. */
260
- isExactEqual(other) { return this.x === other.x && this.y === other.y && this.z === other.z; }
301
+ isExactEqual(other) {
302
+ return this.x === other.x && this.y === other.y && this.z === other.z;
303
+ }
261
304
  /** equality test with Geometry.smallMetricDistance tolerance */
262
- isAlmostEqualMetric(other) { return this.maxDiff(other) <= Geometry_1.Geometry.smallMetricDistance; }
305
+ isAlmostEqualMetric(other) {
306
+ return this.maxDiff(other) <= Geometry_1.Geometry.smallMetricDistance;
307
+ }
263
308
  /** add x,y,z from other in place. */
264
- addInPlace(other) { this.x += other.x; this.y += other.y; this.z += other.z; }
309
+ addInPlace(other) {
310
+ this.x += other.x;
311
+ this.y += other.y;
312
+ this.z += other.z;
313
+ }
265
314
  /** add x,y,z from other in place. */
266
- subtractInPlace(other) { this.x -= other.x; this.y -= other.y; this.z -= other.z; }
315
+ subtractInPlace(other) {
316
+ this.x -= other.x;
317
+ this.y -= other.y;
318
+ this.z -= other.z;
319
+ }
267
320
  /** add (in place) the scaled x,y,z of other */
268
321
  addScaledInPlace(other, scale) {
269
322
  this.x += scale * other.x;
@@ -271,11 +324,21 @@ class XYZ {
271
324
  this.z += scale * other.z;
272
325
  }
273
326
  /** Multiply the x, y, z parts by scale. */
274
- scaleInPlace(scale) { this.x *= scale; this.y *= scale; this.z *= scale; }
327
+ scaleInPlace(scale) {
328
+ this.x *= scale;
329
+ this.y *= scale;
330
+ this.z *= scale;
331
+ }
275
332
  /** add to x, y, z parts */
276
- addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) { this.x += dx; this.y += dy; this.z += dz; }
333
+ addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) {
334
+ this.x += dx;
335
+ this.y += dy;
336
+ this.z += dz;
337
+ }
277
338
  /** Clone strongly typed as Point3d */
278
- cloneAsPoint3d() { return Point3d.create(this.x, this.y, this.z); }
339
+ cloneAsPoint3d() {
340
+ return Point3d.create(this.x, this.y, this.z);
341
+ }
279
342
  /** Return a (full length) vector from this point to other */
280
343
  vectorTo(other, result) {
281
344
  return Vector3d.create(other.x - this.x, other.y - this.y, other.z - this.z, result);
@@ -288,9 +351,13 @@ class XYZ {
288
351
  * @param other target of created vector.
289
352
  * @param result optional result vector.
290
353
  */
291
- unitVectorTo(target, result) { return this.vectorTo(target, result).normalize(result); }
354
+ unitVectorTo(target, result) {
355
+ return this.vectorTo(target, result).normalize(result);
356
+ }
292
357
  /** Freeze this XYZ */
293
- freeze() { return Object.freeze(this); }
358
+ freeze() {
359
+ return Object.freeze(this);
360
+ }
294
361
  /** access x part of XYZProps (which may be .x or [0]) */
295
362
  static x(xyz, defaultValue = 0) {
296
363
  if (xyz === undefined)
@@ -328,7 +395,9 @@ exports.XYZ = XYZ;
328
395
  */
329
396
  class Point3d extends XYZ {
330
397
  /** Constructor for Point3d */
331
- constructor(x = 0, y = 0, z = 0) { super(x, y, z); }
398
+ constructor(x = 0, y = 0, z = 0) {
399
+ super(x, y, z);
400
+ }
332
401
  /**
333
402
  * Convert json to Point3d. Accepted forms are:
334
403
  * * `[1,2,3]` --- array of numbers
@@ -336,9 +405,15 @@ class Point3d extends XYZ {
336
405
  * * object with x,y, and (optional) z as numeric properties {x: xValue, y: yValue, z: zValue}
337
406
  * @param json json value.
338
407
  */
339
- static fromJSON(json) { const val = new Point3d(); val.setFromJSON(json); return val; }
408
+ static fromJSON(json) {
409
+ const val = new Point3d();
410
+ val.setFromJSON(json);
411
+ return val;
412
+ }
340
413
  /** Return a new Point3d with the same coordinates */
341
- clone(result) { return Point3d.create(this.x, this.y, this.z, result); }
414
+ clone(result) {
415
+ return Point3d.create(this.x, this.y, this.z, result);
416
+ }
342
417
  /** Create a new Point3d with given coordinates
343
418
  * @param x x part
344
419
  * @param y y part
@@ -384,7 +459,7 @@ class Point3d extends XYZ {
384
459
  /**
385
460
  * Copy and unweight xyzw.
386
461
  * @param xyzData flat array of x,y,z,w,x,y,z,w for multiple points
387
- * @param pointIndex index of point to extract. This index is multiplied by 4 to obtain starting index in the array.
462
+ * @param pointIndex index of point to extract. This index is multiplied by 4 to obtain starting index in the array.
388
463
  * @param result optional result point.
389
464
  */
390
465
  static createFromPackedXYZW(xyzData, pointIndex, result) {
@@ -409,7 +484,9 @@ class Point3d extends XYZ {
409
484
  return result;
410
485
  }
411
486
  /** Create a new point with 000 xyz */
412
- static createZero(result) { return Point3d.create(0, 0, 0, result); }
487
+ static createZero(result) {
488
+ return Point3d.create(0, 0, 0, result);
489
+ }
413
490
  /** Return the cross product of the vectors from this to pointA and pointB
414
491
  *
415
492
  * * the result is a vector
@@ -427,7 +504,7 @@ class Point3d extends XYZ {
427
504
  /** Return the triple product of the vectors from this to pointA, pointB, pointC
428
505
  *
429
506
  * * This is a scalar (number)
430
- * * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
507
+ * * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
431
508
  */
432
509
  tripleProductToPoints(pointA, pointB, pointC) {
433
510
  return Geometry_1.Geometry.tripleProduct(pointA.x - this.x, pointA.y - this.y, pointA.z - this.z, pointB.x - this.x, pointB.y - this.y, pointB.z - this.z, pointC.x - this.x, pointC.y - this.y, pointC.z - this.z);
@@ -524,9 +601,7 @@ class Point3d extends XYZ {
524
601
  (targetA.y - this.y) * (targetB.y - this.y) +
525
602
  (targetA.z - this.z) * (targetB.z - this.z);
526
603
  }
527
- /** Return the fractional projection of this onto a line between points.
528
- *
529
- */
604
+ /** Return the fractional projection of this onto a line between points. */
530
605
  fractionOfProjectionToLine(startPoint, endPoint, defaultFraction = 0) {
531
606
  const denominator = startPoint.distanceSquared(endPoint);
532
607
  if (denominator < Geometry_1.Geometry.smallMetricDistanceSquared)
@@ -539,7 +614,9 @@ exports.Point3d = Point3d;
539
614
  * @public
540
615
  */
541
616
  class Vector3d extends XYZ {
542
- constructor(x = 0, y = 0, z = 0) { super(x, y, z); }
617
+ constructor(x = 0, y = 0, z = 0) {
618
+ super(x, y, z);
619
+ }
543
620
  /**
544
621
  * Return an array of vectors constructed from groups of 3 entries in a Float64Array.
545
622
  * Any incomplete group at the tail of the array is ignored.
@@ -554,7 +631,9 @@ class Vector3d extends XYZ {
554
631
  * Copy xyz from this instance to a new (or optionally reused) Vector3d
555
632
  * @param result optional instance to reuse.
556
633
  */
557
- clone(result) { return Vector3d.create(this.x, this.y, this.z, result); }
634
+ clone(result) {
635
+ return Vector3d.create(this.x, this.y, this.z, result);
636
+ }
558
637
  /**
559
638
  * return a Vector3d (new or reused from optional result)
560
639
  * @param x x component
@@ -643,7 +722,11 @@ class Vector3d extends XYZ {
643
722
  * * object with x,y, and (optional) z as numeric properties {x: xValue, y: yValue, z: zValue}
644
723
  * @param json json value.
645
724
  */
646
- static fromJSON(json) { const val = new Vector3d(); val.setFromJSON(json); return val; }
725
+ static fromJSON(json) {
726
+ const val = new Vector3d();
727
+ val.setFromJSON(json);
728
+ return val;
729
+ }
647
730
  /** Copy contents from another Point3d, Point2d, Vector2d, or Vector3d */
648
731
  static createFrom(data, result) {
649
732
  if (data instanceof Float64Array) {
@@ -719,7 +802,7 @@ class Vector3d extends XYZ {
719
802
  return undefined;
720
803
  }
721
804
  /**
722
- * Set (replace) xzz components so they are a vector from point0 to point1
805
+ * Set (replace) xyz components so they are a vector from point0 to point1
723
806
  * @param point0 start point of computed vector
724
807
  * @param point1 end point of computed vector.
725
808
  */
@@ -729,13 +812,21 @@ class Vector3d extends XYZ {
729
812
  this.z = point1.z - point0.z;
730
813
  }
731
814
  /** Return a vector with 000 xyz parts. */
732
- static createZero(result) { return Vector3d.create(0, 0, 0, result); }
815
+ static createZero(result) {
816
+ return Vector3d.create(0, 0, 0, result);
817
+ }
733
818
  /** Return a unit X vector optionally multiplied by a scale */
734
- static unitX(scale = 1) { return new Vector3d(scale, 0, 0); }
735
- /** Return a unit Y vector */
736
- static unitY(scale = 1) { return new Vector3d(0, scale, 0); }
737
- /** Return a unit Z vector */
738
- static unitZ(scale = 1) { return new Vector3d(0, 0, scale); }
819
+ static unitX(scale = 1) {
820
+ return new Vector3d(scale, 0, 0);
821
+ }
822
+ /** Return a unit Y vector optionally multiplied by a scale */
823
+ static unitY(scale = 1) {
824
+ return new Vector3d(0, scale, 0);
825
+ }
826
+ /** Return a unit Z vector optionally multiplied by a scale */
827
+ static unitZ(scale = 1) {
828
+ return new Vector3d(0, 0, scale);
829
+ }
739
830
  /** Divide by denominator, but return undefined if denominator is zero. */
740
831
  safeDivideOrNull(denominator, result) {
741
832
  if (denominator !== 0.0) {
@@ -744,8 +835,8 @@ class Vector3d extends XYZ {
744
835
  return undefined;
745
836
  }
746
837
  /**
747
- * Return a pair object containing (a) property `v` which is a unit vector in the direction
748
- * of the input and (b) property mag which is the magnitude (length) of the input (instance) prior to normalization.
838
+ * Return a pair object containing (a) property `v` which is a unit vector in the direction of the input
839
+ * and (b) property mag which is the magnitude (length) of the input (instance) prior to normalization.
749
840
  * If the instance (input) is a near zero length the `v` property of the output is undefined.
750
841
  * @param result optional result.
751
842
  */
@@ -758,7 +849,9 @@ class Vector3d extends XYZ {
758
849
  * Return a unit vector parallel with this. Return undefined if this.magnitude is near zero.
759
850
  * @param result optional result.
760
851
  */
761
- normalize(result) { return this.normalizeWithLength(result).v; }
852
+ normalize(result) {
853
+ return this.normalizeWithLength(result).v;
854
+ }
762
855
  /**
763
856
  * If this vector has nonzero length, divide by the length to change to a unit vector.
764
857
  * @returns true if normalization completed.
@@ -793,7 +886,7 @@ class Vector3d extends XYZ {
793
886
  /** Return a vector same length as this but rotate 90 degrees CCW */
794
887
  rotate90CCWXY(result) {
795
888
  result = result ? result : new Vector3d();
796
- // save x,y to allow aliasing ..
889
+ // save x,y to allow aliasing ("this" can be passed to the function as "result")
797
890
  const xx = this.x;
798
891
  const yy = this.y;
799
892
  result.x = -yy;
@@ -839,17 +932,23 @@ class Vector3d extends XYZ {
839
932
  return result;
840
933
  }
841
934
  /**
842
- * Return a (new or optionally preallocated) vector that is rotated 90 degrees in the plane of this vector and the target vector.
935
+ * Return a (new or optionally preallocated) vector that is rotated 90 degrees in
936
+ * the plane of this vector and the target vector.
843
937
  * @param target Second vector which defines the plane of rotation.
844
938
  * @param result optional preallocated vector for result.
845
- * @returns rotated vector, or undefined if the cross product of this and the the target cannot be normalized (i.e. if the target and this are colinear)
939
+ * @returns rotated vector, or undefined if the cross product of this and
940
+ * the the target cannot be normalized (i.e. if the target and this are colinear)
846
941
  */
847
942
  rotate90Towards(target, result) {
848
943
  const normal = this.crossProduct(target).normalize();
849
944
  return normal ? normal.crossProduct(this, result) : undefined;
850
945
  }
851
946
  /** Rotate this vector 90 degrees around an axis vector.
852
- * @returns the (new or optionally reused result) rotated vector, or undefined if the axis vector cannot be normalized.
947
+ * * Note that simple cross is in the plane perpendicular to axis -- it loses the part
948
+ * of "this" that is along the axis. The unit and scale is supposed to fix that.
949
+ * This matches with Rodrigues' rotation formula because cos(theta) = 0 and sin(theta) = 1
950
+ * @returns the (new or optionally reused result) rotated vector, or undefined if the axis
951
+ * vector cannot be normalized.
853
952
  */
854
953
  rotate90Around(axis, result) {
855
954
  const unitNormal = axis.normalize();
@@ -857,7 +956,8 @@ class Vector3d extends XYZ {
857
956
  }
858
957
  /**
859
958
  * Return a vector computed at fractional position between this vector and vectorB
860
- * @param fraction fractional position. 0 is at `this`. 1 is at `vectorB`. True fractions are "between", negatives are "before this", beyond 1 is "beyond vectorB".
959
+ * @param fraction fractional position. 0 is at `this`. 1 is at `vectorB`.
960
+ * True fractions are "between", negatives are "before this", beyond 1 is "beyond vectorB".
861
961
  * @param vectorB second vector
862
962
  * @param result optional preallocated result.
863
963
  */
@@ -928,7 +1028,8 @@ class Vector3d extends XYZ {
928
1028
  static createAdd2Scaled(vectorA, scaleA, vectorB, scaleB, result) {
929
1029
  return Vector3d.create(vectorA.x * scaleA + vectorB.x * scaleB, vectorA.y * scaleA + vectorB.y * scaleB, vectorA.z * scaleA + vectorB.z * scaleB, result);
930
1030
  }
931
- /** Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB` with all components presented as numbers */
1031
+ /** Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB`
1032
+ * with all components presented as numbers */
932
1033
  static createAdd2ScaledXYZ(ax, ay, az, scaleA, bx, by, bz, scaleB, result) {
933
1034
  return Vector3d.create(ax * scaleA + bx * scaleB, ay * scaleA + by * scaleB, az * scaleA + bz * scaleB, result);
934
1035
  }
@@ -963,7 +1064,8 @@ class Vector3d extends XYZ {
963
1064
  return this.crossProduct(vectorB, result).normalize(result);
964
1065
  }
965
1066
  /**
966
- * Compute the cross product of this vector with `vectorB`. Normalize it, using given xyz as default if length is zero.
1067
+ * Compute the cross product of this vector with `vectorB`. Normalize it, using given xyz as
1068
+ * default if length is zero.
967
1069
  * @param vectorB second vector of cross product
968
1070
  * @param x x value for default result
969
1071
  * @param y y value for default result
@@ -1096,17 +1198,18 @@ class Vector3d extends XYZ {
1096
1198
  return this.x * (pointB.x - pointA.x)
1097
1199
  + this.y * (pointB.y - pointA.y);
1098
1200
  }
1099
- /** Dot product with vector from pointA to pointB, with pointB given as (weighted) x,y,z,w
1100
- * * pointB is a homogeneous point that has to be unweighted
1201
+ /** Dot product with vector from pointA to pointB, with pointB given as (weighted) wx,wy,wz,w
1202
+ * * We need to unweight pointB (which is a homogeneous point) to be able to participate in the
1203
+ * vector dot product
1101
1204
  * * if the weight is near zero metric, the return is zero.
1102
1205
  */
1103
- dotProductStartEndXYZW(pointA, x, y, z, w) {
1206
+ dotProductStartEndXYZW(pointA, wx, wy, wz, w) {
1104
1207
  if (Geometry_1.Geometry.isSmallMetricDistance(w))
1105
1208
  return 0.0;
1106
1209
  const dw = 1.0 / w;
1107
- return this.x * (dw * x - pointA.x)
1108
- + this.y * (dw * y - pointA.y)
1109
- + this.z * (dw * z - pointA.z);
1210
+ return this.x * (dw * wx - pointA.x)
1211
+ + this.y * (dw * wy - pointA.y)
1212
+ + this.z * (dw * wz - pointA.z);
1110
1213
  }
1111
1214
  /** Return the dot product of the instance and vectorB, using only the x and y parts. */
1112
1215
  dotProductXY(vectorB) {
@@ -1148,46 +1251,93 @@ class Vector3d extends XYZ {
1148
1251
  return Vector3d.createCrossProduct(this.x, this.y, this.z, x, y, z, result);
1149
1252
  }
1150
1253
  /**
1151
- * Return the (Strongly typed) angle from this vector to vectorB.
1254
+ * Return the (radians as a simple number, not strongly typed Angle) angle from this vector to vectorB.
1255
+ * * The returned angle is always positive and no larger than 180 degrees (PI radians)
1256
+ * * The returned angle is "in the plane containing the two vectors"
1257
+ * * Use `planarRadiansTo` and `signedRadiansTo` to take have angle measured in specific plane.
1258
+ * @param vectorB target vector of rotation.
1259
+ */
1260
+ radiansTo(vectorB) {
1261
+ // ||axb|| = ||a|| ||b|| |sin(t)| and a.b = ||a|| ||b|| cos(t) ==>
1262
+ // ||axb|| / a.b = sin(t)/cos(t) = tan(t) ==> t = arctan(||axb|| / a.b).
1263
+ return Math.atan2(this.crossProductMagnitude(vectorB), this.dotProduct(vectorB));
1264
+ }
1265
+ /**
1266
+ * Return the (strongly typed) angle from this vector to vectorB.
1152
1267
  * * The returned angle is always positive and no larger than 180 degrees (PI radians)
1153
1268
  * * The returned angle is "in the plane containing the two vectors"
1154
- * * Use `planarAngleTo`, `signedAngleTo`, `angleToXY` to take have angle measured in specific plane.
1269
+ * * Use `planarAngleTo` and `signedAngleTo` to take have angle measured in specific plane.
1155
1270
  * @param vectorB target vector of rotation.
1156
1271
  */
1157
1272
  angleTo(vectorB) {
1158
- return Angle_1.Angle.createAtan2(this.crossProductMagnitude(vectorB), this.dotProduct(vectorB));
1273
+ return Angle_1.Angle.createRadians(this.radiansTo(vectorB));
1159
1274
  }
1160
1275
  /**
1161
- * Return the (Strongly typed) angle from this vector to the plane perpendicular to planeNormal.
1276
+ * Return the (strongly typed) angle from this vector to the plane perpendicular to planeNormal.
1162
1277
  * * The returned vector is signed
1163
- * * The returned vector is (as degrees) always less than or equal to 90 degrees.
1164
- * @param planeNormal a normal vector to the plane
1278
+ * * The returned vector is (as degrees) always between -90 and 90 degrees.
1279
+ * * The function returns "PI/2 - angleTo(planeNormal)"
1280
+ * @param planeNormal a normal vector to the plane.
1165
1281
  */
1166
- angleFromPerpendicular(vectorB) {
1167
- return Angle_1.Angle.createAtan2(this.dotProduct(vectorB), this.crossProductMagnitude(vectorB));
1282
+ angleFromPerpendicular(planeNormal) {
1283
+ return Angle_1.Angle.createAtan2(this.dotProduct(planeNormal), this.crossProductMagnitude(planeNormal));
1168
1284
  }
1169
1285
  /**
1170
- * Return the (Strongly typed) angle from this vector to vectorB,using only the xy parts.
1171
- * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees (positive PI radians), not closed on the negative side.
1172
- * * Use `planarAngleTo`, `signedAngleTo`, `angleToXY` to take have angle measured in other planes.
1286
+ * Return the (Strongly typed) angle from this vector to vectorB, using only the xy parts.
1287
+ * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180
1288
+ * * degrees (positive PI radians), not closed on the negative side.
1289
+ * * Use `planarAngleTo` and `signedAngleTo` to take have angle measured in other planes.
1173
1290
  * @param vectorB target vector of rotation.
1174
1291
  */
1175
1292
  angleToXY(vectorB) {
1176
1293
  return Angle_1.Angle.createAtan2(this.crossProductXY(vectorB), this.dotProductXY(vectorB));
1177
1294
  }
1295
+ /**
1296
+ * Return the (simple number of radians, not Strongly typed Angle) angle from this vector to vectorB, measured
1297
+ * in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1298
+ * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1299
+ * * The returned angle is "in the plane containing the two vectors"
1300
+ * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1301
+ * * vectorW does not have to be perpendicular to the plane.
1302
+ * @param vectorB target vector of rotation.
1303
+ * @param vectorW distinguishes between the sides of the plane.
1304
+ */
1305
+ signedRadiansTo(vectorB, vectorW) {
1306
+ const p = this.crossProduct(vectorB);
1307
+ const theta = Math.atan2(p.magnitude(), this.dotProduct(vectorB));
1308
+ if (vectorW.dotProduct(p) < 0.0)
1309
+ return -theta;
1310
+ else
1311
+ return theta;
1312
+ }
1313
+ /**
1314
+ * Return the (strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both,
1315
+ * with vectorW indicating which side to view to control sign of the angle.
1316
+ * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees
1317
+ * * (positive PI radians), not closed on the negative side.
1318
+ * * The returned angle is "in the plane containing the two vectors"
1319
+ * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1320
+ * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1321
+ * @param vectorB target vector of rotation.
1322
+ * @param vectorW distinguishes between the sides of the plane.
1323
+ */
1324
+ signedAngleTo(vectorB, vectorW) {
1325
+ return Angle_1.Angle.createRadians(this.signedRadiansTo(vectorB, vectorW));
1326
+ }
1178
1327
  /**
1179
1328
  * Return the (radians as a simple number, not strongly typed Angle) radians from this vector to vectorB.
1180
1329
  * * The returned angle can be positive or negative, with magnitude no larger than PI radians
1181
1330
  * * Use signedRadiansTo` to take have angle measured in other planes.
1182
1331
  * @param vectorB target vector of rotation.
1332
+ * @param planeNormal a normal vector to the plane.
1183
1333
  */
1184
- planarRadiansTo(vector, planeNormal) {
1334
+ planarRadiansTo(vectorB, planeNormal) {
1185
1335
  const square = planeNormal.dotProduct(planeNormal);
1186
1336
  if (square === 0.0)
1187
1337
  return 0.0;
1188
1338
  const factor = 1.0 / square;
1189
1339
  const projection0 = this.plusScaled(planeNormal, -this.dotProduct(planeNormal) * factor);
1190
- const projection1 = vector.plusScaled(planeNormal, -vector.dotProduct(planeNormal) * factor);
1340
+ const projection1 = vectorB.plusScaled(planeNormal, -vectorB.dotProduct(planeNormal) * factor);
1191
1341
  return projection0.signedRadiansTo(projection1, planeNormal);
1192
1342
  }
1193
1343
  /**
@@ -1195,86 +1345,67 @@ class Vector3d extends XYZ {
1195
1345
  * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1196
1346
  * * Use signedRadiansTo` to take have angle measured in other planes.
1197
1347
  * @param vectorB target vector of rotation.
1348
+ * @param planeNormal a normal vector to the plane.
1198
1349
  */
1199
- planarAngleTo(vector, planeNormal) {
1200
- return Angle_1.Angle.createRadians(this.planarRadiansTo(vector, planeNormal));
1201
- }
1202
- /**
1203
- * Return the (simple number of radians, not Strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1204
- * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1205
- * * The returned angle is "in the plane containing the two vectors"
1206
- * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1207
- * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1208
- * @param vectorB target vector of rotation.
1209
- */
1210
- signedRadiansTo(vector1, vectorW) {
1211
- const p = this.crossProduct(vector1);
1212
- const theta = Math.atan2(p.magnitude(), this.dotProduct(vector1));
1213
- if (vectorW.dotProduct(p) < 0.0)
1214
- return -theta;
1215
- else
1216
- return theta;
1217
- }
1218
- /**
1219
- * Return the (strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1220
- * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees (positive PI radians), not closed on the negative side.
1221
- * * The returned angle is "in the plane containing the two vectors"
1222
- * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1223
- * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1224
- * @param vectorB target vector of rotation.
1225
- */
1226
- signedAngleTo(vector1, vectorW) { return Angle_1.Angle.createRadians(this.signedRadiansTo(vector1, vectorW)); }
1227
- /** Return the smallest (strongly typed) angle from the (bidirectional) line containing `this` to the (bidirectional) line containing `vectorB` */
1228
- smallerUnorientedAngleTo(vectorB) {
1229
- return Angle_1.Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
1350
+ planarAngleTo(vectorB, planeNormal) {
1351
+ return Angle_1.Angle.createRadians(this.planarRadiansTo(vectorB, planeNormal));
1230
1352
  }
1231
- /** Return the smallest angle (in radians) from the (bidirectional) line containing `this` to the (bidirectional) line containing `vectorB` */
1353
+ /** Return the smallest angle (in radians) from the (bidirectional) line containing `this`
1354
+ * to the (bidirectional) line containing `vectorB` */
1232
1355
  smallerUnorientedRadiansTo(vectorB) {
1233
1356
  const c = this.dotProduct(vectorB);
1234
1357
  const s = this.crossProductMagnitude(vectorB);
1235
1358
  return Math.atan2(Math.abs(s), Math.abs(c));
1236
1359
  }
1237
- /*
1238
- signedAngleTo(vectorB: Vector3d, upVector: Vector3d): Angle { }
1239
- // sectors
1240
- isInSmallerSector(vectorA: Vector3d, vectorB: Vector3d): boolean { }
1241
- isInCCWSector(vectorA: Vector3d, vectorB: Vector3d, upVector: Vector3d): boolean { }
1242
- */
1360
+ /** Return the smallest (strongly typed) angle from the (bidirectional) line containing `this`
1361
+ * to the (bidirectional) line containing `vectorB` */
1362
+ smallerUnorientedAngleTo(vectorB) {
1363
+ return Angle_1.Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
1364
+ }
1243
1365
  /**
1244
1366
  * Test if this vector is parallel to other.
1367
+ * * The input tolerances in `options`, if given, are considered to be squared for efficiency's sake,
1368
+ * so if you have a distance or angle tolerance t, you should pass in t * t.
1245
1369
  * @param other second vector in comparison
1246
- * @param oppositeIsParallel if the vectors are on the same line but in opposite directions, return this value.
1370
+ * @param oppositeIsParallel whether to consider diametrically opposed vectors as parallel
1247
1371
  * @param returnValueIfAnInputIsZeroLength if either vector is near zero length, return this value.
1372
+ * @param options optional radian and distance tolerances.
1248
1373
  */
1249
- isParallelTo(other, oppositeIsParallel = false, returnValueIfAnInputIsZeroLength = false) {
1374
+ isParallelTo(other, oppositeIsParallel = false, returnValueIfAnInputIsZeroLength = false, options) {
1375
+ var _a, _b;
1376
+ const radianSquaredTol = (_a = options === null || options === void 0 ? void 0 : options.radianSquaredTol) !== null && _a !== void 0 ? _a : Geometry_1.Geometry.smallAngleRadiansSquared;
1377
+ const distanceSquaredTol = (_b = options === null || options === void 0 ? void 0 : options.distanceSquaredTol) !== null && _b !== void 0 ? _b : Geometry_1.Geometry.smallMetricDistanceSquared;
1250
1378
  const a2 = this.magnitudeSquared();
1251
1379
  const b2 = other.magnitudeSquared();
1252
- // we know both are 0 or positive -- no need for
1253
- if (a2 < Geometry_1.Geometry.smallMetricDistanceSquared || b2 < Geometry_1.Geometry.smallMetricDistanceSquared)
1380
+ if (a2 < distanceSquaredTol || b2 < distanceSquaredTol)
1254
1381
  return returnValueIfAnInputIsZeroLength;
1255
1382
  const dot = this.dotProduct(other);
1256
1383
  if (dot < 0.0 && !oppositeIsParallel)
1257
- return returnValueIfAnInputIsZeroLength;
1384
+ return false;
1258
1385
  const cross2 = this.crossProductMagnitudeSquared(other);
1259
1386
  /* a2,b2,cross2 are squared lengths of respective vectors */
1260
1387
  /* cross2 = sin^2(theta) * a2 * b2 */
1261
1388
  /* For small theta, sin^2(theta)~~theta^2 */
1262
- return cross2 <= Geometry_1.Geometry.smallAngleRadiansSquared * a2 * b2;
1389
+ return cross2 <= radianSquaredTol * a2 * b2;
1263
1390
  }
1264
1391
  /**
1265
1392
  * Test if this vector is perpendicular to other.
1393
+ * * The input tolerances in `options`, if given, are considered to be squared for efficiency's sake,
1394
+ * so if you have a distance or angle tolerance t, you should pass in t * t.
1266
1395
  * @param other second vector in comparison
1267
1396
  * @param returnValueIfAnInputIsZeroLength if either vector is near zero length, return this value.
1397
+ * @param options optional radian and distance tolerances.
1268
1398
  */
1269
- isPerpendicularTo(other, returnValueIfAnInputIsZeroLength = false) {
1399
+ isPerpendicularTo(other, returnValueIfAnInputIsZeroLength = false, options) {
1400
+ var _a, _b;
1401
+ const radianSquaredTol = (_a = options === null || options === void 0 ? void 0 : options.radianSquaredTol) !== null && _a !== void 0 ? _a : Geometry_1.Geometry.smallAngleRadiansSquared;
1402
+ const distanceSquaredTol = (_b = options === null || options === void 0 ? void 0 : options.distanceSquaredTol) !== null && _b !== void 0 ? _b : Geometry_1.Geometry.smallMetricDistanceSquared;
1270
1403
  const aa = this.magnitudeSquared();
1271
- if (aa < Geometry_1.Geometry.smallMetricDistanceSquared)
1272
- return returnValueIfAnInputIsZeroLength;
1273
1404
  const bb = other.magnitudeSquared();
1274
- if (bb < Geometry_1.Geometry.smallMetricDistanceSquared)
1405
+ if (aa < distanceSquaredTol || bb < distanceSquaredTol)
1275
1406
  return returnValueIfAnInputIsZeroLength;
1276
1407
  const ab = this.dotProduct(other);
1277
- return ab * ab <= Geometry_1.Geometry.smallAngleRadiansSquared * aa * bb;
1408
+ return ab * ab <= radianSquaredTol * aa * bb;
1278
1409
  }
1279
1410
  }
1280
1411
  exports.Vector3d = Vector3d;