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

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