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