@itwin/core-geometry 5.7.2 → 5.8.0-dev.10

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 (242) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/lib/cjs/Geometry.d.ts +24 -14
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +34 -14
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurve.d.ts +1 -1
  7. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  8. package/lib/cjs/bspline/BSplineCurve.js +1 -1
  9. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  10. package/lib/cjs/clipping/ClipPrimitive.d.ts +2 -1
  11. package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
  12. package/lib/cjs/clipping/ClipPrimitive.js +2 -1
  13. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  14. package/lib/cjs/core-geometry.d.ts +1 -0
  15. package/lib/cjs/core-geometry.d.ts.map +1 -1
  16. package/lib/cjs/core-geometry.js +1 -0
  17. package/lib/cjs/core-geometry.js.map +1 -1
  18. package/lib/cjs/curve/Arc3d.d.ts +19 -3
  19. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  20. package/lib/cjs/curve/Arc3d.js +50 -23
  21. package/lib/cjs/curve/Arc3d.js.map +1 -1
  22. package/lib/cjs/curve/ConstrainedCurve2d.d.ts +149 -0
  23. package/lib/cjs/curve/ConstrainedCurve2d.d.ts.map +1 -0
  24. package/lib/cjs/curve/ConstrainedCurve2d.js +317 -0
  25. package/lib/cjs/curve/ConstrainedCurve2d.js.map +1 -0
  26. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +18 -5
  27. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  28. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +34 -14
  29. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  30. package/lib/cjs/curve/CurveCollection.d.ts +12 -11
  31. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  32. package/lib/cjs/curve/CurveCollection.js +36 -36
  33. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  34. package/lib/cjs/curve/CurveExtendMode.d.ts +5 -5
  35. package/lib/cjs/curve/CurveExtendMode.d.ts.map +1 -1
  36. package/lib/cjs/curve/CurveExtendMode.js +4 -1
  37. package/lib/cjs/curve/CurveExtendMode.js.map +1 -1
  38. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  40. package/lib/cjs/curve/CurvePrimitive.d.ts +14 -2
  41. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  42. package/lib/cjs/curve/CurvePrimitive.js +19 -3
  43. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  44. package/lib/cjs/curve/LineSegment3d.d.ts +2 -2
  45. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  46. package/lib/cjs/curve/LineSegment3d.js +2 -2
  47. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  48. package/lib/cjs/curve/LineString3d.d.ts +1 -1
  49. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  50. package/lib/cjs/curve/LineString3d.js +1 -1
  51. package/lib/cjs/curve/LineString3d.js.map +1 -1
  52. package/lib/cjs/curve/Path.d.ts +4 -15
  53. package/lib/cjs/curve/Path.d.ts.map +1 -1
  54. package/lib/cjs/curve/Path.js +1 -35
  55. package/lib/cjs/curve/Path.js.map +1 -1
  56. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +2 -1
  57. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  58. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +18 -13
  59. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  60. package/lib/cjs/curve/internalContexts/PointToCurveTangentHandler.d.ts +26 -0
  61. package/lib/cjs/curve/internalContexts/PointToCurveTangentHandler.d.ts.map +1 -0
  62. package/lib/cjs/curve/internalContexts/PointToCurveTangentHandler.js +78 -0
  63. package/lib/cjs/curve/internalContexts/PointToCurveTangentHandler.js.map +1 -0
  64. package/lib/cjs/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.d.ts +152 -0
  65. package/lib/cjs/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.d.ts.map +1 -0
  66. package/lib/cjs/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.js +843 -0
  67. package/lib/cjs/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.js.map +1 -0
  68. package/lib/cjs/curve/internalContexts/geometry2d/ConstraintSet.d.ts +97 -0
  69. package/lib/cjs/curve/internalContexts/geometry2d/ConstraintSet.d.ts.map +1 -0
  70. package/lib/cjs/curve/internalContexts/geometry2d/ConstraintSet.js +300 -0
  71. package/lib/cjs/curve/internalContexts/geometry2d/ConstraintSet.js.map +1 -0
  72. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2d.d.ts +105 -0
  73. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2d.d.ts.map +1 -0
  74. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2d.js +141 -0
  75. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2d.js.map +1 -0
  76. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.d.ts +27 -0
  77. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.d.ts.map +1 -0
  78. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.js +152 -0
  79. package/lib/cjs/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.js.map +1 -0
  80. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedCircle2d.d.ts +81 -0
  81. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedCircle2d.d.ts.map +1 -0
  82. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedCircle2d.js +170 -0
  83. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedCircle2d.js.map +1 -0
  84. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedEllipse2d.d.ts +96 -0
  85. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedEllipse2d.d.ts.map +1 -0
  86. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedEllipse2d.js +187 -0
  87. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedEllipse2d.js.map +1 -0
  88. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedHyperbola2d.d.ts +91 -0
  89. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedHyperbola2d.d.ts.map +1 -0
  90. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedHyperbola2d.js +197 -0
  91. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedHyperbola2d.js.map +1 -0
  92. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedLine2d.d.ts +129 -0
  93. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedLine2d.d.ts.map +1 -0
  94. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedLine2d.js +208 -0
  95. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedLine2d.js.map +1 -0
  96. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedParabola2d.d.ts +87 -0
  97. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedParabola2d.d.ts.map +1 -0
  98. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedParabola2d.js +193 -0
  99. package/lib/cjs/curve/internalContexts/geometry2d/UnboundedParabola2d.js.map +1 -0
  100. package/lib/cjs/geometry3d/Ellipsoid.d.ts +2 -1
  101. package/lib/cjs/geometry3d/Ellipsoid.d.ts.map +1 -1
  102. package/lib/cjs/geometry3d/Ellipsoid.js +2 -1
  103. package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
  104. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +7 -0
  105. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  106. package/lib/cjs/geometry3d/Point2dVector2d.js +9 -0
  107. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  108. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  109. package/lib/cjs/geometry3d/Ray3d.d.ts +5 -0
  110. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  111. package/lib/cjs/geometry3d/Ray3d.js +7 -0
  112. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  113. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  114. package/lib/cjs/numerics/Newton.js +2 -1
  115. package/lib/cjs/numerics/Newton.js.map +1 -1
  116. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  117. package/lib/cjs/numerics/Polynomials.js +8 -6
  118. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  119. package/lib/cjs/topology/HalfEdgeGraphSpineContext.d.ts.map +1 -1
  120. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js +3 -1
  121. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  122. package/lib/esm/Geometry.d.ts +24 -14
  123. package/lib/esm/Geometry.d.ts.map +1 -1
  124. package/lib/esm/Geometry.js +34 -14
  125. package/lib/esm/Geometry.js.map +1 -1
  126. package/lib/esm/bspline/BSplineCurve.d.ts +1 -1
  127. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  128. package/lib/esm/bspline/BSplineCurve.js +1 -1
  129. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  130. package/lib/esm/clipping/ClipPrimitive.d.ts +2 -1
  131. package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
  132. package/lib/esm/clipping/ClipPrimitive.js +2 -1
  133. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  134. package/lib/esm/core-geometry.d.ts +1 -0
  135. package/lib/esm/core-geometry.d.ts.map +1 -1
  136. package/lib/esm/core-geometry.js +1 -0
  137. package/lib/esm/core-geometry.js.map +1 -1
  138. package/lib/esm/curve/Arc3d.d.ts +19 -3
  139. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  140. package/lib/esm/curve/Arc3d.js +50 -23
  141. package/lib/esm/curve/Arc3d.js.map +1 -1
  142. package/lib/esm/curve/ConstrainedCurve2d.d.ts +149 -0
  143. package/lib/esm/curve/ConstrainedCurve2d.d.ts.map +1 -0
  144. package/lib/esm/curve/ConstrainedCurve2d.js +313 -0
  145. package/lib/esm/curve/ConstrainedCurve2d.js.map +1 -0
  146. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +18 -5
  147. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  148. package/lib/esm/curve/CurveChainWithDistanceIndex.js +34 -14
  149. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  150. package/lib/esm/curve/CurveCollection.d.ts +12 -11
  151. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  152. package/lib/esm/curve/CurveCollection.js +36 -36
  153. package/lib/esm/curve/CurveCollection.js.map +1 -1
  154. package/lib/esm/curve/CurveExtendMode.d.ts +5 -5
  155. package/lib/esm/curve/CurveExtendMode.d.ts.map +1 -1
  156. package/lib/esm/curve/CurveExtendMode.js +4 -1
  157. package/lib/esm/curve/CurveExtendMode.js.map +1 -1
  158. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  159. package/lib/esm/curve/CurveFactory.js.map +1 -1
  160. package/lib/esm/curve/CurvePrimitive.d.ts +14 -2
  161. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  162. package/lib/esm/curve/CurvePrimitive.js +19 -3
  163. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  164. package/lib/esm/curve/LineSegment3d.d.ts +2 -2
  165. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  166. package/lib/esm/curve/LineSegment3d.js +2 -2
  167. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  168. package/lib/esm/curve/LineString3d.d.ts +1 -1
  169. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  170. package/lib/esm/curve/LineString3d.js +1 -1
  171. package/lib/esm/curve/LineString3d.js.map +1 -1
  172. package/lib/esm/curve/Path.d.ts +4 -15
  173. package/lib/esm/curve/Path.d.ts.map +1 -1
  174. package/lib/esm/curve/Path.js +1 -35
  175. package/lib/esm/curve/Path.js.map +1 -1
  176. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +2 -1
  177. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  178. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +19 -14
  179. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  180. package/lib/esm/curve/internalContexts/PointToCurveTangentHandler.d.ts +26 -0
  181. package/lib/esm/curve/internalContexts/PointToCurveTangentHandler.d.ts.map +1 -0
  182. package/lib/esm/curve/internalContexts/PointToCurveTangentHandler.js +74 -0
  183. package/lib/esm/curve/internalContexts/PointToCurveTangentHandler.js.map +1 -0
  184. package/lib/esm/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.d.ts +152 -0
  185. package/lib/esm/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.d.ts.map +1 -0
  186. package/lib/esm/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.js +839 -0
  187. package/lib/esm/curve/internalContexts/geometry2d/ConstrainedImplicitCurve2d.js.map +1 -0
  188. package/lib/esm/curve/internalContexts/geometry2d/ConstraintSet.d.ts +97 -0
  189. package/lib/esm/curve/internalContexts/geometry2d/ConstraintSet.d.ts.map +1 -0
  190. package/lib/esm/curve/internalContexts/geometry2d/ConstraintSet.js +295 -0
  191. package/lib/esm/curve/internalContexts/geometry2d/ConstraintSet.js.map +1 -0
  192. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2d.d.ts +105 -0
  193. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2d.d.ts.map +1 -0
  194. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2d.js +135 -0
  195. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2d.js.map +1 -0
  196. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.d.ts +27 -0
  197. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.d.ts.map +1 -0
  198. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.js +148 -0
  199. package/lib/esm/curve/internalContexts/geometry2d/ImplicitCurve2dConverter.js.map +1 -0
  200. package/lib/esm/curve/internalContexts/geometry2d/UnboundedCircle2d.d.ts +81 -0
  201. package/lib/esm/curve/internalContexts/geometry2d/UnboundedCircle2d.d.ts.map +1 -0
  202. package/lib/esm/curve/internalContexts/geometry2d/UnboundedCircle2d.js +166 -0
  203. package/lib/esm/curve/internalContexts/geometry2d/UnboundedCircle2d.js.map +1 -0
  204. package/lib/esm/curve/internalContexts/geometry2d/UnboundedEllipse2d.d.ts +96 -0
  205. package/lib/esm/curve/internalContexts/geometry2d/UnboundedEllipse2d.d.ts.map +1 -0
  206. package/lib/esm/curve/internalContexts/geometry2d/UnboundedEllipse2d.js +183 -0
  207. package/lib/esm/curve/internalContexts/geometry2d/UnboundedEllipse2d.js.map +1 -0
  208. package/lib/esm/curve/internalContexts/geometry2d/UnboundedHyperbola2d.d.ts +91 -0
  209. package/lib/esm/curve/internalContexts/geometry2d/UnboundedHyperbola2d.d.ts.map +1 -0
  210. package/lib/esm/curve/internalContexts/geometry2d/UnboundedHyperbola2d.js +193 -0
  211. package/lib/esm/curve/internalContexts/geometry2d/UnboundedHyperbola2d.js.map +1 -0
  212. package/lib/esm/curve/internalContexts/geometry2d/UnboundedLine2d.d.ts +129 -0
  213. package/lib/esm/curve/internalContexts/geometry2d/UnboundedLine2d.d.ts.map +1 -0
  214. package/lib/esm/curve/internalContexts/geometry2d/UnboundedLine2d.js +204 -0
  215. package/lib/esm/curve/internalContexts/geometry2d/UnboundedLine2d.js.map +1 -0
  216. package/lib/esm/curve/internalContexts/geometry2d/UnboundedParabola2d.d.ts +87 -0
  217. package/lib/esm/curve/internalContexts/geometry2d/UnboundedParabola2d.d.ts.map +1 -0
  218. package/lib/esm/curve/internalContexts/geometry2d/UnboundedParabola2d.js +189 -0
  219. package/lib/esm/curve/internalContexts/geometry2d/UnboundedParabola2d.js.map +1 -0
  220. package/lib/esm/geometry3d/Ellipsoid.d.ts +2 -1
  221. package/lib/esm/geometry3d/Ellipsoid.d.ts.map +1 -1
  222. package/lib/esm/geometry3d/Ellipsoid.js +2 -1
  223. package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
  224. package/lib/esm/geometry3d/Point2dVector2d.d.ts +7 -0
  225. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  226. package/lib/esm/geometry3d/Point2dVector2d.js +9 -0
  227. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  228. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  229. package/lib/esm/geometry3d/Ray3d.d.ts +5 -0
  230. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  231. package/lib/esm/geometry3d/Ray3d.js +7 -0
  232. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  233. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  234. package/lib/esm/numerics/Newton.js +2 -1
  235. package/lib/esm/numerics/Newton.js.map +1 -1
  236. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  237. package/lib/esm/numerics/Polynomials.js +8 -6
  238. package/lib/esm/numerics/Polynomials.js.map +1 -1
  239. package/lib/esm/topology/HalfEdgeGraphSpineContext.d.ts.map +1 -1
  240. package/lib/esm/topology/HalfEdgeGraphSpineContext.js +3 -1
  241. package/lib/esm/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  242. package/package.json +3 -3
@@ -771,48 +771,61 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
771
771
  /**
772
772
  * Return details of the closest point on the arc, optionally extending to full ellipse.
773
773
  * @param spacePoint search for point closest to this point.
774
- * @param extend if true, consider projections to the complete ellipse. If false, consider only endpoints and
775
- * projections within the arc sweep.
774
+ * @param extend if true, consider projections to the complete ellipse. If false (default), consider only endpoints
775
+ * and projections within the arc sweep. Note that for an open arc, extending one end is the same as extending both ends.
776
776
  * @param result optional preallocated result.
777
777
  */
778
- closestPoint(spacePoint, extend, result) {
778
+ closestPoint(spacePoint, extend = false, result) {
779
779
  result = CurveLocationDetail_1.CurveLocationDetail.create(this, result);
780
- const allRadians = this.allPerpendicularAngles(spacePoint, true, true);
781
- let extend0 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
782
- let extend1 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
783
- // distinct extends for cyclic space are awkward ....
784
- if (this._sweep.isFullCircle) {
785
- extend0 = CurveExtendMode_1.CurveExtendMode.None;
786
- extend1 = CurveExtendMode_1.CurveExtendMode.None;
787
- }
788
- if (extend0 !== CurveExtendMode_1.CurveExtendMode.None && extend1 !== CurveExtendMode_1.CurveExtendMode.None) {
789
- allRadians.push(this._sweep.startRadians);
790
- allRadians.push(this._sweep.endRadians);
780
+ const allRadians = this.allPerpendicularAngles(spacePoint, true, false);
781
+ // test endpoints if and only if arc is open and unextended
782
+ if (!this._sweep.isFullCircle) {
783
+ const extend0 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
784
+ const extend1 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
785
+ if (extend0 === CurveExtendMode_1.CurveExtendMode.None && extend1 === CurveExtendMode_1.CurveExtendMode.None) {
786
+ allRadians.push(this._sweep.startRadians);
787
+ allRadians.push(this._sweep.endRadians);
788
+ }
791
789
  }
792
- // hm... logically there must at least two angles there ... but if it happens return the start point ...
793
790
  const workRay = Ray3d_1.Ray3d.createZero();
794
- if (allRadians.length === 0) {
795
- result.setFR(0.0, this.radiansToPointAndDerivative(this._sweep.startRadians, workRay));
796
- result.a = spacePoint.distance(result.point);
791
+ if (allRadians.length === 0) { // shouldn't happen; there should always be at least 2 angles
792
+ result.setFR(0.0, this.radiansToPointAndDerivative(this._sweep.startRadians, workRay), spacePoint.distance(result.point));
797
793
  }
798
794
  else {
799
795
  let dMin = Number.MAX_VALUE;
800
796
  let d = 0;
801
797
  for (const radians of allRadians) {
802
- const fraction = CurveExtendMode_1.CurveExtendOptions.resolveRadiansToSweepFraction(extend, radians, this.sweep);
803
- if (fraction !== undefined) {
804
- this.fractionToPointAndDerivative(fraction, workRay);
798
+ const validatedFraction = CurveExtendMode_1.CurveExtendOptions.resolveRadiansToValidSweepFraction(extend, radians, this.sweep);
799
+ if (validatedFraction.isValid) {
800
+ this.fractionToPointAndDerivative(validatedFraction.fraction, workRay);
805
801
  d = spacePoint.distance(workRay.origin);
806
802
  if (d < dMin) {
807
803
  dMin = d;
808
- result.setFR(fraction, workRay);
809
- result.a = d;
804
+ result.setFR(validatedFraction.fraction, workRay, d);
810
805
  }
811
806
  }
812
807
  }
813
808
  }
814
809
  return result;
815
810
  }
811
+ /**
812
+ * Search for a point on the Arc3d that is closest to the spacePoint as viewed in the xy-plane (ignoring z).
813
+ * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
814
+ * * Since CurvePrimitive should always have start and end available as candidate points, this method should always
815
+ * succeed.
816
+ * @param spacePoint point in space.
817
+ * @param extend if true, consider projections to the complete ellipse. If false (default), consider only endpoints
818
+ * and projections within the arc sweep. Note that for an open arc, extending one end is the same as extending both ends.
819
+ * @param result (optional) pre-allocated detail to populate and return.
820
+ * @returns details of the closest point.
821
+ */
822
+ closestPointXY(spacePoint, extend = false, result) {
823
+ // prevent `ClosestPointStroker.claimResult` from clamping an exterior fraction when arc is half-extended
824
+ const extend0 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 0);
825
+ const extend1 = CurveExtendMode_1.CurveExtendOptions.resolveVariantCurveExtendParameterToCurveExtendMode(extend, 1);
826
+ extend = extend0 !== CurveExtendMode_1.CurveExtendMode.None || extend1 !== CurveExtendMode_1.CurveExtendMode.None;
827
+ return super.closestPointXY(spacePoint, extend, result); // TODO: implement exact solution instead of deferring to superclass
828
+ }
816
829
  /** Override of [[CurvePrimitive.emitTangents]] for Arc3d. */
817
830
  emitTangents(spacePoint, announceTangent, options) {
818
831
  const centerToPoint = Point3dVector3d_1.Vector3d.createStartEnd(this.centerRef, spacePoint);
@@ -880,6 +893,20 @@ class Arc3d extends CurvePrimitive_1.CurvePrimitive {
880
893
  const axy = this._matrix.columnXDotColumnY();
881
894
  return Angle_1.Angle.isPerpendicularDotSet(axx, ayy, axy) && Geometry_1.Geometry.isSameCoordinateSquared(axx, ayy);
882
895
  }
896
+ /** Return true if the vector0 and vector90 xy parts are of equal length and perpendicular. */
897
+ get isCircularXY() {
898
+ const columnX = this._matrix.columnX();
899
+ const columnY = this._matrix.columnY();
900
+ const axx = columnX.magnitudeSquaredXY();
901
+ const ayy = columnY.magnitudeSquaredXY();
902
+ const axy = columnX.dotProductXY(columnY);
903
+ return Angle_1.Angle.isPerpendicularDotSet(axx, ayy, axy) && Geometry_1.Geometry.isSameCoordinateSquared(axx, ayy);
904
+ }
905
+ /** Return true if the arc has zero radius (is a point). */
906
+ get isDegenerateCircle() {
907
+ return Geometry_1.Geometry.isSmallMetricDistanceSquared(this._matrix.columnXMagnitudeSquared()) &&
908
+ Geometry_1.Geometry.isSmallMetricDistanceSquared(this._matrix.columnYMagnitudeSquared());
909
+ }
883
910
  /** Return radius if the vector0 and vector90 are of equal length and perpendicular. Ignores z. */
884
911
  circularRadiusXY() {
885
912
  const ux = this._matrix.at(0, 0);