@itwin/core-geometry 4.10.0-dev.3 → 4.10.0-dev.31

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 (208) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +2 -2
  3. package/lib/cjs/Geometry.js +2 -2
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/clipping/ClipPrimitive.d.ts +7 -7
  6. package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
  7. package/lib/cjs/clipping/ClipPrimitive.js +1 -1
  8. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  9. package/lib/cjs/core-geometry.d.ts +1 -1
  10. package/lib/cjs/core-geometry.d.ts.map +1 -1
  11. package/lib/cjs/core-geometry.js +1 -1
  12. package/lib/cjs/core-geometry.js.map +1 -1
  13. package/lib/cjs/curve/Arc3d.d.ts +21 -10
  14. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  15. package/lib/cjs/curve/Arc3d.js +66 -38
  16. package/lib/cjs/curve/Arc3d.js.map +1 -1
  17. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  18. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  19. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +44 -25
  20. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  21. package/lib/cjs/curve/CurveFactory.d.ts +11 -13
  22. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  23. package/lib/cjs/curve/CurveFactory.js +19 -46
  24. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  25. package/lib/cjs/curve/LineSegment3d.js +2 -2
  26. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  27. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  28. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +5 -4
  29. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  30. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  31. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  32. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +40 -65
  33. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  34. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  35. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  36. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +131 -70
  37. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  38. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  39. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  40. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  41. package/lib/cjs/geometry3d/Angle.d.ts +5 -5
  42. package/lib/cjs/geometry3d/Angle.js +5 -5
  43. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  44. package/lib/cjs/geometry3d/AngleSweep.d.ts +101 -13
  45. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  46. package/lib/cjs/geometry3d/AngleSweep.js +156 -57
  47. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  48. package/lib/cjs/geometry3d/BilinearPatch.js +4 -4
  49. package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
  50. package/lib/cjs/geometry3d/Matrix3d.d.ts +35 -31
  51. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  52. package/lib/cjs/geometry3d/Matrix3d.js +55 -31
  53. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  54. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +6 -5
  55. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  56. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
  57. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  58. package/lib/cjs/geometry3d/PolygonOps.js +2 -2
  59. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  60. package/lib/cjs/geometry3d/Ray3d.js +2 -2
  61. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  62. package/lib/cjs/geometry3d/Transform.d.ts +4 -2
  63. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/Transform.js +4 -2
  65. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  66. package/lib/cjs/geometry4d/Map4d.d.ts +5 -5
  67. package/lib/cjs/geometry4d/Map4d.js +5 -5
  68. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  69. package/lib/cjs/geometry4d/Matrix4d.d.ts +4 -7
  70. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  71. package/lib/cjs/geometry4d/Matrix4d.js +4 -7
  72. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  73. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  74. package/lib/cjs/geometry4d/Point4d.js +2 -1
  75. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  76. package/lib/cjs/numerics/Newton.d.ts +3 -0
  77. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  78. package/lib/cjs/numerics/Newton.js +2 -5
  79. package/lib/cjs/numerics/Newton.js.map +1 -1
  80. package/lib/cjs/numerics/Polynomials.d.ts +46 -201
  81. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  82. package/lib/cjs/numerics/Polynomials.js +132 -445
  83. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  84. package/lib/cjs/numerics/SmallSystem.d.ts +164 -0
  85. package/lib/cjs/numerics/SmallSystem.d.ts.map +1 -0
  86. package/lib/cjs/numerics/SmallSystem.js +321 -0
  87. package/lib/cjs/numerics/SmallSystem.js.map +1 -0
  88. package/lib/cjs/polyface/PolyfaceClip.d.ts +3 -3
  89. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  90. package/lib/cjs/polyface/PolyfaceClip.js +1 -1
  91. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  92. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  93. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  94. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +7 -7
  95. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  96. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  97. package/lib/cjs/topology/Graph.js +2 -2
  98. package/lib/cjs/topology/Graph.js.map +1 -1
  99. package/lib/cjs/topology/InsertAndRetriangulateContext.js +2 -2
  100. package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
  101. package/lib/cjs/topology/Merging.d.ts +1 -1
  102. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  103. package/lib/cjs/topology/Merging.js +2 -2
  104. package/lib/cjs/topology/Merging.js.map +1 -1
  105. package/lib/esm/Geometry.d.ts +2 -2
  106. package/lib/esm/Geometry.js +2 -2
  107. package/lib/esm/Geometry.js.map +1 -1
  108. package/lib/esm/clipping/ClipPrimitive.d.ts +7 -7
  109. package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
  110. package/lib/esm/clipping/ClipPrimitive.js +1 -1
  111. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  112. package/lib/esm/core-geometry.d.ts +1 -1
  113. package/lib/esm/core-geometry.d.ts.map +1 -1
  114. package/lib/esm/core-geometry.js +1 -1
  115. package/lib/esm/core-geometry.js.map +1 -1
  116. package/lib/esm/curve/Arc3d.d.ts +21 -10
  117. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  118. package/lib/esm/curve/Arc3d.js +66 -38
  119. package/lib/esm/curve/Arc3d.js.map +1 -1
  120. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  121. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  122. package/lib/esm/curve/CurveChainWithDistanceIndex.js +44 -25
  123. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  124. package/lib/esm/curve/CurveFactory.d.ts +11 -13
  125. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  126. package/lib/esm/curve/CurveFactory.js +17 -44
  127. package/lib/esm/curve/CurveFactory.js.map +1 -1
  128. package/lib/esm/curve/LineSegment3d.js +1 -1
  129. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  130. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  131. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +4 -3
  132. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  133. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  134. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  135. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +35 -60
  136. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  137. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  138. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  139. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +130 -69
  140. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  141. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  142. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  143. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  144. package/lib/esm/geometry3d/Angle.d.ts +5 -5
  145. package/lib/esm/geometry3d/Angle.js +5 -5
  146. package/lib/esm/geometry3d/Angle.js.map +1 -1
  147. package/lib/esm/geometry3d/AngleSweep.d.ts +101 -13
  148. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/AngleSweep.js +156 -57
  150. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  151. package/lib/esm/geometry3d/BilinearPatch.js +1 -1
  152. package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
  153. package/lib/esm/geometry3d/Matrix3d.d.ts +35 -31
  154. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/Matrix3d.js +55 -31
  156. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  157. package/lib/esm/geometry3d/Point3dVector3d.d.ts +6 -5
  158. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  159. package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
  160. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  161. package/lib/esm/geometry3d/PolygonOps.js +2 -2
  162. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  163. package/lib/esm/geometry3d/Ray3d.js +1 -1
  164. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  165. package/lib/esm/geometry3d/Transform.d.ts +4 -2
  166. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  167. package/lib/esm/geometry3d/Transform.js +4 -2
  168. package/lib/esm/geometry3d/Transform.js.map +1 -1
  169. package/lib/esm/geometry4d/Map4d.d.ts +5 -5
  170. package/lib/esm/geometry4d/Map4d.js +5 -5
  171. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  172. package/lib/esm/geometry4d/Matrix4d.d.ts +4 -7
  173. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  174. package/lib/esm/geometry4d/Matrix4d.js +4 -7
  175. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  176. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  177. package/lib/esm/geometry4d/Point4d.js +2 -1
  178. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  179. package/lib/esm/numerics/Newton.d.ts +3 -0
  180. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  181. package/lib/esm/numerics/Newton.js +1 -4
  182. package/lib/esm/numerics/Newton.js.map +1 -1
  183. package/lib/esm/numerics/Polynomials.d.ts +46 -201
  184. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  185. package/lib/esm/numerics/Polynomials.js +132 -444
  186. package/lib/esm/numerics/Polynomials.js.map +1 -1
  187. package/lib/esm/numerics/SmallSystem.d.ts +164 -0
  188. package/lib/esm/numerics/SmallSystem.d.ts.map +1 -0
  189. package/lib/esm/numerics/SmallSystem.js +317 -0
  190. package/lib/esm/numerics/SmallSystem.js.map +1 -0
  191. package/lib/esm/polyface/PolyfaceClip.d.ts +3 -3
  192. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  193. package/lib/esm/polyface/PolyfaceClip.js +1 -1
  194. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  195. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  196. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  197. package/lib/esm/polyface/multiclip/OffsetMeshContext.js +4 -4
  198. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  199. package/lib/esm/topology/Graph.d.ts.map +1 -1
  200. package/lib/esm/topology/Graph.js +1 -1
  201. package/lib/esm/topology/Graph.js.map +1 -1
  202. package/lib/esm/topology/InsertAndRetriangulateContext.js +1 -1
  203. package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
  204. package/lib/esm/topology/Merging.d.ts +1 -1
  205. package/lib/esm/topology/Merging.d.ts.map +1 -1
  206. package/lib/esm/topology/Merging.js +1 -1
  207. package/lib/esm/topology/Merging.js.map +1 -1
  208. package/package.json +7 -19
@@ -15,6 +15,7 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
15
15
  const Range_1 = require("../geometry3d/Range");
16
16
  const Ray3d_1 = require("../geometry3d/Ray3d");
17
17
  const Polynomials_1 = require("../numerics/Polynomials");
18
+ const SmallSystem_1 = require("../numerics/SmallSystem");
18
19
  const CurveExtendMode_1 = require("./CurveExtendMode");
19
20
  const CurveLocationDetail_1 = require("./CurveLocationDetail");
20
21
  const CurvePrimitive_1 = require("./CurvePrimitive");
@@ -291,19 +292,19 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
291
292
  }
292
293
  /**
293
294
  * Create an elliptical arc from three points on the ellipse: two points on an axis and one in between.
294
- * @param point0 start of arc, on an axis
295
- * @param point1 point on arc somewhere between `point0` and `point2`
296
- * @param point2 point on arc directly opposite `point0`
297
- * @param sweep angular sweep, measured from `point0` in the direction of `point1`.
298
- * For a half-ellipse from `point0` to `point2` passing through `point1`, pass `AngleSweep.createStartEndDegrees(0,180)`.
295
+ * @param start start of arc, on an axis
296
+ * @param middle point on arc somewhere between `start` and `end`
297
+ * @param end point on arc directly opposite `start`
298
+ * @param sweep angular sweep, measured from `start` in the direction of `middle`.
299
+ * For a half-ellipse from `start` to `end` passing through `middle`, pass `AngleSweep.createStartEndDegrees(0,180)`.
299
300
  * Default value is full sweep to create the entire ellipse.
300
301
  * @param result optional preallocated result
301
302
  * @returns elliptical arc, or undefined if construction impossible.
302
303
  */
303
- static createStartMiddleEnd(point0, point1, point2, sweep, result) {
304
- const center = Point3dVector3d_1.Point3d.createAdd2Scaled(point0, 0.5, point2, 0.5);
305
- const vector0 = Point3dVector3d_1.Vector3d.createStartEnd(center, point0);
306
- const vector1 = Point3dVector3d_1.Vector3d.createStartEnd(center, point1);
304
+ static createStartMiddleEnd(start, middle, end, sweep, result) {
305
+ const center = Point3dVector3d_1.Point3d.createAdd2Scaled(start, 0.5, end, 0.5);
306
+ const vector0 = Point3dVector3d_1.Vector3d.createStartEnd(center, start);
307
+ const vector1 = Point3dVector3d_1.Vector3d.createStartEnd(center, middle);
307
308
  const v0DotV1 = vector0.dotProduct(vector1);
308
309
  const v0Len2 = vector0.magnitudeSquared();
309
310
  if (Math.abs(v0DotV1) >= v0Len2)
@@ -311,7 +312,7 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
311
312
  const normal = vector0.crossProduct(vector1);
312
313
  const vector90 = normal.unitCrossProductWithDefault(vector0, 0, 0, 0);
313
314
  const v1DotV90 = vector1.dotProduct(vector90);
314
- // Solve the standard ellipse equation for the unknown axis length, given local coords of point1 (v0.v1/||v0||, v90.v1)
315
+ // solve the standard ellipse equation for the unknown axis length, given local coords of middle (v0.v1/||v0||, v90.v1)
315
316
  const v90Len = Geometry_1.Geometry.safeDivideFraction(v0Len2 * v1DotV90, Math.sqrt(v0Len2 * v0Len2 - v0DotV1 * v0DotV1), 0);
316
317
  if (Geometry_1.Geometry.isSmallMetricDistanceSquared(v90Len))
317
318
  return undefined;
@@ -320,33 +321,55 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
320
321
  }
321
322
  /**
322
323
  * Create a circular arc defined by start point, tangent at start point, and end point.
323
- * If tangent is parallel to line segment from start to end, return the line segment.
324
+ * * The circular arc is swept from `start` to `end` in the direction of `tangentAtStart`.
325
+ * * If `tangentAtStart` is parallel to the line segment from `start` to `end`, return the line segment.
324
326
  */
325
327
  static createCircularStartTangentEnd(start, tangentAtStart, end, result) {
326
- // To find the circle passing through start and end with tangentAtStart at start:
327
- // - find line 1: the perpendicular bisector of the line from start to end.
328
- // - find line 2: the perpendicular to the tangentAtStart.
329
- // - intersection of the two lines would be the circle center.
330
- const vector = Point3dVector3d_1.Vector3d.createStartEnd(start, end);
331
- const normal = tangentAtStart.crossProduct(vector).normalize();
332
- if (normal) {
333
- const vectorPerp = normal.crossProduct(vector);
334
- const tangentPerp = normal.crossProduct(tangentAtStart);
335
- const midPoint = start.plusScaled(vector, 0.5);
336
- const lineSeg1 = LineSegment3d_1.LineSegment3d.create(start, start.plusScaled(tangentPerp, 1));
337
- const lineSeg2 = LineSegment3d_1.LineSegment3d.create(midPoint, midPoint.plusScaled(vectorPerp, 1));
338
- const intersection = LineSegment3d_1.LineSegment3d.closestApproach(lineSeg1, true, lineSeg2, true);
339
- if (intersection) {
340
- const center = intersection.detailA.point;
341
- const vector0 = Point3dVector3d_1.Vector3d.createStartEnd(center, start);
342
- const vector90 = normal.crossProduct(vector0);
343
- const endVector = Point3dVector3d_1.Vector3d.createStartEnd(center, end);
344
- const sweep = AngleSweep_1.AngleSweep.create(vector0.signedAngleTo(endVector, normal));
328
+ // see itwinjs-core\core\geometry\internaldocs\Arc3d.md to clarify below algorithm
329
+ const startToEnd = Point3dVector3d_1.Vector3d.createStartEnd(start, end);
330
+ const frame = Matrix3d_1.Matrix3d.createRigidFromColumns(tangentAtStart, startToEnd, Geometry_1.AxisOrder.XYZ);
331
+ if (frame !== undefined) {
332
+ const vv = startToEnd.dotProduct(startToEnd);
333
+ const vw = frame.dotColumnY(startToEnd);
334
+ const radius = Geometry_1.Geometry.conditionalDivideCoordinate(vv, 2 * vw);
335
+ if (radius !== undefined) {
336
+ const vector0 = frame.columnY();
337
+ vector0.scaleInPlace(-radius); // center to start
338
+ const vector90 = frame.columnX();
339
+ vector90.scaleInPlace(radius);
340
+ const centerToEnd = vector0.plus(startToEnd);
341
+ const sweepAngle = vector0.angleTo(centerToEnd);
342
+ let sweepRadians = sweepAngle.radians; // always positive and less than PI
343
+ if (tangentAtStart.dotProduct(centerToEnd) < 0.0) // sweepRadians is the wrong way
344
+ sweepRadians = 2.0 * Math.PI - sweepRadians;
345
+ const center = start.plusScaled(vector0, -1.0);
346
+ const sweep = AngleSweep_1.AngleSweep.createStartEndRadians(0.0, sweepRadians);
345
347
  return Arc3d.create(center, vector0, vector90, sweep, result);
346
348
  }
347
349
  }
348
350
  return LineSegment3d_1.LineSegment3d.create(start, end);
349
351
  }
352
+ /**
353
+ * Create a circular arc from start point, tangent at start, radius, optional plane normal, arc sweep.
354
+ * * The vector from start point to center is in the direction of upVector crossed with tangentA.
355
+ * @param start start point.
356
+ * @param tangentAtStart vector in tangent direction at the start.
357
+ * @param radius signed radius.
358
+ * @param upVector optional out-of-plane vector. Defaults to positive Z.
359
+ * @param sweep angular range. If single `Angle` is given, start angle is at 0 degrees (the start point).
360
+ */
361
+ static createCircularStartTangentRadius(start, tangentAtStart, radius, upVector, sweep) {
362
+ if (upVector === undefined)
363
+ upVector = Point3dVector3d_1.Vector3d.unitZ();
364
+ const vector0 = upVector.unitCrossProduct(tangentAtStart);
365
+ if (vector0 === undefined)
366
+ return undefined;
367
+ const center = start.plusScaled(vector0, radius);
368
+ // reverse the A-to-center vector and bring it up to scale
369
+ vector0.scaleInPlace(-radius);
370
+ const vector90 = tangentAtStart.scaleToLength(Math.abs(radius)); // cannot fail; prior unitCrossProduct would have failed first
371
+ return Arc3d.create(center, vector0, vector90, AngleSweep_1.AngleSweep.create(sweep));
372
+ }
350
373
  /**
351
374
  * Create a circular arc defined by start and end points and radius.
352
375
  * @param start start point of the arc
@@ -423,7 +446,7 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
423
446
  const ac2 = vectorAC.magnitudeSquared();
424
447
  const normal = vectorAB.sizedCrossProduct(vectorAC, Math.sqrt(Math.sqrt(ab2 * ac2)));
425
448
  if (normal) {
426
- const vectorToCenter = Polynomials_1.SmallSystem.linearSystem3d(normal.x, normal.y, normal.z, vectorAB.x, vectorAB.y, vectorAB.z, vectorAC.x, vectorAC.y, vectorAC.z, 0, // vectorToCenter DOT normal = 0 (ensure normal is perp to the plane of the 3 points)
449
+ const vectorToCenter = SmallSystem_1.SmallSystem.linearSystem3d(normal.x, normal.y, normal.z, vectorAB.x, vectorAB.y, vectorAB.z, vectorAC.x, vectorAC.y, vectorAC.z, 0, // vectorToCenter DOT normal = 0 (ensure normal is perp to the plane of the 3 points)
427
450
  0.5 * ab2, // vectorToCenter DOT vectorAB = ab2 / 2 (ensure the projection of vectorToCenter on AB bisects AB)
428
451
  0.5 * ac2);
429
452
  if (vectorToCenter) { // i.e., the negative of vectorX
@@ -761,7 +784,7 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
761
784
  circularRadius() {
762
785
  return this.isCircular ? this._matrix.columnXMagnitude() : undefined;
763
786
  }
764
- /** Return the larger of the two defining vectors. */
787
+ /** Return the larger length of the two defining vectors. */
765
788
  maxVectorLength() {
766
789
  return Math.max(this._matrix.columnXMagnitude(), this._matrix.columnYMagnitude());
767
790
  }
@@ -969,12 +992,12 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
969
992
  };
970
993
  }
971
994
  /** Test if this arc is almost equal to another GeometryQuery object */
972
- isAlmostEqual(otherGeometry) {
995
+ isAlmostEqual(otherGeometry, distanceTol = Geometry_1.Geometry.smallMetricDistance, radianTol = Geometry_1.Geometry.smallAngleRadians) {
973
996
  if (otherGeometry instanceof Arc3d) {
974
997
  const other = otherGeometry;
975
- return this._center.isAlmostEqual(other._center)
976
- && this._matrix.isAlmostEqual(other._matrix)
977
- && this._sweep.isAlmostEqualAllowPeriodShift(other._sweep);
998
+ return this._center.isAlmostEqual(other._center, distanceTol)
999
+ && this._matrix.isAlmostEqual(other._matrix, distanceTol)
1000
+ && this._sweep.isAlmostEqualAllowPeriodShift(other._sweep, radianTol);
978
1001
  }
979
1002
  return false;
980
1003
  }
@@ -1057,7 +1080,12 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
1057
1080
  const otherVector0 = this._matrix.multiplyInverse(other.vector0);
1058
1081
  const otherVector90 = this._matrix.multiplyInverse(other.vector90);
1059
1082
  if (otherOrigin && otherVector0 && otherVector90) {
1060
- return { center: otherOrigin, vector0: otherVector0, vector90: otherVector90, sweep: this.sweep.clone() };
1083
+ return {
1084
+ center: otherOrigin,
1085
+ vector0: otherVector0,
1086
+ vector90: otherVector90,
1087
+ sweep: this.sweep.clone(),
1088
+ };
1061
1089
  }
1062
1090
  return undefined;
1063
1091
  }
@@ -1075,7 +1103,7 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
1075
1103
  * * `point` is the `point1` input.
1076
1104
  * * both fractions are zero
1077
1105
  * * `arc` is undefined.
1078
- * @param point0 first point of path. (the point before the point of inflection)
1106
+ * @param point0 first point of path (the point before the point of inflection)
1079
1107
  * @param point1 second point of path (the point of inflection)
1080
1108
  * @param point2 third point of path (the point after the point of inflection)
1081
1109
  * @param radius arc radius