@itwin/core-geometry 4.2.0-dev.9 → 4.3.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (478) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +4 -4
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +2 -2
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +4 -3
  7. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  8. package/lib/cjs/clipping/AlternatingConvexClipTree.js +1 -1
  9. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  10. package/lib/cjs/clipping/BooleanClipNode.d.ts +4 -3
  11. package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
  12. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  13. package/lib/cjs/clipping/ClipPlane.d.ts +2 -1
  14. package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
  15. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  16. package/lib/cjs/clipping/ClipUtils.d.ts +17 -11
  17. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  18. package/lib/cjs/clipping/ClipUtils.js +14 -8
  19. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  20. package/lib/cjs/clipping/ClipVector.d.ts +6 -5
  21. package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
  22. package/lib/cjs/clipping/ClipVector.js +1 -1
  23. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  24. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +3 -2
  25. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  26. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  27. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  28. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  29. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  30. package/lib/cjs/core-geometry.d.ts +1 -3
  31. package/lib/cjs/core-geometry.d.ts.map +1 -1
  32. package/lib/cjs/core-geometry.js +1 -3
  33. package/lib/cjs/core-geometry.js.map +1 -1
  34. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  35. package/lib/cjs/curve/Arc3d.js +4 -4
  36. package/lib/cjs/curve/Arc3d.js.map +1 -1
  37. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  38. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +171 -152
  40. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  41. package/lib/cjs/curve/CurveCollection.d.ts +19 -19
  42. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  43. package/lib/cjs/curve/CurveCollection.js +20 -22
  44. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  45. package/lib/cjs/curve/CurveCurve.d.ts +47 -30
  46. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  47. package/lib/cjs/curve/CurveCurve.js +81 -46
  48. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  49. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  50. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  51. package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -5
  52. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  53. package/lib/cjs/curve/CurveLocationDetail.js +14 -2
  54. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  55. package/lib/cjs/curve/CurveOps.d.ts +1 -1
  56. package/lib/cjs/curve/CurveOps.js.map +1 -1
  57. package/lib/cjs/curve/CurvePrimitive.d.ts +1 -2
  58. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  59. package/lib/cjs/curve/CurvePrimitive.js +2 -2
  60. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  61. package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
  62. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  63. package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  64. package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
  65. package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
  66. package/lib/cjs/curve/CurveTypes.js.map +1 -0
  67. package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
  68. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  69. package/lib/cjs/curve/ParityRegion.d.ts +3 -3
  70. package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
  71. package/lib/cjs/curve/ParityRegion.js +2 -2
  72. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  73. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  74. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  75. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
  76. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  77. package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
  78. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  79. package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
  80. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  81. package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
  82. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  83. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
  84. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  85. package/lib/cjs/curve/RegionOps.d.ts +54 -5
  86. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  87. package/lib/cjs/curve/RegionOps.js +154 -3
  88. package/lib/cjs/curve/RegionOps.js.map +1 -1
  89. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  90. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  91. package/lib/cjs/curve/StrokeOptions.d.ts +20 -11
  92. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  93. package/lib/cjs/curve/StrokeOptions.js +22 -11
  94. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  95. package/lib/cjs/curve/UnionRegion.d.ts +3 -3
  96. package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
  97. package/lib/cjs/curve/UnionRegion.js +2 -2
  98. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  99. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  100. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  101. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  102. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  103. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  104. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  105. package/lib/cjs/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  106. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  107. package/lib/{esm/curve → cjs/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  108. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  109. package/lib/cjs/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +104 -115
  110. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  111. package/lib/cjs/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  112. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  113. package/lib/cjs/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  114. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  115. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  116. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  117. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  118. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  119. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  120. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  121. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +1 -0
  122. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  123. package/lib/cjs/geometry3d/BarycentricTriangle.js +1 -0
  124. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  125. package/lib/cjs/geometry3d/FrameBuilder.d.ts +28 -11
  126. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  127. package/lib/cjs/geometry3d/FrameBuilder.js +57 -45
  128. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  129. package/lib/cjs/geometry3d/GeometryHandler.d.ts +15 -26
  130. package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
  131. package/lib/cjs/geometry3d/GeometryHandler.js +23 -32
  132. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  133. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +0 -8
  134. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  135. package/lib/cjs/geometry3d/GrowableXYZArray.js +0 -16
  136. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  137. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +4 -4
  138. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  139. package/lib/cjs/geometry3d/IndexedXYZCollection.js +12 -0
  140. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  141. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  142. package/lib/cjs/geometry3d/Matrix3d.js +3 -6
  143. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  144. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  145. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  146. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -2
  147. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  148. package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
  149. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  150. package/lib/cjs/geometry3d/PolygonOps.d.ts +2 -2
  151. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  152. package/lib/cjs/geometry3d/PolygonOps.js +2 -3
  153. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  154. package/lib/cjs/geometry3d/Range.d.ts +1 -1
  155. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  156. package/lib/cjs/geometry3d/Range.js +1 -1
  157. package/lib/cjs/geometry3d/Range.js.map +1 -1
  158. package/lib/cjs/geometry3d/Ray3d.d.ts +3 -1
  159. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  160. package/lib/cjs/geometry3d/Ray3d.js +4 -3
  161. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  162. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts +2 -1
  163. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  164. package/lib/cjs/geometry3d/ReusableObjectCache.js +1 -1
  165. package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
  166. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
  167. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  168. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  169. package/lib/cjs/geometry3d/Transform.js +4 -6
  170. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  171. package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
  172. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  173. package/lib/cjs/geometry4d/Map4d.d.ts +14 -8
  174. package/lib/cjs/geometry4d/Map4d.d.ts.map +1 -1
  175. package/lib/cjs/geometry4d/Map4d.js +38 -16
  176. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  177. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  178. package/lib/cjs/geometry4d/Matrix4d.js +4 -2
  179. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  180. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  181. package/lib/cjs/numerics/Polynomials.d.ts +2 -2
  182. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  183. package/lib/cjs/numerics/Polynomials.js +2 -2
  184. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  185. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -6
  186. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  187. package/lib/cjs/polyface/PolyfaceBuilder.js +55 -25
  188. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  189. package/lib/cjs/polyface/PolyfaceClip.d.ts +16 -7
  190. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  191. package/lib/cjs/polyface/PolyfaceClip.js +38 -7
  192. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  193. package/lib/cjs/polyface/PolyfaceData.d.ts +5 -39
  194. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  195. package/lib/cjs/polyface/PolyfaceData.js +7 -41
  196. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  197. package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -8
  198. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  199. package/lib/cjs/polyface/PolyfaceQuery.js +64 -18
  200. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  201. package/lib/cjs/serialization/GeometrySamples.d.ts +6 -0
  202. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  203. package/lib/cjs/serialization/GeometrySamples.js +68 -2
  204. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  205. package/lib/cjs/solid/LinearSweep.d.ts +1 -1
  206. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  207. package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
  208. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  209. package/lib/cjs/solid/RuledSweep.d.ts +1 -1
  210. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  211. package/lib/cjs/solid/SweepContour.d.ts +35 -26
  212. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  213. package/lib/cjs/solid/SweepContour.js +84 -100
  214. package/lib/cjs/solid/SweepContour.js.map +1 -1
  215. package/lib/cjs/topology/Graph.d.ts +29 -11
  216. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  217. package/lib/cjs/topology/Graph.js +45 -26
  218. package/lib/cjs/topology/Graph.js.map +1 -1
  219. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts +2 -2
  220. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  221. package/lib/cjs/topology/HalfEdgeMarkSet.js +4 -4
  222. package/lib/cjs/topology/HalfEdgeMarkSet.js.map +1 -1
  223. package/lib/cjs/topology/Merging.d.ts +3 -0
  224. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  225. package/lib/cjs/topology/Merging.js +19 -5
  226. package/lib/cjs/topology/Merging.js.map +1 -1
  227. package/lib/cjs/topology/Triangulation.d.ts +15 -7
  228. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  229. package/lib/cjs/topology/Triangulation.js +89 -47
  230. package/lib/cjs/topology/Triangulation.js.map +1 -1
  231. package/lib/esm/Geometry.d.ts +4 -4
  232. package/lib/esm/Geometry.d.ts.map +1 -1
  233. package/lib/esm/Geometry.js +2 -2
  234. package/lib/esm/Geometry.js.map +1 -1
  235. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +4 -3
  236. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  237. package/lib/esm/clipping/AlternatingConvexClipTree.js +1 -1
  238. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  239. package/lib/esm/clipping/BooleanClipNode.d.ts +4 -3
  240. package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
  241. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  242. package/lib/esm/clipping/ClipPlane.d.ts +2 -1
  243. package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
  244. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  245. package/lib/esm/clipping/ClipUtils.d.ts +17 -11
  246. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  247. package/lib/esm/clipping/ClipUtils.js +14 -8
  248. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  249. package/lib/esm/clipping/ClipVector.d.ts +6 -5
  250. package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
  251. package/lib/esm/clipping/ClipVector.js +1 -1
  252. package/lib/esm/clipping/ClipVector.js.map +1 -1
  253. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +3 -2
  254. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  255. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  256. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  257. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  258. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  259. package/lib/esm/core-geometry.d.ts +1 -3
  260. package/lib/esm/core-geometry.d.ts.map +1 -1
  261. package/lib/esm/core-geometry.js +1 -3
  262. package/lib/esm/core-geometry.js.map +1 -1
  263. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  264. package/lib/esm/curve/Arc3d.js +4 -4
  265. package/lib/esm/curve/Arc3d.js.map +1 -1
  266. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  267. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  268. package/lib/esm/curve/CurveChainWithDistanceIndex.js +171 -152
  269. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  270. package/lib/esm/curve/CurveCollection.d.ts +19 -19
  271. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  272. package/lib/esm/curve/CurveCollection.js +19 -20
  273. package/lib/esm/curve/CurveCollection.js.map +1 -1
  274. package/lib/esm/curve/CurveCurve.d.ts +47 -30
  275. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  276. package/lib/esm/curve/CurveCurve.js +81 -46
  277. package/lib/esm/curve/CurveCurve.js.map +1 -1
  278. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  279. package/lib/esm/curve/CurveFactory.js.map +1 -1
  280. package/lib/esm/curve/CurveLocationDetail.d.ts +17 -5
  281. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  282. package/lib/esm/curve/CurveLocationDetail.js +12 -1
  283. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  284. package/lib/esm/curve/CurveOps.d.ts +1 -1
  285. package/lib/esm/curve/CurveOps.js.map +1 -1
  286. package/lib/esm/curve/CurvePrimitive.d.ts +1 -2
  287. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  288. package/lib/esm/curve/CurvePrimitive.js +2 -2
  289. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  290. package/lib/esm/curve/CurveProcessor.d.ts +1 -1
  291. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  292. package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  293. package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
  294. package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
  295. package/lib/esm/curve/CurveTypes.js.map +1 -0
  296. package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
  297. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  298. package/lib/esm/curve/ParityRegion.d.ts +3 -3
  299. package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
  300. package/lib/esm/curve/ParityRegion.js +2 -2
  301. package/lib/esm/curve/ParityRegion.js.map +1 -1
  302. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  303. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  304. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
  305. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  306. package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
  307. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  308. package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
  309. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  310. package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
  311. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  312. package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
  313. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  314. package/lib/esm/curve/RegionOps.d.ts +54 -5
  315. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  316. package/lib/esm/curve/RegionOps.js +153 -3
  317. package/lib/esm/curve/RegionOps.js.map +1 -1
  318. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  319. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  320. package/lib/esm/curve/StrokeOptions.d.ts +20 -11
  321. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  322. package/lib/esm/curve/StrokeOptions.js +22 -11
  323. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  324. package/lib/esm/curve/UnionRegion.d.ts +3 -3
  325. package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
  326. package/lib/esm/curve/UnionRegion.js +2 -2
  327. package/lib/esm/curve/UnionRegion.js.map +1 -1
  328. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  329. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  330. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  331. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  332. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  333. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  334. package/lib/esm/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  335. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  336. package/lib/{cjs/curve → esm/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  337. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  338. package/lib/esm/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +103 -113
  339. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  340. package/lib/esm/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  341. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  342. package/lib/esm/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  343. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  344. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  345. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  346. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  347. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  348. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  349. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  350. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +1 -0
  351. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  352. package/lib/esm/geometry3d/BarycentricTriangle.js +1 -0
  353. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  354. package/lib/esm/geometry3d/FrameBuilder.d.ts +28 -11
  355. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  356. package/lib/esm/geometry3d/FrameBuilder.js +57 -45
  357. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  358. package/lib/esm/geometry3d/GeometryHandler.d.ts +15 -26
  359. package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
  360. package/lib/esm/geometry3d/GeometryHandler.js +23 -32
  361. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  362. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +0 -8
  363. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  364. package/lib/esm/geometry3d/GrowableXYZArray.js +0 -16
  365. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  366. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +4 -4
  367. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  368. package/lib/esm/geometry3d/IndexedXYZCollection.js +12 -0
  369. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  370. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  371. package/lib/esm/geometry3d/Matrix3d.js +3 -6
  372. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  373. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  374. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  375. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -2
  376. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  377. package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
  378. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  379. package/lib/esm/geometry3d/PolygonOps.d.ts +2 -2
  380. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  381. package/lib/esm/geometry3d/PolygonOps.js +2 -3
  382. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  383. package/lib/esm/geometry3d/Range.d.ts +1 -1
  384. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  385. package/lib/esm/geometry3d/Range.js +1 -1
  386. package/lib/esm/geometry3d/Range.js.map +1 -1
  387. package/lib/esm/geometry3d/Ray3d.d.ts +3 -1
  388. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  389. package/lib/esm/geometry3d/Ray3d.js +4 -3
  390. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  391. package/lib/esm/geometry3d/ReusableObjectCache.d.ts +2 -1
  392. package/lib/esm/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  393. package/lib/esm/geometry3d/ReusableObjectCache.js +1 -1
  394. package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
  395. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
  396. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  397. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  398. package/lib/esm/geometry3d/Transform.js +4 -6
  399. package/lib/esm/geometry3d/Transform.js.map +1 -1
  400. package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
  401. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  402. package/lib/esm/geometry4d/Map4d.d.ts +14 -8
  403. package/lib/esm/geometry4d/Map4d.d.ts.map +1 -1
  404. package/lib/esm/geometry4d/Map4d.js +38 -16
  405. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  406. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  407. package/lib/esm/geometry4d/Matrix4d.js +4 -2
  408. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  409. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  410. package/lib/esm/numerics/Polynomials.d.ts +2 -2
  411. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  412. package/lib/esm/numerics/Polynomials.js +2 -2
  413. package/lib/esm/numerics/Polynomials.js.map +1 -1
  414. package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -6
  415. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  416. package/lib/esm/polyface/PolyfaceBuilder.js +55 -25
  417. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  418. package/lib/esm/polyface/PolyfaceClip.d.ts +16 -7
  419. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  420. package/lib/esm/polyface/PolyfaceClip.js +38 -7
  421. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  422. package/lib/esm/polyface/PolyfaceData.d.ts +5 -39
  423. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  424. package/lib/esm/polyface/PolyfaceData.js +7 -41
  425. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  426. package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -8
  427. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  428. package/lib/esm/polyface/PolyfaceQuery.js +64 -18
  429. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  430. package/lib/esm/serialization/GeometrySamples.d.ts +6 -0
  431. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  432. package/lib/esm/serialization/GeometrySamples.js +68 -2
  433. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  434. package/lib/esm/solid/LinearSweep.d.ts +1 -1
  435. package/lib/esm/solid/LinearSweep.js.map +1 -1
  436. package/lib/esm/solid/RotationalSweep.d.ts +1 -1
  437. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  438. package/lib/esm/solid/RuledSweep.d.ts +1 -1
  439. package/lib/esm/solid/RuledSweep.js.map +1 -1
  440. package/lib/esm/solid/SweepContour.d.ts +35 -26
  441. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  442. package/lib/esm/solid/SweepContour.js +84 -100
  443. package/lib/esm/solid/SweepContour.js.map +1 -1
  444. package/lib/esm/topology/Graph.d.ts +29 -11
  445. package/lib/esm/topology/Graph.d.ts.map +1 -1
  446. package/lib/esm/topology/Graph.js +45 -26
  447. package/lib/esm/topology/Graph.js.map +1 -1
  448. package/lib/esm/topology/HalfEdgeMarkSet.d.ts +2 -2
  449. package/lib/esm/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  450. package/lib/esm/topology/HalfEdgeMarkSet.js +2 -2
  451. package/lib/esm/topology/HalfEdgeMarkSet.js.map +1 -1
  452. package/lib/esm/topology/Merging.d.ts +3 -0
  453. package/lib/esm/topology/Merging.d.ts.map +1 -1
  454. package/lib/esm/topology/Merging.js +19 -5
  455. package/lib/esm/topology/Merging.js.map +1 -1
  456. package/lib/esm/topology/Triangulation.d.ts +15 -7
  457. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  458. package/lib/esm/topology/Triangulation.js +89 -47
  459. package/lib/esm/topology/Triangulation.js.map +1 -1
  460. package/package.json +4 -4
  461. package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
  462. package/lib/cjs/curve/CurveChain.js.map +0 -1
  463. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  464. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  465. package/lib/cjs/curve/CurveCurveCloseApproachXY.js.map +0 -1
  466. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  467. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +0 -1
  468. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  469. package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +0 -1
  470. package/lib/esm/curve/CurveChain.d.ts.map +0 -1
  471. package/lib/esm/curve/CurveChain.js.map +0 -1
  472. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  473. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  474. package/lib/esm/curve/CurveCurveCloseApproachXY.js.map +0 -1
  475. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  476. package/lib/esm/curve/CurveCurveIntersectXY.js.map +0 -1
  477. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  478. package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +0 -1
@@ -8,32 +8,36 @@ exports.CurveCurveCloseApproachXY = void 0;
8
8
  /** @packageDocumentation
9
9
  * @module Curve
10
10
  */
11
- const BSplineCurve_1 = require("../bspline/BSplineCurve");
12
- const Geometry_1 = require("../Geometry");
13
- const GeometryHandler_1 = require("../geometry3d/GeometryHandler");
14
- const GrowableFloat64Array_1 = require("../geometry3d/GrowableFloat64Array");
15
- const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
16
- const Range_1 = require("../geometry3d/Range");
17
- const Polynomials_1 = require("../numerics/Polynomials");
18
- const Arc3d_1 = require("./Arc3d");
19
- const CurveLocationDetail_1 = require("./CurveLocationDetail");
20
- const LineSegment3d_1 = require("./LineSegment3d");
21
- const LineString3d_1 = require("./LineString3d");
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const BSplineCurve_1 = require("../../bspline/BSplineCurve");
13
+ const Geometry_1 = require("../../Geometry");
14
+ const GeometryHandler_1 = require("../../geometry3d/GeometryHandler");
15
+ const GrowableFloat64Array_1 = require("../../geometry3d/GrowableFloat64Array");
16
+ const Point3dVector3d_1 = require("../../geometry3d/Point3dVector3d");
17
+ const Range_1 = require("../../geometry3d/Range");
18
+ const Polynomials_1 = require("../../numerics/Polynomials");
19
+ const Arc3d_1 = require("../Arc3d");
20
+ const CurveChainWithDistanceIndex_1 = require("../CurveChainWithDistanceIndex");
21
+ const CurveCollection_1 = require("../CurveCollection");
22
+ const CurveLocationDetail_1 = require("../CurveLocationDetail");
23
+ const LineSegment3d_1 = require("../LineSegment3d");
24
+ const LineString3d_1 = require("../LineString3d");
22
25
  // cspell:word XYRR
23
26
  /**
24
27
  * Handler class for XY close approach between _geometryB and another geometry.
25
- * * Approach means the distance between _geometryB and another geometry.
26
- * * **NOTE:** GeometryQuery input (_geometryB) should really be AnyCurve.
28
+ * * Approach means the XY distance (z is ignored) between _geometryB and another geometry.
27
29
  * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line
28
30
  * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of
29
31
  * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar
30
- * input curves, rotate them first into a plane parallel to the xy-plane, then afterward, you should rotate the
31
- * results back as required.
32
+ * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the
33
+ * xy-plane, then afterward, rotate the results back as required.
34
+ * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to
35
+ * another curve endpoint.
32
36
  * * Instances are initialized and called from CurveCurve.
33
37
  * * geometryB is saved for later reference.
34
38
  * @internal
35
39
  */
36
- class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
40
+ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometryHandler {
37
41
  setGeometryB(geometryB) {
38
42
  this._geometryB = geometryB;
39
43
  this._circularArcB = undefined;
@@ -46,9 +50,6 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
46
50
  }
47
51
  }
48
52
  }
49
- reinitialize() {
50
- this._results = [];
51
- }
52
53
  /**
53
54
  * Constructor.
54
55
  * @param geometryB second curve for intersection. Saved for reference by specific handler methods.
@@ -57,15 +58,15 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
57
58
  super();
58
59
  this.setGeometryB(geometryB);
59
60
  this._maxDistanceSquared = Geometry_1.Geometry.smallMetricDistanceSquared;
60
- this.reinitialize();
61
+ this._results = [];
61
62
  }
62
- /** Set the (possibly undefined) max distance to accept. */
63
+ /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */
63
64
  set maxDistanceToAccept(value) {
64
65
  this._maxDistanceToAccept = value;
65
66
  if (this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0)
66
67
  this._maxDistanceSquared = this._maxDistanceToAccept * this._maxDistanceToAccept;
67
68
  }
68
- /** Access the (possibly undefined) max distance to accept. */
69
+ /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */
69
70
  get maxDistanceToAccept() {
70
71
  return this._maxDistanceToAccept;
71
72
  }
@@ -92,13 +93,17 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
92
93
  grabPairedResults(reinitialize = false) {
93
94
  const result = this._results;
94
95
  if (reinitialize)
95
- this.reinitialize();
96
+ this._results = [];
96
97
  return result;
97
98
  }
98
99
  /** Returns `true` if `detail` has same curve and fraction. */
99
100
  sameCurveAndFraction(cp, fraction, detail) {
100
101
  return cp === detail.curve && Geometry_1.Geometry.isAlmostEqualNumber(fraction, detail.fraction);
101
102
  }
103
+ /**
104
+ * If distance between pointA and pointB is less than maxDistance, record CurveLocationDetailPair which is
105
+ * the approach from pointA to pointB.
106
+ */
102
107
  testAndRecordPointPairApproach(cpA, fA, pointA, cpB, fB, pointB, reversed) {
103
108
  const d2 = pointA.distanceSquaredXY(pointB);
104
109
  if (d2 < this._maxDistanceSquared) {
@@ -111,12 +116,19 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
111
116
  }
112
117
  }
113
118
  /**
114
- * Compute intersection of two line segments.
115
- * Filter by extension rules.
116
- * Record with fraction mapping.
119
+ * Create a close approach pair if XY distance is within maxDistance.
120
+ * @param localFractionA a fraction on first curve
121
+ * @param cpA the first curve
122
+ * @param fractionA0 start of the first curve
123
+ * @param fractionA1 end of the first curve
124
+ * @param localFractionB a fraction on second curve
125
+ * @param cpB the second curve
126
+ * @param fractionB0 start of the second curve
127
+ * @param fractionB1 end of the second curve
128
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
129
+ * @param intervalDetails optional CurveLocationDetailPair
117
130
  */
118
- recordPointWithLocalFractions(localFractionA, cpA, fractionA0, fractionA1, localFractionB, // Computed intersection fraction
119
- cpB, fractionB0, fractionB1, reversed, intervalDetails) {
131
+ recordPointWithLocalFractions(localFractionA, cpA, fractionA0, fractionA1, localFractionB, cpB, fractionB0, fractionB1, reversed, intervalDetails) {
120
132
  let globalFractionA, globalFractionB;
121
133
  let globalFractionA1, globalFractionB1;
122
134
  const isInterval = intervalDetails !== undefined &&
@@ -132,7 +144,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
132
144
  globalFractionA = globalFractionA1 = Geometry_1.Geometry.interpolate(fractionA0, localFractionA, fractionA1);
133
145
  globalFractionB = globalFractionB1 = Geometry_1.Geometry.interpolate(fractionB0, localFractionB, fractionB1);
134
146
  }
135
- // ignore duplicate of most recent point . ..
147
+ // ignore duplicate of most recent approach
136
148
  const numPrevious = this._results.length;
137
149
  if (numPrevious > 0 && !isInterval) {
138
150
  const oldDetailA = this._results[numPrevious - 1].detailA;
@@ -155,6 +167,9 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
155
167
  detailB.captureFraction1Point1(globalFractionB1, cpB.fractionToPoint(globalFractionB1));
156
168
  }
157
169
  else {
170
+ const d2 = detailA.point.distanceSquaredXY(detailB.point);
171
+ if (d2 > this._maxDistanceSquared)
172
+ return;
158
173
  detailA.setIntervalRole(CurveLocationDetail_1.CurveIntervalRole.isolated);
159
174
  detailB.setIntervalRole(CurveLocationDetail_1.CurveIntervalRole.isolated);
160
175
  }
@@ -167,12 +182,21 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
167
182
  }
168
183
  /**
169
184
  * Capture a close approach pair that has point and local fraction but not curve.
170
- * Record with fraction mapping.
185
+ * * Record the pair, each detail modified with global fraction and input curve.
186
+ * * Pair is neither modified nor recorded if it would be a duplicate of the last recorded pair.
187
+ * @param pair details computed with local fractions
188
+ * @param cpA curveA
189
+ * @param fractionA0 global start fraction on curveA
190
+ * @param fractionA1 global end fraction on curveA
191
+ * @param cpB curveB
192
+ * @param fractionB0 global start fraction on curveB
193
+ * @param fractionB1 global end fraction on curveB
194
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
171
195
  */
172
196
  capturePairWithLocalFractions(pair, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed) {
173
197
  const globalFractionA = Geometry_1.Geometry.interpolate(fractionA0, pair.detailA.fraction, fractionA1);
174
198
  const globalFractionB = Geometry_1.Geometry.interpolate(fractionB0, pair.detailB.fraction, fractionB1);
175
- // ignore duplicate of most recent point . ..
199
+ // ignore duplicate of most recent pair
176
200
  const numPrevious = this._results.length;
177
201
  if (numPrevious > 0) {
178
202
  const oldDetailA = this._results[numPrevious - 1].detailA;
@@ -188,22 +212,21 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
188
212
  return;
189
213
  }
190
214
  }
215
+ // recompute the points just in case
216
+ CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(cpA, globalFractionA, pair.detailA);
217
+ CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(cpB, globalFractionB, pair.detailB);
191
218
  pair.detailA.setIntervalRole(CurveLocationDetail_1.CurveIntervalRole.isolated);
192
219
  pair.detailB.setIntervalRole(CurveLocationDetail_1.CurveIntervalRole.isolated);
193
- if (reversed) {
194
- this._results.push(pair);
195
- }
196
- else {
220
+ if (reversed)
197
221
  pair.swapDetails();
198
- this._results.push(pair);
199
- }
222
+ this._results.push(pair);
200
223
  }
201
224
  /**
202
- * Emit recordPoint for multiple pairs (on full curve!)
225
+ * Emit recordPoint for multiple pairs (on full curve) if within maxDistance.
203
226
  * @param cpA first curve primitive (possibly different from curve in detailA, but fraction compatible)
204
227
  * @param cpB second curve primitive (possibly different from curve in detailA, but fraction compatible)
205
228
  * @param pairs array of pairs
206
- * @param reversed true to have order reversed in final structures.
229
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
207
230
  */
208
231
  recordPairs(cpA, cpB, pairs, reversed) {
209
232
  if (pairs !== undefined) {
@@ -216,49 +239,45 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
216
239
  * Record fully assembled (but possibly reversed) detail pair.
217
240
  * @param detailA first detail
218
241
  * @param detailB second detail
219
- * @param reversed true to have order reversed in final structures.
242
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
220
243
  */
221
244
  captureDetailPair(detailA, detailB, reversed) {
222
245
  if (detailA && detailB) {
223
246
  if (reversed) {
224
- this._results.push(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB));
247
+ this._results.push(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB, detailA));
225
248
  }
226
249
  else {
227
- this._results.push(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB, detailA));
250
+ this._results.push(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB));
228
251
  }
229
252
  }
230
253
  }
231
- static updatePointToSegmentDistance(fractionA, pointA, pointB0, pointB1, fractionB, minDistanceSquared, closestApproach) {
254
+ static updatePointToSegmentDistance(fractionA, pointA, pointB0, pointB1, fractionB, maxDistanceSquared, closestApproach) {
255
+ let updated = false;
232
256
  if (fractionB < 0)
233
257
  fractionB = 0;
234
258
  else if (fractionB > 1)
235
259
  fractionB = 1;
236
260
  this._workPointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);
237
261
  const distanceSquared = this._workPointB.distanceSquaredXY(pointA);
238
- if (distanceSquared < minDistanceSquared) {
239
- if (closestApproach === undefined || distanceSquared < closestApproach.detailA.a) {
240
- if (closestApproach === undefined)
241
- closestApproach = CurveLocationDetail_1.CurveLocationDetailPair.createCapture(CurveLocationDetail_1.CurveLocationDetail.create(), CurveLocationDetail_1.CurveLocationDetail.create());
242
- closestApproach.detailA.setFP(fractionA, pointA);
243
- closestApproach.detailA.a = distanceSquared;
244
- closestApproach.detailB.setFP(fractionB, this._workPointB);
245
- closestApproach.detailA.a = distanceSquared;
246
- }
262
+ if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {
263
+ closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);
264
+ closestApproach.detailB.setFP(fractionB, this._workPointB, undefined, distanceSquared);
265
+ updated = true;
247
266
  }
248
- return closestApproach;
267
+ return updated;
249
268
  }
250
269
  /**
251
- * Return fractions of close approach within minDistance between two line segments (a0,a1) and (b0, b1).
252
- * * minDistanceSquared is assumed positive.
253
- * Return the fractional (not xy) coordinates in result.x, result.y
270
+ * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1).
271
+ * * Math details can be found at core/geometry/internaldocs/Curve.md
254
272
  * @param a0 start point of line a
255
- * @param a1 end point of line a
256
- * @param b0 start point of line b
273
+ * @param a1 end point of line a
274
+ * @param b0 start point of line b
257
275
  * @param b1 end point of line b
258
- * @param result point to receive fractional coordinates of intersection. result.x is fraction on line a. result.y
259
- * is fraction on line b.
276
+ * @param maxDistanceSquared maximum distance squared (assumed to be positive)
277
+ * @returns the fractional (not xy) coordinates in result.x and result.y. result.x is fraction on line a.
278
+ * result.y is fraction on line b.
260
279
  */
261
- static segmentSegmentBoundedApproach(a0, a1, b0, b1, minDistanceSquared) {
280
+ static segmentSegmentBoundedApproach(a0, a1, b0, b1, maxDistanceSquared) {
262
281
  const ux = a1.x - a0.x;
263
282
  const uy = a1.y - a0.y;
264
283
  const vx = b1.x - b0.x;
@@ -269,41 +288,60 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
269
288
  const e01y = b1.y - a0.y;
270
289
  const e10x = b0.x - a1.x;
271
290
  const e10y = b0.y - a1.y;
272
- const e11x = b1.x - a1.x;
273
- const e11y = b1.y - a1.y;
274
291
  const hab0 = Geometry_1.Geometry.crossProductXYXY(ux, uy, e00x, e00y);
275
292
  const hab1 = Geometry_1.Geometry.crossProductXYXY(ux, uy, e01x, e01y);
276
293
  const hba0 = -Geometry_1.Geometry.crossProductXYXY(vx, vy, e00x, e00y);
277
- const hba1 = -Geometry_1.Geometry.crossProductXYXY(vx, vy, e11x, e11y);
278
- if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) {
279
- // true intersection, strictly within both segments !!!
294
+ const hba1 = -Geometry_1.Geometry.crossProductXYXY(vx, vy, e10x, e10y);
295
+ if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) { // true intersection, strictly within both segments
280
296
  const fractionA = -hba0 / (hba1 - hba0);
281
297
  const fractionB = -hab0 / (hab1 - hab0);
282
298
  return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(undefined, fractionA, a0.interpolate(fractionA, a1)), CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(undefined, fractionB, b0.interpolate(fractionB, b1)));
283
299
  }
284
- let closestApproach;
300
+ // there's no intersection, so find the closest approach within maxDistance from an endpoint
301
+ const closestApproach = new CurveLocationDetail_1.CurveLocationDetailPair();
302
+ closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away
303
+ let reversed = false;
285
304
  const uu = Geometry_1.Geometry.hypotenuseSquaredXY(ux, uy);
286
- if (hab0 * hab0 < minDistanceSquared * uu)
287
- closestApproach = this.updatePointToSegmentDistance(0, b0, a0, a1, Geometry_1.Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu, minDistanceSquared, closestApproach);
288
- if (hab1 * hab1 < minDistanceSquared * uu)
289
- closestApproach = this.updatePointToSegmentDistance(1, b1, a0, a1, Geometry_1.Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu, minDistanceSquared, closestApproach);
305
+ if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u
306
+ const fractionA = Geometry_1.Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu;
307
+ if (this.updatePointToSegmentDistance(0, b0, a0, a1, fractionA, maxDistanceSquared, closestApproach))
308
+ reversed = true;
309
+ }
310
+ if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u
311
+ const fractionA = Geometry_1.Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu;
312
+ if (this.updatePointToSegmentDistance(1, b1, a0, a1, fractionA, maxDistanceSquared, closestApproach))
313
+ reversed = true;
314
+ }
290
315
  const vv = Geometry_1.Geometry.hypotenuseSquaredXY(vx, vy);
291
- if (hba0 * hba0 < minDistanceSquared * vv)
292
- closestApproach = this.updatePointToSegmentDistance(0, a0, b0, b1, -Geometry_1.Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv, minDistanceSquared, closestApproach);
293
- if (hba1 * hba1 < minDistanceSquared * vv)
294
- closestApproach = this.updatePointToSegmentDistance(1, a1, b0, b1, -Geometry_1.Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv, minDistanceSquared, closestApproach);
316
+ if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v
317
+ const fractionB = -Geometry_1.Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv;
318
+ if (this.updatePointToSegmentDistance(0, a0, b0, b1, fractionB, maxDistanceSquared, closestApproach))
319
+ reversed = false;
320
+ }
321
+ if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v
322
+ const fractionB = -Geometry_1.Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv;
323
+ if (this.updatePointToSegmentDistance(1, a1, b0, b1, fractionB, maxDistanceSquared, closestApproach))
324
+ reversed = false;
325
+ }
326
+ if (closestApproach.detailA.a > maxDistanceSquared)
327
+ return undefined;
328
+ if (reversed)
329
+ closestApproach.swapDetails();
295
330
  return closestApproach;
296
331
  }
297
332
  /**
298
- * Return fractions of close approach within minDistance between two line segments( a0,a1) and (b0, b1)
299
- * * minDistance is assumed positive
300
- * Return the fractional (not xy) coordinates in result.x, result.y
301
- * @param a0 start point of line a
302
- * @param a1 end point of line a
303
- * @param b0 start point of line b
304
- * @param b1 end point of line b
305
- * @param result point to receive fractional coordinates of intersection. result.x is fraction on line a. result.y
306
- * is fraction on line b.
333
+ * Check different combination of fractions on curveA and curveB. If distance between points at 2 fractions
334
+ * is less than maxDistance, record CurveLocationDetailPair which is the approach between the 2 points.
335
+ * Optionally, record close approaches of one curve's points if they fall between the other curve's points.
336
+ * @param cpA curveA
337
+ * @param fA0 fraction0 on curveA
338
+ * @param fA1 fraction1 on curveA
339
+ * @param testProjectionOnA whether to record projections of the given curveB points onto curveA
340
+ * @param cpB curveB
341
+ * @param fB0 fraction0 on curveB
342
+ * @param fB1 fraction0 on curveB
343
+ * @param testProjectionOnB whether to record projections of the given curveA points onto curveB
344
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
307
345
  */
308
346
  testAndRecordFractionalPairApproach(cpA, fA0, fA1, testProjectionOnA, cpB, fB0, fB1, testProjectionOnB, reversed) {
309
347
  const pointA0 = cpA.fractionToPoint(fA0);
@@ -323,12 +361,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
323
361
  this.testAndRecordProjection(cpB, fB1, pointB1, cpA, fA0, fA1, !reversed);
324
362
  }
325
363
  }
364
+ /** Find the closest approach between pointA and cpB. Add the approach if it's within fB0 and fB1. */
326
365
  testAndRecordProjection(cpA, fA, pointA, cpB, fB0, fB1, reversed) {
327
366
  // NO NO NO -- this is 3D closest point --- need 2d !!
328
367
  const detail = cpB.closestPoint(pointA, false);
329
368
  if (detail) {
330
369
  const fB = Geometry_1.Geometry.restrictToInterval(detail.fraction, fB0, fB1);
331
- if (fB === detail.fraction) {
370
+ if (fB === detail.fraction) { // if fraction is within fB0 and fB1
332
371
  this.testAndRecordPointPairApproach(cpA, fA, pointA, cpB, detail.fraction, detail.point, reversed);
333
372
  }
334
373
  }
@@ -340,53 +379,73 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
340
379
  * * The fraction mappings allow portions of a linestring to be passed here.
341
380
  */
342
381
  computeSegmentSegment3D(cpA, pointA0, fractionA0, pointA1, fractionA1, cpB, pointB0, fractionB0, pointB1, fractionB1, reversed) {
382
+ // compute a pair with fractions local to segments
343
383
  const approach = CurveCurveCloseApproachXY.segmentSegmentBoundedApproach(pointA0, pointA1, pointB0, pointB1, this._maxDistanceSquared);
344
- if (approach)
384
+ // adjust the pair to refer to input curves and global fractions, then record it if new
385
+ if (approach) {
386
+ approach.detailA.setCurve(cpA);
387
+ approach.detailB.setCurve(cpB);
345
388
  this.capturePairWithLocalFractions(approach, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed);
389
+ }
346
390
  }
347
- // Caller accesses data from a line segment and passes to here.
348
- // (The line segment in question might be (a) a full line segment or (b) a fragment within a linestring.
349
- // The fraction and extend parameters allow all combinations to be passed in)
350
- // This method applies transform.
391
+ /** Low level dispatch of segment with segment. */
351
392
  dispatchSegmentSegment(cpA, pointA0, fractionA0, pointA1, fractionA1, cpB, pointB0, fractionB0, pointB1, fractionB1, reversed) {
352
393
  this.computeSegmentSegment3D(cpA, pointA0, fractionA0, pointA1, fractionA1, cpB, pointB0, fractionB0, pointB1, fractionB1, reversed);
353
394
  }
354
- // Caller accesses data from a linestring or segment and passes it here.
355
- // (The line segment in question might be (a) a full line segment or (b) a fragment within a linestring.
356
- // The fraction and extend parameters allow all combinations to be passed in)
395
+ /**
396
+ * Low level dispatch of segment with arc.
397
+ * Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.
398
+ * To consider:
399
+ * 1) intersection between arc and segment.
400
+ * 2) arc endpoints to segment endpoints or arc endpoints projection to the segment.
401
+ * 3) line parallel to arc tangent.
402
+ * @param cpA curve A (line segment or line string)
403
+ * @param pointA0 start point of the segment
404
+ * @param fractionA0 fraction of the start of the segment
405
+ * @param pointA1 end point of the segment
406
+ * @param fractionA1 fraction of the end of the segment
407
+ * @param arc the arc
408
+ * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
409
+ */
357
410
  dispatchSegmentArc(cpA, pointA0, fractionA0, pointA1, fractionA1, arc, reversed) {
358
- // To consider:
359
- // 1) endpoint to endpoint or projection
360
- // 2) true intersection
361
- // 3) line parallel to arc tangent.
362
- this.testAndRecordFractionalPairApproach(cpA, 0, 1, true, arc, 0, 1, false, reversed);
363
- // Arc: X = C + cU + sV
364
- // Line: contains points A0,A1
365
- // Arc point colinear with line if det (A0, A1, X) = 0
366
- // with homogeneous xyw points and vectors.
367
- // With equational X: det (A0, A1, C) + c det (A0, A1,U) + s det (A0, A1, V) = 0.
411
+ // 1) intersection between arc and segment
412
+ // Suppose:
413
+ // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)
414
+ // Line: contains points A0 and A1
415
+ // The arc intersects the line at point X if det(A0, A1, X) = 0 with homogeneous xyw points and vectors.
416
+ // With equational X: det(A0, A1, C) + c*det(A0, A1, U) + s*det(A0, A1, V) = 0.
368
417
  // solve for theta.
369
418
  // evaluate points.
370
419
  // project back to line.
420
+ let intersectionFound = false;
371
421
  const data = arc.toTransformedVectors();
372
422
  const pointA0Local = pointA0;
373
423
  const pointA1Local = pointA1;
374
- const alpha = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.center, 1);
375
- const beta = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector0, 0);
376
- const gamma = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector90, 0);
424
+ const alpha = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.center, 1); // det(A0, A1, C)
425
+ const beta = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector0, 0); // det(A0, A1, U)
426
+ const gamma = Geometry_1.Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector90, 0); // det(A0, A1, V)
377
427
  const cosines = new GrowableFloat64Array_1.GrowableFloat64Array(2);
378
428
  const sines = new GrowableFloat64Array_1.GrowableFloat64Array(2);
379
429
  const radians = new GrowableFloat64Array_1.GrowableFloat64Array(2);
380
- const numRoots = Polynomials_1.AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians);
430
+ const numRoots = Polynomials_1.AnalyticRoots.appendImplicitLineUnitCircleIntersections(// solve the equation
431
+ alpha, beta, gamma, cosines, sines, radians);
381
432
  for (let i = 0; i < numRoots; i++) {
382
433
  const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));
383
434
  const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians.atUncheckedIndex(i));
384
435
  const lineFraction = Polynomials_1.SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);
436
+ // only add if the point is within the start and end fractions of both line segment and arc
385
437
  if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {
386
438
  this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
439
+ intersectionFound = true;
387
440
  }
388
441
  }
389
- // line parallel to arc tangent.
442
+ if (intersectionFound)
443
+ return;
444
+ // 2) endpoints to endpoints or endpoints projection to the other curve
445
+ this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, false, reversed);
446
+ // 3) line parallel to arc tangent.
447
+ // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a
448
+ // point where the tangent line on arc at that point is parallel to the line.
390
449
  const dotUT = data.vector0.crossProductStartEndXY(pointA0, pointA1);
391
450
  const dotVT = data.vector90.crossProductStartEndXY(pointA0, pointA1);
392
451
  const parallelRadians = Math.atan2(dotVT, dotUT);
@@ -394,53 +453,43 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
394
453
  const arcPoint = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));
395
454
  const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians1);
396
455
  const lineFraction = Polynomials_1.SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);
456
+ // only add if the point is within the start and end fractions of both line segment and arc
397
457
  if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {
398
458
  this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
399
459
  }
400
460
  }
401
461
  }
402
- // Caller accesses data from two arcs, ensures circular, and orders with radiusA >= radiusB
462
+ /** Low level dispatch of circular arc with circular arc. radiusA must be larger than or equal to radiusB. */
403
463
  dispatchCircularCircularOrdered(cpA, radiusA, cpB, radiusB, reversed) {
404
464
  const c = cpA.center.distance(cpB.center);
405
465
  const e = this._maxDistanceToAccept !== undefined ? this._maxDistanceToAccept : Geometry_1.Geometry.smallMetricDistance;
406
- if (c > radiusA + radiusB + e) // widely separated
466
+ if (c > radiusA + radiusB + e) // distance between circles is more than max distance
407
467
  return;
408
- // To consider:
409
- // 1) endpoint to endpoint or projection
410
- // 2) true intersection
411
- // 3) line parallel to arc tangent.
468
+ // TODO: 1) intersection between arcs
469
+ // 2) endpoints to endpoints
412
470
  this.testAndRecordFractionalPairApproach(cpA, 0, 1, false, cpB, 0, 1, false, reversed);
471
+ // 3) line from one arc to another (perpendicular to arc tangents along center-center line)
413
472
  if (!Geometry_1.Geometry.isSmallMetricDistance(c)) {
414
- // ?? endpoint hits are recorded. Maybe also need overlap?
415
473
  const vectorAB = Point3dVector3d_1.Vector3d.createStartEnd(cpA.center, cpB.center);
416
474
  vectorAB.scaleInPlace(1.0 / c);
417
- if (c - radiusA - radiusB > e) {
418
- // no approaches possible
419
- }
420
- else {
421
- for (const rA of [-radiusA, radiusA]) {
422
- for (const rB of [-radiusB, radiusB]) {
423
- const tangentDistance = c - rA + rB;
424
- if (tangentDistance < e) {
425
- const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
426
- if (detailA) {
427
- const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
428
- if (detailB) {
429
- this.captureDetailPair(detailA, detailB, reversed);
430
- }
431
- }
475
+ for (const rA of [-radiusA, radiusA]) {
476
+ for (const rB of [-radiusB, radiusB]) {
477
+ const tangentDistance = c - rA + rB;
478
+ if (tangentDistance < e) {
479
+ const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
480
+ if (detailA) {
481
+ const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
482
+ if (detailB)
483
+ this.captureDetailPair(detailA, detailB, reversed);
432
484
  }
433
485
  }
434
486
  }
435
487
  }
436
488
  }
437
489
  }
438
- /**
439
- * Find the fractional point (if any) on an arc, known to be circular and displayed from the center in the
440
- * direction of a scaled vector.
441
- */
490
+ /** Find the fractional point (if any) on the circular `arc` in the direction of `radialVector`. */
442
491
  resolveDirectionToArcXYFraction(arc, radialVector, scale) {
443
- // The scale ultimately only affects the direction --- easiest way to use it is two multiplies
492
+ // The scale ultimately only affects the direction --- easiest way to use it is two multiplies.
444
493
  const c = scale * arc.matrixRef.columnDotXYZ(0, radialVector.x, radialVector.y, 0);
445
494
  const s = scale * arc.matrixRef.columnDotXYZ(1, radialVector.x, radialVector.y, 0);
446
495
  const radians = Math.atan2(s, c);
@@ -449,10 +498,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
449
498
  return CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(arc, fraction);
450
499
  return undefined;
451
500
  }
452
- // Caller accesses data from two arcs.
453
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
454
- // Solves the arc-arc equations
501
+ /** Low level dispatch of arc with arc. Only circular arcs are supported. */
455
502
  dispatchArcArc(cpA, cpB, reversed) {
503
+ const rangeA = cpA.range();
504
+ const rangeB = cpB.range();
505
+ rangeA.expandInPlace(this._maxDistanceToAccept);
506
+ if (!rangeB.intersectsRangeXY(rangeA))
507
+ return;
456
508
  if (this._circularArcB) {
457
509
  const radiusB = this._circularRadiusB;
458
510
  const radiusA = cpA.circularRadiusXY();
@@ -465,17 +517,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
465
517
  }
466
518
  }
467
519
  }
468
- // Caller accesses data from two arcs.
469
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
470
- // Solves the arc-arc equations
520
+ /** Low level dispatch of arc with (beziers of) a bspline curve */
471
521
  dispatchArcBsplineCurve3d(cpA, cpB, reversed) {
472
522
  const ls = LineString3d_1.LineString3d.create();
473
523
  cpB.emitStrokes(ls);
474
524
  this.computeArcLineString(cpA, ls, reversed);
475
525
  }
476
- // Caller accesses data from two arcs.
477
- // Selects the best conditioned arc (in xy parts) as "circle after inversion"
478
- // Solves the arc-arc equations
526
+ /** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */
479
527
  dispatchBSplineCurve3dBSplineCurve3d(bcurveA, bcurveB, reversed) {
480
528
  const lsA = LineString3d_1.LineString3d.create();
481
529
  bcurveA.emitStrokes(lsA);
@@ -490,66 +538,34 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
490
538
  this.computeLineStringLineString(lsA, lsB, reversed);
491
539
  }
492
540
  /** Low level dispatch of segment with (beziers of) a bspline curve */
493
- dispatchSegmentBsplineCurve(lsA, curveB, reversed) {
541
+ dispatchSegmentBsplineCurve(segA, curveB, reversed) {
494
542
  const lsB = LineString3d_1.LineString3d.create();
495
543
  curveB.emitStrokes(lsB);
496
- this.computeSegmentLineString(lsA, lsB, reversed);
544
+ this.computeSegmentLineString(segA, lsB, reversed);
497
545
  }
498
546
  /** Detail computation for segment approaching linestring. */
499
- computeSegmentLineString(lsA, lsB, reversed) {
500
- const pointA0 = lsA.point0Ref;
501
- const pointA1 = lsA.point1Ref;
502
- let pointB0 = CurveCurveCloseApproachXY._workPointBB0;
503
- let pointB1 = CurveCurveCloseApproachXY._workPointBB1;
504
- let pointB2 = CurveCurveCloseApproachXY._workPointBB2;
505
- let cross0, cross1, cross2;
506
- let dot0, dot1, dot2;
507
- const vectorA = CurveCurveCloseApproachXY._workVectorA;
508
- Point3dVector3d_1.Vector3d.createStartEnd(pointA0, pointA1, vectorA);
509
- const aa = vectorA.magnitudeSquared();
547
+ computeSegmentLineString(segA, lsB, reversed) {
510
548
  const numB = lsB.numPoints();
511
- lsB.packedPoints.getPoint3dAtUncheckedPointIndex(0, pointB0);
512
- lsB.packedPoints.getPoint3dAtUncheckedPointIndex(1, pointB0);
513
- cross0 = vectorA.crossProductStartEndXY(pointA0, pointB0);
514
- cross1 = vectorA.crossProductStartEndXY(pointA0, pointB0);
515
- dot0 = vectorA.dotProductStartEndXY(pointA0, pointB0);
516
- dot1 = vectorA.dotProductStartEndXY(pointA0, pointB1);
517
- for (let iB = 2; iB < numB; iB++) {
518
- // project point B[iB] to segmentA. If within limits, see if it is a local minimum distance . . .
519
- lsB.packedPoints.getPoint3dAtUncheckedPointIndex(iB, pointB1);
520
- cross2 = vectorA.crossProductStartEndXY(pointA0, pointB0);
521
- dot2 = vectorA.dotProductStartEndXY(pointA0, pointB2);
522
- if ((cross0 - cross1) * (cross2 - cross1) <= 0.0) {
523
- // There is a true minimum at point1 ... see if it is within the line
524
- if (dot1 >= 0.0 && dot1 <= aa) {
525
- const fractionA1 = dot1 / aa;
526
- const projection = pointA0.interpolate(dot1 / aa, pointA1);
527
- if (pointB1.distanceXY(projection) < this._maxDistanceToAccept) {
528
- const detailA = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(lsA, fractionA1, projection);
529
- const detailB = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(lsB, iB / (numB - 1), pointB2);
530
- const pair = CurveLocationDetail_1.CurveLocationDetailPair.createCaptureOptionalReverse(detailA, detailB, reversed);
531
- this._results.push(pair);
532
- }
533
- }
534
- }
535
- const tempPoint = pointB0;
536
- pointB0 = pointB1;
537
- pointB1 = pointB2;
538
- pointB2 = tempPoint;
539
- const tempCross = cross0;
540
- cross0 = cross1;
541
- cross1 = cross2;
542
- cross2 = tempCross;
543
- const tempDot = dot0;
544
- dot0 = dot1;
545
- dot1 = dot2;
546
- dot2 = tempDot;
547
- }
548
- this.testAndRecordFractionalPairApproach(lsA, 0, 1, true, lsB, 0, 1, false, reversed);
549
- return undefined;
549
+ const deltaFracB = Geometry_1.Geometry.safeDivideFraction(1, numB - 1, 0);
550
+ const pointA0 = segA.point0Ref;
551
+ const pointA1 = segA.point1Ref;
552
+ const pointB0 = CurveCurveCloseApproachXY._workPointBB0;
553
+ const pointB1 = CurveCurveCloseApproachXY._workPointBB1;
554
+ for (let i = 0; i < numB - 1; ++i) {
555
+ const fB0 = i * deltaFracB; // global linestring fractions
556
+ const fB1 = (i + 1 === numB - 1) ? 1.0 : (i + 1) * deltaFracB; // make sure we nail the end fraction
557
+ lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i, pointB0);
558
+ lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i + 1, pointB1);
559
+ this.dispatchSegmentSegment(segA, pointA0, 0.0, pointA1, 1.0, lsB, pointB0, fB0, pointB1, fB1, reversed);
560
+ }
550
561
  }
551
562
  /** Detail computation for arc approaching linestring. */
552
563
  computeArcLineString(arcA, lsB, reversed) {
564
+ const rangeA = arcA.range();
565
+ const rangeB = lsB.range();
566
+ rangeA.expandInPlace(this._maxDistanceToAccept);
567
+ if (!rangeB.intersectsRangeXY(rangeA))
568
+ return;
553
569
  const pointB0 = CurveCurveCloseApproachXY._workPointBB0;
554
570
  const pointB1 = CurveCurveCloseApproachXY._workPointBB1;
555
571
  const numB = lsB.numPoints();
@@ -567,6 +583,50 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
567
583
  }
568
584
  return undefined;
569
585
  }
586
+ /** Low level dispatch of curve collection. */
587
+ dispatchCurveCollection(geomA, geomAHandler) {
588
+ const geomB = this._geometryB; // save
589
+ if (!geomB || !geomB.children || !(geomB instanceof CurveCollection_1.CurveCollection))
590
+ return;
591
+ for (const child of geomB.children) {
592
+ this.resetGeometry(child);
593
+ geomAHandler(geomA);
594
+ }
595
+ this._geometryB = geomB; // restore
596
+ }
597
+ /**
598
+ * Given a parent chain, convert the corresponding child details so that they refer to the chain's global parameterization.
599
+ * * It is assumed that `this._results[i].detailA.curve` is a child of chainA, and similarly for detailB/chainB.
600
+ * @param chainA convert each detailA to the global parameterization of chainA
601
+ * @param chainB convert each detailB to the global parameterization of chainB
602
+ */
603
+ convertChildDetailToChainDetail(chainA, chainB) {
604
+ for (const childDetailPair of this._results) {
605
+ if (chainA) {
606
+ const chainDetail = chainA.computeChainDetail(childDetailPair.detailA);
607
+ if (chainDetail)
608
+ childDetailPair.detailA = chainDetail;
609
+ }
610
+ if (chainB) {
611
+ const chainDetail = chainB.computeChainDetail(childDetailPair.detailB);
612
+ if (chainDetail)
613
+ childDetailPair.detailB = chainDetail;
614
+ }
615
+ }
616
+ }
617
+ /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */
618
+ dispatchCurveChainWithDistanceIndex(geomA, geomAHandler) {
619
+ if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex))
620
+ return;
621
+ const geomB = this._geometryB; // save
622
+ for (const child of geomB.path.children) {
623
+ this.resetGeometry(child);
624
+ geomAHandler(geomA);
625
+ }
626
+ this.resetGeometry(geomB); // restore
627
+ (0, core_bentley_1.assert)(!(geomA instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex));
628
+ this.convertChildDetailToChainDetail(undefined, geomB);
629
+ }
570
630
  /** Double dispatch handler for strongly typed segment. */
571
631
  handleLineSegment3d(segmentA) {
572
632
  if (this._geometryB instanceof LineSegment3d_1.LineSegment3d) {
@@ -582,6 +642,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
582
642
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
583
643
  this.dispatchSegmentBsplineCurve(segmentA, this._geometryB, false);
584
644
  }
645
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
646
+ this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));
647
+ }
648
+ else if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
649
+ this.dispatchCurveChainWithDistanceIndex(segmentA, this.handleLineSegment3d.bind(this));
650
+ }
651
+ return undefined;
585
652
  }
586
653
  /**
587
654
  * Set bits for comparison to range xy
@@ -589,6 +656,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
589
656
  * * bit 0x02 => x larger than range.high.x
590
657
  * * bit 0x04 => y smaller than range.low.y
591
658
  * * bit 0x08 => y larger than range.high.y
659
+ * * If we divide XY plane into 9 areas using the range, the function returns 0 for points
660
+ * inside the range. Below is other binary numbers returned by the function for all 9 areas:
661
+ * 1001 | 1000 | 1010
662
+ * ------------------
663
+ * 1 | 0 | 10
664
+ * ------------------
665
+ * 101 | 100 | 110
592
666
  * @param xy point to test
593
667
  * @param range range for comparison
594
668
  */
@@ -598,12 +672,14 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
598
672
  result = 0x01;
599
673
  else if (x > range.high.x)
600
674
  result = 0x02;
675
+ // note the OR operation
601
676
  if (y < range.low.y)
602
677
  result |= 0x04;
603
678
  else if (y > range.high.y)
604
679
  result |= 0x08;
605
680
  return result;
606
681
  }
682
+ /** Low level dispatch of line string with line string. */
607
683
  computeLineStringLineString(lsA, lsB, reversed) {
608
684
  const rangeA = lsA.range();
609
685
  const rangeB = lsB.range();
@@ -620,7 +696,6 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
620
696
  const numA = lsA.numPoints();
621
697
  const numB = lsB.numPoints();
622
698
  if (numA > 1 && numB > 1) {
623
- lsA.pointAt(0, pointA0);
624
699
  const dfA = 1.0 / (numA - 1);
625
700
  const dfB = 1.0 / (numB - 1);
626
701
  let fA0 = 0.0;
@@ -630,6 +705,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
630
705
  fA1 = ia * dfA;
631
706
  fB0 = 0.0;
632
707
  lsA.pointAt(ia, pointA1);
708
+ // rangeA1 is around line segment [A0,A1] expanded by max distance
633
709
  rangeA1.setNull();
634
710
  rangeA1.extendPoint(pointA0);
635
711
  rangeA1.extendPoint(pointA1);
@@ -641,10 +717,10 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
641
717
  lsB.pointAt(ib, pointB1);
642
718
  bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);
643
719
  fB1 = ib * dfB;
644
- // Do NOT study the segment in detail if both bitB bits are on for any of the 4 planes . ..
645
- if ((bitB0 & bitB1) === 0) {
720
+ // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes
721
+ // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])
722
+ if ((bitB0 & bitB1) === 0)
646
723
  this.dispatchSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);
647
- }
648
724
  }
649
725
  }
650
726
  }
@@ -665,6 +741,12 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
665
741
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
666
742
  this.dispatchLineStringBSplineCurve(lsA, this._geometryB, false);
667
743
  }
744
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
745
+ this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));
746
+ }
747
+ else if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
748
+ this.dispatchCurveChainWithDistanceIndex(lsA, this.handleLineString3d.bind(this));
749
+ }
668
750
  return undefined;
669
751
  }
670
752
  /** Double dispatch handler for strongly typed arc. */
@@ -681,6 +763,12 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
681
763
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3d) {
682
764
  this.dispatchArcBsplineCurve3d(arc0, this._geometryB, false);
683
765
  }
766
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
767
+ this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));
768
+ }
769
+ else if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
770
+ this.dispatchCurveChainWithDistanceIndex(arc0, this.handleArc3d.bind(this));
771
+ }
684
772
  return undefined;
685
773
  }
686
774
  /** Double dispatch handler for strongly typed bspline curve. */
@@ -697,8 +785,19 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.NullGeometryHandler {
697
785
  else if (this._geometryB instanceof BSplineCurve_1.BSplineCurve3dBase) {
698
786
  this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);
699
787
  }
788
+ else if (this._geometryB instanceof CurveCollection_1.CurveCollection) {
789
+ this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));
790
+ }
791
+ else if (this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex) {
792
+ this.dispatchCurveChainWithDistanceIndex(curve, this.handleBSplineCurve3d.bind(this));
793
+ }
700
794
  return undefined;
701
795
  }
796
+ /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */
797
+ handleCurveChainWithDistanceIndex(chain) {
798
+ super.handleCurveChainWithDistanceIndex(chain);
799
+ this.convertChildDetailToChainDetail(chain, this._geometryB instanceof CurveChainWithDistanceIndex_1.CurveChainWithDistanceIndex ? this._geometryB : undefined);
800
+ }
702
801
  /** Double dispatch handler for strongly typed homogeneous bspline curve .. */
703
802
  handleBSplineCurve3dH(_curve) {
704
803
  /*
@@ -721,8 +820,6 @@ CurveCurveCloseApproachXY._workPointAA0 = Point3dVector3d_1.Point3d.create();
721
820
  CurveCurveCloseApproachXY._workPointAA1 = Point3dVector3d_1.Point3d.create();
722
821
  CurveCurveCloseApproachXY._workPointBB0 = Point3dVector3d_1.Point3d.create();
723
822
  CurveCurveCloseApproachXY._workPointBB1 = Point3dVector3d_1.Point3d.create();
724
- CurveCurveCloseApproachXY._workPointBB2 = Point3dVector3d_1.Point3d.create();
725
- CurveCurveCloseApproachXY._workVectorA = Point3dVector3d_1.Vector3d.create();
726
823
  CurveCurveCloseApproachXY._workPointB = Point3dVector3d_1.Point3d.create();
727
824
  exports.CurveCurveCloseApproachXY = CurveCurveCloseApproachXY;
728
825
  //# sourceMappingURL=CurveCurveCloseApproachXY.js.map