flo-mat 4.1.5 → 5.0.2

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 (356) hide show
  1. package/__tests__/closest-boundary-point/get-endpoint-info.spec.ts +140 -0
  2. package/__tests__/closest-boundary-point/root-interval-to-distance-squared-interval.spec.ts +87 -0
  3. package/__tests__/cp-node/fs/get-all-on-loop-by-loop.spec.ts +55 -0
  4. package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +39 -3
  5. package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +87 -3
  6. package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +68 -3
  7. package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +41 -3
  8. package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +20 -3
  9. package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +42 -3
  10. package/__tests__/cp-node/fs/get-branch.spec.ts +60 -3
  11. package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +19 -3
  12. package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +37 -4
  13. package/__tests__/cp-node/fs/get-edge-direction.spec.ts +50 -3
  14. package/__tests__/cp-node/fs/get-first-exit.spec.ts +78 -3
  15. package/__tests__/cp-node/fs/get-hole-closers.spec.ts +32 -3
  16. package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +48 -3
  17. package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +77 -3
  18. package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +17 -4
  19. package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +38 -3
  20. package/__tests__/cp-node/fs/get-salience.spec.ts +68 -3
  21. package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +40 -3
  22. package/__tests__/cp-node/fs/insert-cp-node.spec.ts +87 -3
  23. package/__tests__/cp-node/fs/is-special.spec.ts +1 -1
  24. package/__tests__/cp-node/fs/remove-cp-node.spec.ts +42 -3
  25. package/__tests__/find-2-prong/calc-seperation-tolerance.spec.ts +46 -0
  26. package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +1 -1
  27. package/__tests__/floyd-warshall/get-graph.spec.ts +100 -0
  28. package/__tests__/get-mats-with-hole.ts +28 -0
  29. package/__tests__/get-mats1.spec.ts +61 -0
  30. package/__tests__/get-mats1.ts +75 -67
  31. package/__tests__/helpers/cp-node-by-id.ts +27 -0
  32. package/__tests__/helpers/expect-point-close.ts +42 -0
  33. package/__tests__/mat/hausdorff-distance-one-sided-exceeds.spec.ts +129 -0
  34. package/__tests__/mat/simplify-mat.spec.ts +85 -0
  35. package/__tests__/reconstruct-from-mat/reconstruct-from-mat.spec.ts +39 -0
  36. package/__tests__/specific-cases/test-svgs/achispado.svg +14 -0
  37. package/__tests__/utils/get-beziers-from-tangents.spec.ts +142 -0
  38. package/browser/index.js +12985 -9965
  39. package/browser/index.min.js +1 -1
  40. package/node/closest-boundary-point/cull-curve-pieces.d.ts +21 -0
  41. package/node/closest-boundary-point/cull-curve-pieces.js +40 -0
  42. package/node/closest-boundary-point/cull-curve-pieces.js.map +1 -0
  43. package/node/closest-boundary-point/get-close-boundary-points-certified.js +5 -2
  44. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  45. package/node/closest-boundary-point/get-endpoint-info.d.ts +39 -0
  46. package/node/closest-boundary-point/get-endpoint-info.js +78 -0
  47. package/node/closest-boundary-point/get-endpoint-info.js.map +1 -0
  48. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +5 -19
  49. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
  50. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +17 -5
  51. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +37 -50
  52. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
  53. package/node/corner/get-corner.d.ts +18 -1
  54. package/node/corner/get-corner.js +8 -1
  55. package/node/corner/get-corner.js.map +1 -1
  56. package/node/corner/get-interface-ccw.js.map +1 -1
  57. package/node/cp-node/cp-node.d.ts +4 -3
  58. package/node/cp-node/fs/get-all-on-loop-by-loop.js +0 -4
  59. package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -1
  60. package/node/cp-node/fs/get-angle-between-mat-curves.js +6 -4
  61. package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
  62. package/node/cp-node/fs/get-boundary-beziers-between.d.ts +6 -4
  63. package/node/cp-node/fs/get-boundary-beziers-between.js +6 -4
  64. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  65. package/node/cp-node/fs/get-branch-beziers.d.ts +2 -1
  66. package/node/cp-node/fs/get-branch-beziers.js +3 -2
  67. package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
  68. package/node/cp-node/fs/get-branch.js +1 -2
  69. package/node/cp-node/fs/get-branch.js.map +1 -1
  70. package/node/cp-node/fs/get-distance-to-next.js +4 -2
  71. package/node/cp-node/fs/get-distance-to-next.js.map +1 -1
  72. package/node/cp-node/fs/get-first-exit.d.ts +7 -3
  73. package/node/cp-node/fs/get-first-exit.js +13 -11
  74. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  75. package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +9 -1
  76. package/node/cp-node/fs/get-implied-boundary-bezier-between.js +11 -55
  77. package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
  78. package/node/cp-node/fs/get-mat-curve-between.d.ts +4 -3
  79. package/node/cp-node/fs/get-mat-curve-between.js +5 -49
  80. package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
  81. package/node/cp-node/fs/get-mat-curve-to-next.d.ts +1 -1
  82. package/node/cp-node/fs/get-mat-curves-between.d.ts +8 -0
  83. package/node/cp-node/fs/get-mat-curves-between.js +9 -2
  84. package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
  85. package/node/cp-node/fs/get-real-prong-count.d.ts +2 -1
  86. package/node/cp-node/fs/get-real-prong-count.js +11 -5
  87. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  88. package/node/cp-node/fs/get-salience.d.ts +10 -0
  89. package/node/cp-node/fs/get-salience.js +17 -1
  90. package/node/cp-node/fs/get-salience.js.map +1 -1
  91. package/node/cp-node/fs/is-fully-terminating.d.ts +4 -2
  92. package/node/cp-node/fs/is-fully-terminating.js +6 -15
  93. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  94. package/node/cp-node/fs/is-on-same-loop.d.ts +1 -1
  95. package/node/cp-node/fs/is-special.d.ts +7 -0
  96. package/node/cp-node/fs/is-special.js +9 -2
  97. package/node/cp-node/fs/is-special.js.map +1 -1
  98. package/node/cp-node/fs/is-vertex.d.ts +1 -1
  99. package/node/cp-node/fs/traverse-edges.d.ts +7 -3
  100. package/node/cp-node/fs/traverse-edges.js +7 -3
  101. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  102. package/node/cp-node/stringification/from-stringifyable.d.ts +2 -2
  103. package/node/cp-node/stringification/from-stringifyable.js +1 -1
  104. package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
  105. package/node/cp-node/stringification/to-stringifyable.d.ts +3 -3
  106. package/node/cp-node/stringification/to-stringifyable.js +3 -3
  107. package/node/debug/debug.d.ts +26 -3
  108. package/node/debug/debug.js +16 -5
  109. package/node/debug/debug.js.map +1 -1
  110. package/node/find-2-prong/add-2-prong.js +1 -7
  111. package/node/find-2-prong/add-2-prong.js.map +1 -1
  112. package/node/find-2-prong/calc-seperation-tolerance.d.ts +28 -5
  113. package/node/find-2-prong/calc-seperation-tolerance.js +32 -89
  114. package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
  115. package/node/find-2-prong/find-2-prong.js +8 -10
  116. package/node/find-2-prong/find-2-prong.js.map +1 -1
  117. package/node/find-2-prong/find-and-add-2-prongs.js +2 -2
  118. package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
  119. package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -2
  120. package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -3
  121. package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
  122. package/node/find-2-prong/get-medial/get-closest-points.d.ts +1 -8
  123. package/node/find-2-prong/get-medial/get-closest-points.js +4 -40
  124. package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
  125. package/node/find-2-prong/reduce-radius.d.ts +1 -1
  126. package/node/find-2-prong/reduce-radius.js +6 -3
  127. package/node/find-2-prong/reduce-radius.js.map +1 -1
  128. package/node/find-3-prong/calc-better-x.js +1 -1
  129. package/node/find-3-prong/calc-better-x.js.map +1 -1
  130. package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +3 -2
  131. package/node/find-3-prong/find-3-prong-for-delta3s.js +35 -41
  132. package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
  133. package/node/find-3-prong/find-3-prong.js +3 -1
  134. package/node/find-3-prong/find-3-prong.js.map +1 -1
  135. package/node/find-3-prong/find-and-add-3-prongs.js +16 -0
  136. package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
  137. package/node/find-mat/create-initial-cp-tree.js +2 -2
  138. package/node/find-mat/create-initial-cp-tree.js.map +1 -1
  139. package/node/find-mat/find-mat.js +3 -4
  140. package/node/find-mat/find-mat.js.map +1 -1
  141. package/node/find-mat/find-mats.d.ts +6 -12
  142. package/node/find-mat/find-mats.js +10 -27
  143. package/node/find-mat/find-mats.js.map +1 -1
  144. package/node/find-mat/get-dull-corners-on-loop.js +2 -2
  145. package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
  146. package/node/find-mat/get-for-1-prongs-on-loop.js +36 -8
  147. package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
  148. package/node/find-mat/get-meta.d.ts +14 -4
  149. package/node/find-mat/get-meta.js +30 -24
  150. package/node/find-mat/get-meta.js.map +1 -1
  151. package/node/find-mat/get-sharp-corners.js +2 -2
  152. package/node/find-mat/get-sharp-corners.js.map +1 -1
  153. package/node/find-mat/mat-options.d.ts +2 -2
  154. package/node/floyd-warshall/get-graph.d.ts +12 -1
  155. package/node/floyd-warshall/get-graph.js +41 -38
  156. package/node/floyd-warshall/get-graph.js.map +1 -1
  157. package/node/geometry/get-bounding-box-.d.ts +16 -2
  158. package/node/geometry/get-bounding-box-.js +5 -2
  159. package/node/geometry/get-bounding-box-.js.map +1 -1
  160. package/node/geometry/get-closest-square-distance-to-rect.d.ts +3 -0
  161. package/node/geometry/get-closest-square-distance-to-rect.js +7 -5
  162. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
  163. package/node/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +4 -0
  164. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +11 -5
  165. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
  166. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +1 -2
  167. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -1
  168. package/node/index.d.ts +3 -2
  169. package/node/index.js +2 -1
  170. package/node/index.js.map +1 -1
  171. package/node/mat/clone-mat.d.ts +9 -0
  172. package/node/mat/clone-mat.js +17 -0
  173. package/node/mat/clone-mat.js.map +1 -0
  174. package/node/mat/clone-meta.d.ts +12 -0
  175. package/node/mat/clone-meta.js +24 -0
  176. package/node/mat/clone-meta.js.map +1 -0
  177. package/node/mat/get-boundary-piece-beziers.d.ts +5 -0
  178. package/node/mat/get-boundary-piece-beziers.js +7 -93
  179. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  180. package/node/mat/get-largest-3-prong.d.ts +6 -0
  181. package/node/mat/get-largest-3-prong.js +8 -5
  182. package/node/mat/get-largest-3-prong.js.map +1 -1
  183. package/node/mat/get-largest-vertex.d.ts +15 -1
  184. package/node/mat/get-largest-vertex.js +20 -7
  185. package/node/mat/get-largest-vertex.js.map +1 -1
  186. package/node/mat/hausdorff-distance-one-sided-exceeds.d.ts +79 -0
  187. package/node/mat/hausdorff-distance-one-sided-exceeds.js +251 -0
  188. package/node/mat/hausdorff-distance-one-sided-exceeds.js.map +1 -0
  189. package/node/mat/mat-meta.d.ts +0 -6
  190. package/node/mat/simplify-mat.d.ts +25 -8
  191. package/node/mat/simplify-mat.js +182 -53
  192. package/node/mat/simplify-mat.js.map +1 -1
  193. package/node/mat/trim-mat.d.ts +4 -2
  194. package/node/mat/trim-mat.js +3 -1
  195. package/node/mat/trim-mat.js.map +1 -1
  196. package/node/point-on-shape/get-boundary-tangent-line.d.ts +19 -0
  197. package/node/point-on-shape/get-boundary-tangent-line.js +33 -0
  198. package/node/point-on-shape/get-boundary-tangent-line.js.map +1 -0
  199. package/node/point-on-shape/get-osculating-circle.d.ts +6 -4
  200. package/node/point-on-shape/get-osculating-circle.js +6 -4
  201. package/node/point-on-shape/get-osculating-circle.js.map +1 -1
  202. package/node/point-on-shape/get-pos-corner.js +2 -2
  203. package/node/point-on-shape/get-pos-corner.js.map +1 -1
  204. package/node/reconstruct-from-mat/reconstruct-from-mat.js +20 -80
  205. package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
  206. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +4 -0
  207. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +4 -0
  208. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
  209. package/node/sat/cull.d.ts +7 -6
  210. package/node/sat/cull.js +13 -16
  211. package/node/sat/cull.js.map +1 -1
  212. package/node/sat/get-sat-culls.d.ts +12 -2
  213. package/node/sat/get-sat-culls.js +21 -16
  214. package/node/sat/get-sat-culls.js.map +1 -1
  215. package/node/svg/get-shape-bounds.d.ts +1 -12
  216. package/node/svg/get-shape-bounds.js +2 -3
  217. package/node/svg/get-shape-bounds.js.map +1 -1
  218. package/node/sweep-line/sweep-line.js.map +1 -1
  219. package/node/utils/get-beziers-from-tangents.d.ts +28 -0
  220. package/node/utils/get-beziers-from-tangents.js +92 -0
  221. package/node/utils/get-beziers-from-tangents.js.map +1 -0
  222. package/node/vertex/remove-vertex.d.ts +5 -3
  223. package/node/vertex/remove-vertex.js +5 -3
  224. package/node/vertex/remove-vertex.js.map +1 -1
  225. package/package.json +9 -9
  226. package/qv-infinite-loop.md +120 -0
  227. package/src/closest-boundary-point/cull-curve-pieces.ts +49 -0
  228. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -2
  229. package/src/closest-boundary-point/get-endpoint-info.ts +96 -0
  230. package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +5 -23
  231. package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +42 -60
  232. package/src/corner/get-corner.ts +10 -1
  233. package/src/corner/get-interface-ccw.ts +2 -2
  234. package/src/cp-node/cp-node.ts +4 -3
  235. package/src/cp-node/fs/get-all-on-loop-by-loop.ts +0 -4
  236. package/src/cp-node/fs/get-angle-between-mat-curves.ts +6 -4
  237. package/src/cp-node/fs/get-boundary-beziers-between.ts +10 -8
  238. package/src/cp-node/fs/get-branch-beziers.ts +3 -2
  239. package/src/cp-node/fs/get-branch.ts +1 -2
  240. package/src/cp-node/fs/get-distance-to-next.ts +4 -2
  241. package/src/cp-node/fs/get-first-exit.ts +15 -14
  242. package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +17 -69
  243. package/src/cp-node/fs/get-mat-curve-between.ts +9 -67
  244. package/src/cp-node/fs/get-mat-curves-between.ts +9 -2
  245. package/src/cp-node/fs/get-real-prong-count.ts +11 -7
  246. package/src/cp-node/fs/get-salience.ts +15 -2
  247. package/src/cp-node/fs/is-fully-terminating.ts +6 -18
  248. package/src/cp-node/fs/is-on-same-loop.ts +2 -2
  249. package/src/cp-node/fs/is-special.ts +11 -6
  250. package/src/cp-node/fs/is-vertex.ts +1 -1
  251. package/src/cp-node/fs/traverse-edges.ts +8 -4
  252. package/src/cp-node/stringification/from-stringifyable.ts +75 -75
  253. package/src/cp-node/stringification/to-stringifyable.ts +3 -3
  254. package/src/debug/debug.ts +44 -8
  255. package/src/find-2-prong/add-2-prong.ts +2 -9
  256. package/src/find-2-prong/calc-seperation-tolerance.ts +34 -115
  257. package/src/find-2-prong/find-2-prong.ts +9 -11
  258. package/src/find-2-prong/find-and-add-2-prongs.ts +2 -2
  259. package/src/find-2-prong/get-medial/get-antipodal-points.ts +1 -3
  260. package/src/find-2-prong/get-medial/get-closest-points.ts +6 -51
  261. package/src/find-2-prong/reduce-radius.ts +6 -4
  262. package/src/find-3-prong/calc-better-x.ts +2 -2
  263. package/src/find-3-prong/find-3-prong-for-delta3s.ts +197 -214
  264. package/src/find-3-prong/find-3-prong.ts +54 -51
  265. package/src/find-3-prong/find-and-add-3-prongs.ts +20 -1
  266. package/src/find-mat/create-initial-cp-tree.ts +2 -2
  267. package/src/find-mat/find-mat.ts +4 -6
  268. package/src/find-mat/find-mats.ts +83 -105
  269. package/src/find-mat/get-dull-corners-on-loop.ts +2 -2
  270. package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -8
  271. package/src/find-mat/get-meta.ts +34 -39
  272. package/src/find-mat/get-sharp-corners.ts +2 -2
  273. package/src/find-mat/mat-options.ts +2 -2
  274. package/src/floyd-warshall/get-graph.ts +46 -47
  275. package/src/geometry/get-bounding-box-.ts +5 -2
  276. package/src/geometry/get-closest-square-distance-to-rect.ts +7 -7
  277. package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +12 -10
  278. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +1 -2
  279. package/src/index.ts +3 -2
  280. package/src/mat/clone-mat.ts +9 -3
  281. package/src/mat/clone-meta.ts +8 -0
  282. package/src/mat/get-boundary-piece-beziers.ts +16 -117
  283. package/src/mat/get-largest-3-prong.ts +9 -6
  284. package/src/mat/get-largest-vertex.ts +25 -9
  285. package/src/mat/hausdorff-distance-one-sided-exceeds.ts +314 -0
  286. package/src/mat/mat-meta.ts +0 -9
  287. package/src/mat/simplify-mat.ts +254 -116
  288. package/src/mat/trim-mat.ts +6 -4
  289. package/src/point-on-shape/get-boundary-tangent-line.ts +36 -0
  290. package/src/point-on-shape/get-osculating-circle.ts +7 -5
  291. package/src/point-on-shape/get-pos-corner.ts +2 -2
  292. package/src/reconstruct-from-mat/reconstruct-from-mat.ts +22 -111
  293. package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +4 -0
  294. package/src/sat/cull.ts +16 -20
  295. package/src/sat/get-sat-culls.ts +28 -23
  296. package/src/svg/get-shape-bounds.ts +2 -3
  297. package/src/sweep-line/sweep-line.ts +1 -1
  298. package/src/utils/get-beziers-from-tangents.ts +110 -0
  299. package/src/utils/map-map.ts +1 -1
  300. package/src/vertex/remove-vertex.ts +5 -3
  301. package/__tests__/cp-node/fs/get-distance-between.spec.ts +0 -7
  302. package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +0 -24
  303. package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +0 -17
  304. package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +0 -17
  305. package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +0 -14
  306. package/node/closest-boundary-point/cull-bezier-pieces-1.d.ts +0 -9
  307. package/node/closest-boundary-point/cull-bezier-pieces-1.js +0 -17
  308. package/node/closest-boundary-point/cull-bezier-pieces-1.js.map +0 -1
  309. package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +0 -13
  310. package/node/closest-boundary-point/cull-by-loose-bounding-box.js +0 -27
  311. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
  312. package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +0 -11
  313. package/node/closest-boundary-point/cull-by-tight-boundary-box.js +0 -27
  314. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
  315. package/node/cp-node/fs/find-first.d.ts +0 -10
  316. package/node/cp-node/fs/find-first.js +0 -19
  317. package/node/cp-node/fs/find-first.js.map +0 -1
  318. package/node/debug/functions/check-ordering.d.ts +0 -4
  319. package/node/debug/functions/check-ordering.js +0 -43
  320. package/node/debug/functions/check-ordering.js.map +0 -1
  321. package/node/find-2-prong/cull-bezier-pieces.d.ts +0 -13
  322. package/node/find-2-prong/cull-bezier-pieces.js +0 -43
  323. package/node/find-2-prong/cull-bezier-pieces.js.map +0 -1
  324. package/node/floyd-warshall/get-hole-closer-pairs.d.ts +0 -8
  325. package/node/floyd-warshall/get-hole-closer-pairs.js +0 -27
  326. package/node/floyd-warshall/get-hole-closer-pairs.js.map +0 -1
  327. package/node/utils/dual-set.d.ts +0 -27
  328. package/node/utils/dual-set.js +0 -55
  329. package/node/utils/dual-set.js.map +0 -1
  330. package/node/utils/tri-map.d.ts +0 -27
  331. package/node/utils/tri-map.js +0 -49
  332. package/node/utils/tri-map.js.map +0 -1
  333. package/src/closest-boundary-point/cull-bezier-pieces-1.ts +0 -36
  334. package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +0 -42
  335. package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +0 -43
  336. package/src/closest-boundary-point/get-p-from-box.ts +0 -14
  337. package/src/cp-node/fs/add-distance-from.ts +0 -49
  338. package/src/cp-node/fs/get-distance-between.ts +0 -16
  339. package/src/cp-node/fs/get-terminating-on-circle.ts +0 -24
  340. package/src/cp-node/fs/is-single-3-prong.ts +0 -15
  341. package/src/cp-node/fs/iterate-all-on-loop.ts +0 -15
  342. package/src/cp-node/fs/traverse-all-forward.ts +0 -24
  343. package/src/debug/functions/draw/draw-beziers-as-single-path.ts +0 -40
  344. package/src/debug/functions/draw/draw-disk.ts +0 -34
  345. package/src/debug/functions/draw/xmlns.ts +0 -5
  346. package/src/find-2-prong/cull-bezier-pieces.ts +0 -61
  347. package/src/find-2-prong/find-and-add-2-prong.ts +0 -30
  348. package/src/find-2-prong/get-medial/get-closest-points-d.ts +0 -213
  349. package/src/find-2-prong/x-for-debugging.ts +0 -13
  350. package/src/floyd-warshall/get-hole-closer-pairs.ts +0 -35
  351. package/src/mat/get-two-prong-type.ts +0 -13
  352. package/src/point-on-shape/is-pos-dull-corner.ts +0 -18
  353. package/src/point-on-shape/is-pos-quite-dull-corner.ts +0 -18
  354. package/src/point-on-shape/is-pos-quite-sharp-corner.ts +0 -18
  355. package/src/point-on-shape/pos-to-human-string.ts +0 -18
  356. package/src/sweep-line/are-boxes-intersecting.ts +0 -37
@@ -0,0 +1,17 @@
1
+ import { clone } from "../cp-node/fs/clone.js";
2
+ import { cloneMeta } from "./clone-meta.js";
3
+ /**
4
+ * Returns a deep clone of the given `Mat` (its `CpNode`s are cloned and its
5
+ * `meta` rebuilt for the clones; the boundary loops are shared).
6
+ *
7
+ * @param mat the `Mat` to clone
8
+ */
9
+ function cloneMat(mat) {
10
+ const cpNode = clone(mat.cpNode);
11
+ return {
12
+ cpNode,
13
+ meta: cloneMeta(cpNode, mat.meta)
14
+ };
15
+ }
16
+ export { cloneMat };
17
+ //# sourceMappingURL=clone-mat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-mat.js","sourceRoot":"","sources":["../../src/mat/clone-mat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;GAKG;AACH,SAAS,QAAQ,CACT,GAAQ;IAEZ,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO;QACH,MAAM;QACN,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;KACpC,CAAA;AACL,CAAC;AAGD,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { MatMeta } from './mat-meta.js';
2
+ import type { CpNode } from '../cp-node/cp-node.js';
3
+ /**
4
+ * Returns a clone of the given `MatMeta` for the given (already cloned)
5
+ * `CpNode`, i.e. with `cpTrees` rebuilt from the clone and a fresh
6
+ * `lastInsertId`.
7
+ *
8
+ * @param cpNode the (cloned) `CpNode` the meta is for
9
+ * @param meta the `MatMeta` to clone
10
+ */
11
+ declare function cloneMeta(cpNode: CpNode, meta: MatMeta): MatMeta;
12
+ export { cloneMeta };
@@ -0,0 +1,24 @@
1
+ import { createNewCpTrees } from './create-new-cp-trees.js';
2
+ /**
3
+ * Returns a clone of the given `MatMeta` for the given (already cloned)
4
+ * `CpNode`, i.e. with `cpTrees` rebuilt from the clone and a fresh
5
+ * `lastInsertId`.
6
+ *
7
+ * @param cpNode the (cloned) `CpNode` the meta is for
8
+ * @param meta the `MatMeta` to clone
9
+ */
10
+ function cloneMeta(cpNode, meta) {
11
+ const {
12
+ // pointToCpNode,
13
+ lastInsertId, cpTrees, ...rest } = meta;
14
+ const cpTrees_ = createNewCpTrees(cpNode);
15
+ const lastInsertId_ = { id: lastInsertId.id };
16
+ return {
17
+ cpTrees: cpTrees_,
18
+ lastInsertId: lastInsertId_,
19
+ // pointToCpNode,
20
+ ...rest
21
+ };
22
+ }
23
+ export { cloneMeta };
24
+ //# sourceMappingURL=clone-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-meta.js","sourceRoot":"","sources":["../../src/mat/clone-meta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;GAOG;AACH,SAAS,SAAS,CACV,MAAc,EACd,IAAa;IAEjB,MAAM;IACF,iBAAiB;IACjB,YAAY,EACZ,OAAO,EACP,GAAG,IAAI,EACV,GAAG,IAAI,CAAC;IAET,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC;IAE9C,OAAO;QACH,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,aAAa;QAC3B,iBAAiB;QACjB,GAAG,IAAI;KACV,CAAA;AACL,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -3,6 +3,11 @@ import type { CurvePiece } from './curve-piece.js';
3
3
  /**
4
4
  * Returns the ordered bezier pieces between the two given `CpNode`s.
5
5
  *
6
+ * * NOTE: an earlier version 'stitched' pieces together at hole closers and
7
+ * loop endpoints to avoid duplicate antipodal points later; this was removed
8
+ * (duplicates are now checked for in `find2Prong`) - see the git history
9
+ * before 2026-10 for that code.
10
+ *
6
11
  * @param cpNodes - An ordered pair that represents the start and end points of
7
12
  * the boundary piece
8
13
  *
@@ -2,6 +2,11 @@ import { comparePoss } from '../point-on-shape/compare-poss.js';
2
2
  /**
3
3
  * Returns the ordered bezier pieces between the two given `CpNode`s.
4
4
  *
5
+ * * NOTE: an earlier version 'stitched' pieces together at hole closers and
6
+ * loop endpoints to avoid duplicate antipodal points later; this was removed
7
+ * (duplicates are now checked for in `find2Prong`) - see the git history
8
+ * before 2026-10 for that code.
9
+ *
5
10
  * @param cpNodes - An ordered pair that represents the start and end points of
6
11
  * the boundary piece
7
12
  *
@@ -11,12 +16,6 @@ function getBoundaryPieceBeziers(cpNodes) {
11
16
  let cpThis = cpNodes[0];
12
17
  const cpEnd = cpNodes[1];
13
18
  const curvePieces = [];
14
- // NOTE❗ Currently removed stichables; we're just checking for duplicates
15
- // later in `find2Prong`; KEEP for possible future use.
16
- // We have to stich curves together if they're at a hole closer or at the
17
- // endpoints of a loop to avoid duplicates later within the code; the map
18
- // is from curves
19
- // const stichables: Map<Curve, number[]> = new Map();
20
19
  // As opposed to going around the circle and taking the last exit
21
20
  let goStraight = true;
22
21
  do {
@@ -26,27 +25,6 @@ function getBoundaryPieceBeziers(cpNodes) {
26
25
  const curveNext = posNext.curve;
27
26
  if (!goStraight) {
28
27
  goStraight = true;
29
- // NOTE❗ Currently removed stichables; we're just checking for duplicates
30
- // later in `find2Prong`; KEEP for possible future use.
31
- // const { loop: loopThis } = curveThis;
32
- // const cpPrevOnCircle = cpThis.prevOnCircle;
33
- // const curvePrevOnCircle = cpPrevOnCircle.pointOnShape.curve;
34
- // const { loop: loopNext } = cpPrevOnCircle.pointOnShape.curve;
35
- // if (loopThis !== loopNext) {
36
- // let idxsThis = stichables.get(curveThis);
37
- // if (idxsThis === undefined) {
38
- // idxsThis = [];
39
- // stichables.set(curveThis, idxsThis);
40
- // }
41
- // idxsThis.push(curvePieces.length - 1); // last `CurvePiece` idx
42
- // let idxsNext = stichables.get(curvePrevOnCircle);
43
- // if (idxsNext === undefined) {
44
- // idxsNext = [];
45
- // stichables.set(curvePrevOnCircle, idxsNext);
46
- // }
47
- // idxsNext.push(curvePieces.length); // upcoming `CurvePiece` idx
48
- // }
49
- // cpThis = cpPrevOnCircle; // take last exit
50
28
  cpThis = cpThis.prevOnCircle; // take last exit
51
29
  continue;
52
30
  }
@@ -72,78 +50,14 @@ function getBoundaryPieceBeziers(cpNodes) {
72
50
  // 2. `this` comes after `next` by ordering
73
51
  // so split at t = 1.
74
52
  if (curveThis.loop === curveNext.loop) {
75
- const initialCurvePiece = {
53
+ curvePieces.push({
76
54
  curve: curveThis, ts: [posThis.t, 1]
77
- };
78
- curvePieces.push(initialCurvePiece);
55
+ });
79
56
  // Fill in any curves skipped between the two points.
80
57
  addSkippedBeziers(curvePieces, curveThis, curveNext, posNext.t);
81
- // NOTE❗ Currently removed stichables; we're just checking for duplicates
82
- // later in `find2Prong`; KEEP for possible future use.
83
- // const finalCurvePiece = curvePieces[curvePieces.length - 1];
84
- // if (initialCurvePiece.curve === finalCurvePiece!.curve) {
85
- // const { ts: tsS } = initialCurvePiece;
86
- // const { ts: tsE } = finalCurvePiece!;
87
- // // If it is a closed loop we must join the endpoints to prevent duplicate
88
- // // antipodal points later
89
- // if (tsS[0] === tsE[1]) {
90
- // initialCurvePiece.ts[0] = tsE[0];
91
- // if (curvePieces.length > 1) {
92
- // curvePieces.pop();
93
- // }
94
- // // console.log('was inner closed loop')
95
- // }
96
- // }
97
58
  }
98
59
  cpThis = cpThis.next;
99
60
  } while (cpThis !== cpEnd);
100
- // NOTE❗ Currently removed stichables; we're just checking for duplicates
101
- // later in `find2Prong`; KEEP for possible future use.
102
- // if (stichables.size > 0) {
103
- // for (const [loop,idxs] of stichables.entries()) {
104
- // if (idxs.length === 2) {
105
- // const curvePieceS = curvePieces[idxs[0]]!;
106
- // const curvePieceE = curvePieces[idxs[1]]!;
107
- // if (curvePieceS === undefined || curvePieceE === undefined) {
108
- // console.log(curvePieceS);
109
- // console.log(curvePieceE);
110
- // continue;
111
- // }
112
- // const { curve: curveS, ts: tsS } = curvePieceS;
113
- // const { curve: curveE, ts: tsE } = curvePieceE;
114
- // if (curveS !== curveE) {
115
- // continue;
116
- // }
117
- // // If it is a closed loop we must join the endpoints to prevent duplicate
118
- // // antipodal points later
119
- // if (tsS[0] === tsE[1]) {
120
- // curvePieceS.ts[0] = tsE[0];
121
- // // console.log('was closed loop 1')
122
- // } else if (tsE[0] === tsS[1]) {
123
- // curvePieceS.ts[1] = tsE[1];
124
- // // console.log('was closed loop 2')
125
- // }
126
- // if (idxs[0] !== idxs[1]) {
127
- // curvePieces[idxs[1]] = undefined;
128
- // }
129
- // }
130
- // }
131
- // }
132
- // NOTE❗ The below endcurve check is not enough for specific cases involving
133
- // multiple hole closers; KEEP for now but must use stichables instead
134
- // if (curvePieces[0]!.curve === curvePieces[curvePieces.length - 1]!.curve) {
135
- // const { ts: tsS } = curvePieces[0]!;
136
- // const { ts: tsE } = curvePieces[curvePieces.length - 1]!;
137
- // // If it is a closed loop we must join the endpoints to prevent duplicate
138
- // // antipodal points later
139
- // if (tsS[0] === tsE[1]) {
140
- // curvePieces[0]!.ts[0] = tsE[0];
141
- // if (curvePieces.length > 1) {
142
- // curvePieces.pop();
143
- // }
144
- // // console.log('was closed loop')
145
- // }
146
- // }
147
61
  return curvePieces;
148
62
  }
149
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"get-boundary-piece-beziers.js","sourceRoot":"","sources":["../../src/mat/get-boundary-piece-beziers.ts"],"names":[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C,CAAC,EAAE,CAAC,CAAC;aACvC,CAAC,CAAC;YAEH,qDAAqD;YACrD,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC,QAAQ,MAAM,KAAK,KAAK,EAAE;IAE3B,OAAO,WAAW,CAAC;AACvB,CAAC;AAGD;;;GAGG;AACH,SAAS,iBAAiB,CAClB,WAAyB,EACzB,UAAiB,EACjB,QAAe,EACf,EAAU;IAEd,gEAAgE;IAChE,IAAI,SAAS,GAAG,UAAU,CAAC;IAC3B,GAAG,CAAC;QACA,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;QAC3B,MAAM,IAAI,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC,QAAQ,SAAS,KAAK,QAAQ,EAAE;AACrC,CAAC;AAGD,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
@@ -1,3 +1,9 @@
1
1
  import type { CpNode } from '../cp-node/cp-node.js';
2
+ /**
3
+ * Returns the `CpNode` on a 3-prong (or higher) MAT vertex with the largest
4
+ * maximal disk radius, or `undefined` if there is none.
5
+ *
6
+ * @param cpNode any `CpNode` on the MAT
7
+ */
2
8
  declare function getLargest3Prong(cpNode: CpNode): CpNode | undefined;
3
9
  export { getLargest3Prong };
@@ -1,16 +1,19 @@
1
1
  import { getAllOnLoop } from '../cp-node/fs/get-all-on-loop.js';
2
2
  import { getRealProngCount } from '../cp-node/fs/get-real-prong-count.js';
3
+ import { getLargestOf } from './get-largest-vertex.js';
4
+ /**
5
+ * Returns the `CpNode` on a 3-prong (or higher) MAT vertex with the largest
6
+ * maximal disk radius, or `undefined` if there is none.
7
+ *
8
+ * @param cpNode any `CpNode` on the MAT
9
+ */
3
10
  function getLargest3Prong(cpNode) {
4
11
  const cpNodes = getAllOnLoop(cpNode)
5
12
  .filter(cpNode => getRealProngCount(cpNode) >= 3);
6
13
  if (cpNodes.length === 0) {
7
14
  return undefined;
8
15
  }
9
- return cpNodes.reduce(function (maxCpNode, cpNode) {
10
- return maxCpNode.pointOnShape.circle.radius >= cpNode.pointOnShape.circle.radius
11
- ? maxCpNode
12
- : cpNode;
13
- }, cpNodes[0]);
16
+ return getLargestOf(cpNodes);
14
17
  }
15
18
  export { getLargest3Prong };
16
19
  //# sourceMappingURL=get-largest-3-prong.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-largest-3-prong.js","sourceRoot":"","sources":["../../src/mat/get-largest-3-prong.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,SAAS,gBAAgB,CACjB,MAAc;IAElB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;SAC/B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAE/C,OAAO,OAAO,CAAC,MAAM,CAAC,UAAS,SAAiB,EAAE,MAAc;QAC5D,OAAO,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM;YAC5E,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM,CAAA;IAChB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-largest-3-prong.js","sourceRoot":"","sources":["../../src/mat/get-largest-3-prong.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD;;;;;GAKG;AACH,SAAS,gBAAgB,CACjB,MAAc;IAElB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;SAC/B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAE/C,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,3 +1,17 @@
1
1
  import type { CpNode } from '../cp-node/cp-node.js';
2
+ /**
3
+ * Returns the `CpNode` (of the given ones) with the largest maximal disk
4
+ * radius (the first one in case of a tie).
5
+ *
6
+ * @param cpNodes a non-empty array of `CpNode`s
7
+ *
8
+ * @internal
9
+ */
10
+ declare function getLargestOf(cpNodes: CpNode[]): CpNode;
11
+ /**
12
+ * Returns the `CpNode` on the MAT with the largest maximal disk radius.
13
+ *
14
+ * @param cpNode any `CpNode` on the MAT
15
+ */
2
16
  declare function getLargestVertex(cpNode: CpNode): CpNode;
3
- export { getLargestVertex };
17
+ export { getLargestVertex, getLargestOf };
@@ -1,11 +1,24 @@
1
1
  import { getAllOnLoop } from '../cp-node/fs/get-all-on-loop.js';
2
+ /**
3
+ * Returns the `CpNode` (of the given ones) with the largest maximal disk
4
+ * radius (the first one in case of a tie).
5
+ *
6
+ * @param cpNodes a non-empty array of `CpNode`s
7
+ *
8
+ * @internal
9
+ */
10
+ function getLargestOf(cpNodes) {
11
+ return cpNodes.reduce((maxCpNode, cpNode) => maxCpNode.pointOnShape.circle.radius >= cpNode.pointOnShape.circle.radius
12
+ ? maxCpNode
13
+ : cpNode);
14
+ }
15
+ /**
16
+ * Returns the `CpNode` on the MAT with the largest maximal disk radius.
17
+ *
18
+ * @param cpNode any `CpNode` on the MAT
19
+ */
2
20
  function getLargestVertex(cpNode) {
3
- const cpNodes = getAllOnLoop(cpNode);
4
- return cpNodes.reduce(function (maxCpNode, cpNode) {
5
- return maxCpNode.pointOnShape.circle.radius >= cpNode.pointOnShape.circle.radius
6
- ? maxCpNode
7
- : cpNode;
8
- }, cpNodes[0]);
21
+ return getLargestOf(getAllOnLoop(cpNode));
9
22
  }
10
- export { getLargestVertex };
23
+ export { getLargestVertex, getLargestOf };
11
24
  //# sourceMappingURL=get-largest-vertex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-largest-vertex.js","sourceRoot":"","sources":["../../src/mat/get-largest-vertex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,SAAS,gBAAgB,CACjB,MAAc;IAElB,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAErC,OAAO,OAAO,CAAC,MAAM,CAAC,UAAS,SAAiB,EAAE,MAAc;QAC5D,OAAO,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM;YAC5E,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM,CAAA;IAChB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-largest-vertex.js","sourceRoot":"","sources":["../../src/mat/get-largest-vertex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,OAAiB;IACnC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CACxC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM;QACrE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,MAAM,CACf,CAAC;AACN,CAAC;AAGD;;;;GAIG;AACH,SAAS,gBAAgB,CACjB,MAAc;IAElB,OAAO,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9C,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * A point `q` on a piecewise bezier curve at parameter `t` of piece `k`
3
+ * together with its distance `d` to some other point.
4
+ *
5
+ * @internal
6
+ */
7
+ interface Foot {
8
+ d: number;
9
+ q: number[];
10
+ k: number;
11
+ t: number;
12
+ }
13
+ /**
14
+ * Returns the closest point on the piecewise bezier curve given by `curves`
15
+ * to the point `p` (as a `Foot`), i.e. the piece-wise minimum of the
16
+ * (certified) `closestPointOnBezier` of `flo-bezier3`.
17
+ *
18
+ * @param p the point
19
+ * @param curves the pieces of the piecewise bezier curve
20
+ *
21
+ * @internal
22
+ */
23
+ declare function closestPointOnCurves(p: number[], curves: number[][][]): Foot;
24
+ /**
25
+ * Returns the distance from the point `p` to the piecewise bezier curve given
26
+ * by `curves` (i.e. the minimum over the pieces of the distance to the piece).
27
+ *
28
+ * @param p the point
29
+ * @param curves the pieces of the piecewise bezier curve
30
+ *
31
+ * @internal
32
+ */
33
+ declare function distanceToCurves(p: number[], curves: number[][][]): number;
34
+ /**
35
+ * Returns `true` if the one-sided Hausdorff distance from the bezier curve `A`
36
+ * to the piecewise bezier curve `B` exceeds `tolerance` and `false` otherwise.
37
+ *
38
+ * * this is a *decision procedure* and is thus much cheaper than computing the
39
+ * distance (e.g. via `hausdorffDistanceOneSided` from `flo-bezier3`) and then
40
+ * comparing it: it stops as soon as either a point on `A` further than
41
+ * `tolerance` from `B` is found (a certified *lower* bound exceeding the
42
+ * tolerance) or every piece of `A` is certified to be within `tolerance`
43
+ * (a certified *upper* bound)
44
+ * * `A` is bisected into parameter intervals; the upper bound on an interval
45
+ * `[tS,tE]` is the smaller of
46
+ * * `(hS + hE + L)/2` where `hS`, `hE` are (upper bounds on) the
47
+ * distances from its endpoints to `B` and `L` is the control polygon
48
+ * length of `A` restricted to the interval (an upper bound on its arc
49
+ * length): any point on the interval is within `L` of both endpoints so
50
+ * its distance to `B` is at most `min(hS + l, hE + (L - l))` with `l`
51
+ * the arc length from the start, maximized at `(hS + hE + L)/2`
52
+ * * the maximum distance from the foot (on `B`) of either endpoint to the
53
+ * control points of `A` restricted to the interval (the sub-curve lies
54
+ * within the convex hull of its control points, within which the
55
+ * distance to a fixed point is maximized at a vertex)
56
+ * * the distances from sample points on `A` to `B` are found cheaply by
57
+ * Newton iteration from the feet of the neighboring samples - these are upper
58
+ * bounds (any point on `B` gives one) which suffice for certifying the
59
+ * acceptance of an interval; only when such a bound exceeds the tolerance is
60
+ * the certified (and expensive) closest point computed to decide whether the
61
+ * tolerance is really exceeded
62
+ * * `B` need not be smooth, nor need its pieces be connected
63
+ * * the result is approximate only to the extent that the floating point
64
+ * evaluations are, i.e. a decision is only taken once it is certain up to
65
+ * roundoff
66
+ *
67
+ * @param A the 'from' bezier curve given by its control points
68
+ * @param B the 'to' piecewise bezier curve given as an array of bezier curves
69
+ * @param tolerance the distance to compare against
70
+ * @param maxIterations the maximum number of interval bisections (each
71
+ * costing one cheap closest point calculation) before giving up, in which
72
+ * case `true` is returned (the conservative answer for simplification
73
+ * purposes); defaults to `1000` (curves only just within tolerance may
74
+ * need many bisections, especially where they run nearly parallel to `B`)
75
+ *
76
+ * @internal
77
+ */
78
+ declare function hausdorffDistanceOneSidedExceeds(A: number[][], B: number[][][], tolerance: number, maxIterations?: number): boolean;
79
+ export { hausdorffDistanceOneSidedExceeds, distanceToCurves, closestPointOnCurves };
@@ -0,0 +1,251 @@
1
+ import { closestPointOnBezier, controlPointLinesLength, evalDeCasteljau, fromTo } from 'flo-bezier3';
2
+ const { max, sqrt } = Math;
3
+ /**
4
+ * Returns the closest point on the piecewise bezier curve given by `curves`
5
+ * to the point `p` (as a `Foot`), i.e. the piece-wise minimum of the
6
+ * (certified) `closestPointOnBezier` of `flo-bezier3`.
7
+ *
8
+ * @param p the point
9
+ * @param curves the pieces of the piecewise bezier curve
10
+ *
11
+ * @internal
12
+ */
13
+ function closestPointOnCurves(p, curves) {
14
+ let best = { d: Infinity, q: p, k: 0, t: 0 };
15
+ for (let k = 0; k < curves.length; k++) {
16
+ const c = closestPointOnBezier(curves[k], p);
17
+ if (c.d < best.d) {
18
+ best = { d: c.d, q: c.p, k, t: c.t };
19
+ }
20
+ }
21
+ return best;
22
+ }
23
+ /**
24
+ * Returns the distance from the point `p` to the piecewise bezier curve given
25
+ * by `curves` (i.e. the minimum over the pieces of the distance to the piece).
26
+ *
27
+ * @param p the point
28
+ * @param curves the pieces of the piecewise bezier curve
29
+ *
30
+ * @internal
31
+ */
32
+ function distanceToCurves(p, curves) {
33
+ return closestPointOnCurves(p, curves).d;
34
+ }
35
+ /**
36
+ * Evaluates the bezier curve `ps` (of order 1, 2 or 3) and its first two
37
+ * derivatives at `t`, returned as `[B, B', B'']`.
38
+ *
39
+ * @internal
40
+ */
41
+ function evalWithDerivatives(ps, t) {
42
+ const [p0, p1] = ps;
43
+ if (ps.length === 2) {
44
+ return [
45
+ [p0[0] + t * (p1[0] - p0[0]), p0[1] + t * (p1[1] - p0[1])],
46
+ [p1[0] - p0[0], p1[1] - p0[1]],
47
+ [0, 0]
48
+ ];
49
+ }
50
+ const s = 1 - t;
51
+ if (ps.length === 3) {
52
+ const p2 = ps[2];
53
+ return [
54
+ [s * s * p0[0] + 2 * s * t * p1[0] + t * t * p2[0],
55
+ s * s * p0[1] + 2 * s * t * p1[1] + t * t * p2[1]],
56
+ [2 * (s * (p1[0] - p0[0]) + t * (p2[0] - p1[0])),
57
+ 2 * (s * (p1[1] - p0[1]) + t * (p2[1] - p1[1]))],
58
+ [2 * (p2[0] - 2 * p1[0] + p0[0]),
59
+ 2 * (p2[1] - 2 * p1[1] + p0[1])]
60
+ ];
61
+ }
62
+ const p2 = ps[2];
63
+ const p3 = ps[3];
64
+ return [
65
+ [s * s * s * p0[0] + 3 * s * s * t * p1[0] + 3 * s * t * t * p2[0] + t * t * t * p3[0],
66
+ s * s * s * p0[1] + 3 * s * s * t * p1[1] + 3 * s * t * t * p2[1] + t * t * t * p3[1]],
67
+ [3 * (s * s * (p1[0] - p0[0]) + 2 * s * t * (p2[0] - p1[0]) + t * t * (p3[0] - p2[0])),
68
+ 3 * (s * s * (p1[1] - p0[1]) + 2 * s * t * (p2[1] - p1[1]) + t * t * (p3[1] - p2[1]))],
69
+ [6 * (s * (p2[0] - 2 * p1[0] + p0[0]) + t * (p3[0] - 2 * p2[0] + p1[0])),
70
+ 6 * (s * (p2[1] - 2 * p1[1] + p0[1]) + t * (p3[1] - 2 * p2[1] + p1[1]))]
71
+ ];
72
+ }
73
+ /**
74
+ * Returns a point on piece `k` of `curves` close to `p` found by a few Newton
75
+ * iterations on the squared distance starting from parameter `t0`, as a
76
+ * `Foot`.
77
+ *
78
+ * * the returned distance is thus an *upper bound* on the distance from `p`
79
+ * to the piecewise curve (any point on the curve gives one) - it is not
80
+ * certified to be the minimum
81
+ *
82
+ * @internal
83
+ */
84
+ function newtonFoot(p, curves, k, t0) {
85
+ const ps = curves[k];
86
+ if (ps.length === 1) {
87
+ const q = ps[0];
88
+ return { d: sqrt((q[0] - p[0]) ** 2 + (q[1] - p[1]) ** 2), q, k, t: 0 };
89
+ }
90
+ let t = t0;
91
+ let [q, dq, ddq] = evalWithDerivatives(ps, t);
92
+ let rx = q[0] - p[0];
93
+ let ry = q[1] - p[1];
94
+ let best = { d: sqrt(rx * rx + ry * ry), q, k, t };
95
+ for (let i = 0; i < 4; i++) {
96
+ // minimize g(t) = |B(t) - p|²/2: g' = r·B', g'' = B'·B' + r·B''
97
+ const g1 = rx * dq[0] + ry * dq[1];
98
+ const g2 = dq[0] * dq[0] + dq[1] * dq[1] + rx * ddq[0] + ry * ddq[1];
99
+ if (g2 <= 0) {
100
+ break;
101
+ }
102
+ let t_ = t - g1 / g2;
103
+ if (t_ < 0) {
104
+ t_ = 0;
105
+ }
106
+ else if (t_ > 1) {
107
+ t_ = 1;
108
+ }
109
+ if (t_ === t) {
110
+ break;
111
+ }
112
+ t = t_;
113
+ [q, dq, ddq] = evalWithDerivatives(ps, t);
114
+ rx = q[0] - p[0];
115
+ ry = q[1] - p[1];
116
+ const d = sqrt(rx * rx + ry * ry);
117
+ if (d < best.d) {
118
+ best = { d, q, k, t };
119
+ }
120
+ }
121
+ return best;
122
+ }
123
+ /**
124
+ * Returns the maximum distance from the point `q` to the control points of
125
+ * `ps` - an upper bound on the distance from `q` to any point on the bezier
126
+ * curve `ps` (which lies within the convex hull of its control points).
127
+ *
128
+ * @internal
129
+ */
130
+ function maxDistanceToControlPoints(ps, q) {
131
+ let m = 0;
132
+ for (let i = 0; i < ps.length; i++) {
133
+ const c = ps[i];
134
+ const dd = (c[0] - q[0]) ** 2 + (c[1] - q[1]) ** 2;
135
+ if (dd > m) {
136
+ m = dd;
137
+ }
138
+ }
139
+ return sqrt(m);
140
+ }
141
+ /**
142
+ * Returns `true` if the one-sided Hausdorff distance from the bezier curve `A`
143
+ * to the piecewise bezier curve `B` exceeds `tolerance` and `false` otherwise.
144
+ *
145
+ * * this is a *decision procedure* and is thus much cheaper than computing the
146
+ * distance (e.g. via `hausdorffDistanceOneSided` from `flo-bezier3`) and then
147
+ * comparing it: it stops as soon as either a point on `A` further than
148
+ * `tolerance` from `B` is found (a certified *lower* bound exceeding the
149
+ * tolerance) or every piece of `A` is certified to be within `tolerance`
150
+ * (a certified *upper* bound)
151
+ * * `A` is bisected into parameter intervals; the upper bound on an interval
152
+ * `[tS,tE]` is the smaller of
153
+ * * `(hS + hE + L)/2` where `hS`, `hE` are (upper bounds on) the
154
+ * distances from its endpoints to `B` and `L` is the control polygon
155
+ * length of `A` restricted to the interval (an upper bound on its arc
156
+ * length): any point on the interval is within `L` of both endpoints so
157
+ * its distance to `B` is at most `min(hS + l, hE + (L - l))` with `l`
158
+ * the arc length from the start, maximized at `(hS + hE + L)/2`
159
+ * * the maximum distance from the foot (on `B`) of either endpoint to the
160
+ * control points of `A` restricted to the interval (the sub-curve lies
161
+ * within the convex hull of its control points, within which the
162
+ * distance to a fixed point is maximized at a vertex)
163
+ * * the distances from sample points on `A` to `B` are found cheaply by
164
+ * Newton iteration from the feet of the neighboring samples - these are upper
165
+ * bounds (any point on `B` gives one) which suffice for certifying the
166
+ * acceptance of an interval; only when such a bound exceeds the tolerance is
167
+ * the certified (and expensive) closest point computed to decide whether the
168
+ * tolerance is really exceeded
169
+ * * `B` need not be smooth, nor need its pieces be connected
170
+ * * the result is approximate only to the extent that the floating point
171
+ * evaluations are, i.e. a decision is only taken once it is certain up to
172
+ * roundoff
173
+ *
174
+ * @param A the 'from' bezier curve given by its control points
175
+ * @param B the 'to' piecewise bezier curve given as an array of bezier curves
176
+ * @param tolerance the distance to compare against
177
+ * @param maxIterations the maximum number of interval bisections (each
178
+ * costing one cheap closest point calculation) before giving up, in which
179
+ * case `true` is returned (the conservative answer for simplification
180
+ * purposes); defaults to `1000` (curves only just within tolerance may
181
+ * need many bisections, especially where they run nearly parallel to `B`)
182
+ *
183
+ * @internal
184
+ */
185
+ function hausdorffDistanceOneSidedExceeds(A, B, tolerance, maxIterations = 1000) {
186
+ const fS = closestPointOnCurves(A[0], B);
187
+ if (fS.d > tolerance) {
188
+ return true;
189
+ }
190
+ const fE = closestPointOnCurves(A[A.length - 1], B);
191
+ if (fE.d > tolerance) {
192
+ return true;
193
+ }
194
+ if (A.length <= 2) {
195
+ // A point or a line: if `B` is a single line (a convex set) the
196
+ // distance is convex along `A` and thus maximal at an endpoint.
197
+ if (A.length === 1 || (B.length === 1 && B[0].length <= 2)) {
198
+ return false;
199
+ }
200
+ }
201
+ // Depth first; the stack never holds more than about `2*log2(iterations)`
202
+ // intervals.
203
+ const stack = [{ tS: 0, tE: 1, fS, fE }];
204
+ let iterations = 0;
205
+ while (stack.length > 0) {
206
+ const { tS, tE, fS, fE } = stack.pop();
207
+ const ps = tS === 0 && tE === 1 ? A : fromTo(A, tS, tE);
208
+ // the entire interval is certified within tolerance if either upper
209
+ // bound says so
210
+ if ((fS.d + fE.d + controlPointLinesLength(ps)) / 2 <= tolerance) {
211
+ continue;
212
+ }
213
+ if (maxDistanceToControlPoints(ps, fS.q) <= tolerance ||
214
+ maxDistanceToControlPoints(ps, fE.q) <= tolerance) {
215
+ continue;
216
+ }
217
+ if (iterations++ >= maxIterations) {
218
+ return true; // undecided - be conservative
219
+ }
220
+ const tM = (tS + tE) / 2;
221
+ const pM = evalDeCasteljau(A, tM);
222
+ // a cheap upper bound on the distance from `pM` to `B` - by Newton
223
+ // iteration from the feet of the endpoints
224
+ let fM = newtonFoot(pM, B, fS.k, fS.k === fE.k ? (fS.t + fE.t) / 2 : fS.t);
225
+ if (fS.k !== fE.k) {
226
+ const fM_ = newtonFoot(pM, B, fE.k, fE.t);
227
+ if (fM_.d < fM.d) {
228
+ fM = fM_;
229
+ }
230
+ }
231
+ if (fM.d > tolerance) {
232
+ // possibly exceeds - now get the certified closest point
233
+ fM = closestPointOnCurves(pM, B);
234
+ if (fM.d > tolerance) {
235
+ return true;
236
+ }
237
+ }
238
+ // push the half with the larger lower bound last so it is tried first
239
+ if (max(fS.d, fM.d) >= max(fM.d, fE.d)) {
240
+ stack.push({ tS: tM, tE, fS: fM, fE });
241
+ stack.push({ tS, tE: tM, fS, fE: fM });
242
+ }
243
+ else {
244
+ stack.push({ tS, tE: tM, fS, fE: fM });
245
+ stack.push({ tS: tM, tE, fS: fM, fE });
246
+ }
247
+ }
248
+ return false;
249
+ }
250
+ export { hausdorffDistanceOneSidedExceeds, distanceToCurves, closestPointOnCurves };
251
+ //# sourceMappingURL=hausdorff-distance-one-sided-exceeds.js.map