flo-mat 2.0.4 → 3.0.0

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 (652) hide show
  1. package/.quokka +4 -0
  2. package/browser/index.js +18434 -14538
  3. package/browser/index.min.js +1 -1
  4. package/node/closest-boundary-point/cull-bezier-pieces.d.ts +9 -0
  5. package/node/closest-boundary-point/cull-bezier-pieces.js +17 -0
  6. package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -0
  7. package/node/{mat/closest-boundary-point → closest-boundary-point}/cull-by-loose-bounding-box.d.ts +2 -2
  8. package/node/{mat/closest-boundary-point → closest-boundary-point}/cull-by-loose-bounding-box.js +2 -2
  9. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -0
  10. package/node/{mat/closest-boundary-point → closest-boundary-point}/cull-by-tight-boundary-box.d.ts +2 -2
  11. package/node/{mat/closest-boundary-point → closest-boundary-point}/cull-by-tight-boundary-box.js +1 -1
  12. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -0
  13. package/node/closest-boundary-point/dd-deflate-with-running-error.d.ts +25 -0
  14. package/node/closest-boundary-point/dd-deflate-with-running-error.js +68 -0
  15. package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -0
  16. package/node/closest-boundary-point/foot-and-endpoint-info.d.ts +10 -0
  17. package/node/closest-boundary-point/foot-and-endpoint-info.js +2 -0
  18. package/node/closest-boundary-point/foot-and-endpoint-info.js.map +1 -0
  19. package/node/{mat/closest-boundary-point → closest-boundary-point}/get-best-distance-squared.d.ts +2 -2
  20. package/node/{mat/closest-boundary-point → closest-boundary-point}/get-best-distance-squared.js +2 -3
  21. package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -0
  22. package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +15 -0
  23. package/node/closest-boundary-point/get-close-boundary-points-certified.js +40 -0
  24. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -0
  25. package/node/closest-boundary-point/get-closest-boundary-point-certified.d.ts +15 -0
  26. package/node/closest-boundary-point/get-closest-boundary-point-certified.js +42 -0
  27. package/node/closest-boundary-point/get-closest-boundary-point-certified.js.map +1 -0
  28. package/node/closest-boundary-point/get-p-from-box.d.ts +3 -0
  29. package/node/closest-boundary-point/get-p-from-box.js +11 -0
  30. package/node/closest-boundary-point/get-p-from-box.js.map +1 -0
  31. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.d.ts +12 -0
  32. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +93 -0
  33. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -0
  34. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +13 -0
  35. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +58 -0
  36. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -0
  37. package/node/{contact-point.d.ts → contact-point/contact-point.d.ts} +3 -3
  38. package/node/{contact-point.js → contact-point/contact-point.js} +1 -5
  39. package/node/contact-point/contact-point.js.map +1 -0
  40. package/node/{compare-curvatures-at-interface.js → corner/compare-curvatures-at-interface.js} +2 -2
  41. package/node/corner/compare-curvatures-at-interface.js.map +1 -0
  42. package/node/{mat → corner}/corner.d.ts +1 -1
  43. package/node/{mat → corner}/corner.js.map +1 -1
  44. package/node/corner/get-corner.d.ts +15 -0
  45. package/node/{curve.js → corner/get-corner.js} +6 -17
  46. package/node/corner/get-corner.js.map +1 -0
  47. package/node/{get-interface-ccw.js → corner/get-interface-ccw.js} +18 -33
  48. package/node/corner/get-interface-ccw.js.map +1 -0
  49. package/node/cp-node/clone.d.ts +1 -1
  50. package/node/cp-node/clone.js +6 -4
  51. package/node/cp-node/clone.js.map +1 -1
  52. package/node/cp-node/cp-node.d.ts +196 -0
  53. package/node/cp-node/cp-node.js +249 -0
  54. package/node/cp-node/cp-node.js.map +1 -0
  55. package/node/cp-node/create-cp-node.d.ts +4 -0
  56. package/node/cp-node/create-cp-node.js +8 -0
  57. package/node/cp-node/create-cp-node.js.map +1 -0
  58. package/node/cp-node/enhance-cp-node.d.ts +24 -0
  59. package/node/cp-node/enhance-cp-node.js +20 -0
  60. package/node/cp-node/enhance-cp-node.js.map +1 -0
  61. package/node/{get-boundary-bezier-parts-to-next.js → cp-node/get-boundary-bezier-parts-to-next.js} +1 -1
  62. package/node/cp-node/get-boundary-bezier-parts-to-next.js.map +1 -0
  63. package/node/{get-boundary-beziers-to-next.d.ts → cp-node/get-boundary-beziers-to-next.d.ts} +1 -1
  64. package/node/{get-boundary-beziers-to-next.js → cp-node/get-boundary-beziers-to-next.js} +1 -1
  65. package/node/cp-node/get-boundary-beziers-to-next.js.map +1 -0
  66. package/node/cp-node/get-cp-node-ordering.d.ts +8 -0
  67. package/node/cp-node/get-cp-node-ordering.js +12 -0
  68. package/node/cp-node/get-cp-node-ordering.js.map +1 -0
  69. package/node/{get-curve-to-next.js → cp-node/get-curve-to-next.js} +1 -1
  70. package/node/cp-node/get-curve-to-next.js.map +1 -0
  71. package/node/cp-node/remove.d.ts +1 -1
  72. package/node/cp-node/traverse-cp.d.ts +12 -0
  73. package/node/cp-node/traverse-cp.js +26 -0
  74. package/node/cp-node/traverse-cp.js.map +1 -0
  75. package/node/{traverse-edges.js → cp-node/traverse-edges.js} +4 -3
  76. package/node/cp-node/traverse-edges.js.map +1 -0
  77. package/node/{traverse-vertices.js → cp-node/traverse-vertices.js} +4 -3
  78. package/node/cp-node/traverse-vertices.js.map +1 -0
  79. package/node/{curve.d.ts → curve/curve.d.ts} +4 -17
  80. package/node/curve/curve.js +14 -0
  81. package/node/curve/curve.js.map +1 -0
  82. package/node/debug/cp-node-for-debugging.d.ts +2 -2
  83. package/node/debug/debug-elem-types.d.ts +8 -8
  84. package/node/debug/debug.d.ts +6 -6
  85. package/node/debug/debug.js +2 -2
  86. package/node/debug/debug.js.map +1 -1
  87. package/node/debug/functions/draw-elem/bounding-hull.d.ts +2 -2
  88. package/node/debug/functions/draw-elem/bounding-hull.js +3 -3
  89. package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
  90. package/node/debug/functions/draw-elem/branch.d.ts +2 -2
  91. package/node/debug/functions/draw-elem/branch.js +4 -3
  92. package/node/debug/functions/draw-elem/branch.js.map +1 -1
  93. package/node/debug/functions/draw-elem/culls.d.ts +2 -2
  94. package/node/debug/functions/draw-elem/culls.js +2 -2
  95. package/node/debug/functions/draw-elem/culls.js.map +1 -1
  96. package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +1 -1
  97. package/node/debug/functions/draw-elem/draw-circle-percent.js +1 -1
  98. package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
  99. package/node/debug/functions/draw-elem/draw-elem.d.ts +3 -3
  100. package/node/debug/functions/draw-elem/draw-elem.js +3 -3
  101. package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
  102. package/node/debug/functions/draw-elem/dull-corner.d.ts +3 -3
  103. package/node/debug/functions/draw-elem/dull-corner.js +3 -4
  104. package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
  105. package/node/debug/functions/draw-elem/leaves.d.ts +2 -2
  106. package/node/debug/functions/draw-elem/leaves.js +1 -1
  107. package/node/debug/functions/draw-elem/leaves.js.map +1 -1
  108. package/node/debug/functions/draw-elem/loop.d.ts +2 -2
  109. package/node/debug/functions/draw-elem/loop.js +1 -2
  110. package/node/debug/functions/draw-elem/loop.js.map +1 -1
  111. package/node/debug/functions/draw-elem/loops.d.ts +1 -1
  112. package/node/debug/functions/draw-elem/loops.js +0 -1
  113. package/node/debug/functions/draw-elem/loops.js.map +1 -1
  114. package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +2 -2
  115. package/node/debug/functions/draw-elem/loose-bounding-box.js +3 -3
  116. package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
  117. package/node/debug/functions/draw-elem/mat.d.ts +3 -3
  118. package/node/debug/functions/draw-elem/mat.js +9 -7
  119. package/node/debug/functions/draw-elem/mat.js.map +1 -1
  120. package/node/debug/functions/draw-elem/max-vertex.d.ts +2 -2
  121. package/node/debug/functions/draw-elem/max-vertex.js +1 -1
  122. package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
  123. package/node/debug/functions/draw-elem/min-y.d.ts +3 -3
  124. package/node/debug/functions/draw-elem/min-y.js +2 -6
  125. package/node/debug/functions/draw-elem/min-y.js.map +1 -1
  126. package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +2 -2
  127. package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +2 -2
  128. package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js.map +1 -1
  129. package/node/debug/functions/draw-elem/one-prong.d.ts +2 -2
  130. package/node/debug/functions/draw-elem/one-prong.js +6 -11
  131. package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
  132. package/node/debug/functions/draw-elem/sharp-corner.d.ts +3 -3
  133. package/node/debug/functions/draw-elem/sharp-corner.js +3 -4
  134. package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
  135. package/node/debug/functions/draw-elem/three-prong.d.ts +2 -2
  136. package/node/debug/functions/draw-elem/three-prong.js +8 -10
  137. package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
  138. package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +2 -2
  139. package/node/debug/functions/draw-elem/tight-bounding-box.js +3 -3
  140. package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
  141. package/node/debug/functions/draw-elem/two-prong.d.ts +2 -2
  142. package/node/debug/functions/draw-elem/two-prong.js +7 -8
  143. package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
  144. package/node/debug/functions/draw-elem/vertex.d.ts +4 -3
  145. package/node/debug/functions/draw-elem/vertex.js +11 -9
  146. package/node/debug/functions/draw-elem/vertex.js.map +1 -1
  147. package/node/debug/functions/general.d.ts +8 -8
  148. package/node/debug/functions/general.js +8 -8
  149. package/node/debug/functions/general.js.map +1 -1
  150. package/node/debug/functions/three-prong.d.ts +2 -2
  151. package/node/debug/functions/three-prong.js +10 -13
  152. package/node/debug/functions/three-prong.js.map +1 -1
  153. package/node/debug/functions/two-prong.d.ts +16 -5
  154. package/node/debug/functions/two-prong.js +56 -58
  155. package/node/debug/functions/two-prong.js.map +1 -1
  156. package/node/debug/three-prong-for-debugging.d.ts +6 -6
  157. package/node/debug/three-prong-for-debugging.js +1 -1
  158. package/node/debug/three-prong-for-debugging.js.map +1 -1
  159. package/node/debug/two-prong-for-debugging.d.ts +7 -7
  160. package/node/error-analysis/gamma.d.ts +26 -0
  161. package/node/error-analysis/gamma.js +35 -0
  162. package/node/error-analysis/gamma.js.map +1 -0
  163. package/node/find-2-prong/add-1-prong.d.ts +12 -0
  164. package/node/{mat/find-mat → find-2-prong}/add-1-prong.js +11 -11
  165. package/node/find-2-prong/add-1-prong.js.map +1 -0
  166. package/node/{mat/find-mat → find-2-prong}/add-2-prong.d.ts +6 -9
  167. package/node/{mat/find-mat → find-2-prong}/add-2-prong.js +26 -74
  168. package/node/find-2-prong/add-2-prong.js.map +1 -0
  169. package/node/find-2-prong/add-debug-info.d.ts +8 -0
  170. package/node/{mat/find-mat/find-2-prong → find-2-prong}/add-debug-info.js +5 -4
  171. package/node/find-2-prong/add-debug-info.js.map +1 -0
  172. package/node/find-2-prong/cull-bezier-pieces.d.ts +11 -0
  173. package/node/find-2-prong/cull-bezier-pieces.js +28 -0
  174. package/node/find-2-prong/cull-bezier-pieces.js.map +1 -0
  175. package/node/{mat/find-mat/find-2-prong → find-2-prong}/find-2-prong.d.ts +9 -13
  176. package/node/find-2-prong/find-2-prong.js +144 -0
  177. package/node/find-2-prong/find-2-prong.js.map +1 -0
  178. package/node/find-2-prong/find-and-add-2-prongs-on-all-paths.d.ts +15 -0
  179. package/node/{mat/find-mat → find-2-prong}/find-and-add-2-prongs-on-all-paths.js +5 -4
  180. package/node/find-2-prong/find-and-add-2-prongs-on-all-paths.js.map +1 -0
  181. package/node/{mat/find-mat → find-2-prong}/find-and-add-2-prongs.d.ts +5 -5
  182. package/node/find-2-prong/find-and-add-2-prongs.js +60 -0
  183. package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -0
  184. package/node/{mat/find-mat → find-2-prong}/find-and-add-hole-closing-2-prongs.d.ts +3 -3
  185. package/node/{mat/find-mat → find-2-prong}/find-and-add-hole-closing-2-prongs.js +5 -5
  186. package/node/find-2-prong/find-and-add-hole-closing-2-prongs.js.map +1 -0
  187. package/node/find-2-prong/find-equidistant-point-on-line-dd.d.ts +10 -0
  188. package/node/find-2-prong/find-equidistant-point-on-line-dd.js +56 -0
  189. package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -0
  190. package/node/find-2-prong/get-initial-bezier-pieces.d.ts +15 -0
  191. package/node/find-2-prong/get-initial-bezier-pieces.js +40 -0
  192. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -0
  193. package/node/find-2-prong/reduce-radius.d.ts +8 -0
  194. package/node/find-2-prong/reduce-radius.js +72 -0
  195. package/node/find-2-prong/reduce-radius.js.map +1 -0
  196. package/node/find-2-prong/squared-distance-between-dd.d.ts +2 -0
  197. package/node/find-2-prong/squared-distance-between-dd.js +17 -0
  198. package/node/find-2-prong/squared-distance-between-dd.js.map +1 -0
  199. package/node/find-2-prong/x-for-debugging.d.ts +9 -0
  200. package/node/find-2-prong/x-for-debugging.js.map +1 -0
  201. package/node/{mat/find-mat → find-3-prong.ts}/add-3-prong.d.ts +12 -7
  202. package/node/find-3-prong.ts/add-3-prong.js +82 -0
  203. package/node/find-3-prong.ts/add-3-prong.js.map +1 -0
  204. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-better-x.d.ts +4 -4
  205. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-better-x.js +1 -1
  206. package/node/find-3-prong.ts/calc-better-x.js.map +1 -0
  207. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-initial-3-prong-center.d.ts +3 -3
  208. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-initial-3-prong-center.js +5 -7
  209. package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -0
  210. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/find-3-prong-for-delta3s.d.ts +6 -6
  211. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/find-3-prong-for-delta3s.js +11 -12
  212. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -0
  213. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/find-3-prong.d.ts +5 -5
  214. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/find-3-prong.js +52 -39
  215. package/node/find-3-prong.ts/find-3-prong.js.map +1 -0
  216. package/node/find-3-prong.ts/find-and-add-3-prongs.d.ts +5 -0
  217. package/node/find-3-prong.ts/find-and-add-3-prongs.js +74 -0
  218. package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -0
  219. package/node/{mat/find-mat/find-and-add-3-prongs.d.ts → find-3-prong.ts/find-and-add-all-3-prongs.d.ts} +3 -3
  220. package/node/find-3-prong.ts/find-and-add-all-3-prongs.js +66 -0
  221. package/node/find-3-prong.ts/find-and-add-all-3-prongs.js.map +1 -0
  222. package/node/{mat/find-mat/find-3-prong → find-3-prong.ts}/get-closest-points.d.ts +3 -3
  223. package/node/find-3-prong.ts/get-closest-points.js +14 -0
  224. package/node/find-3-prong.ts/get-closest-points.js.map +1 -0
  225. package/node/{mat/find-mat → find-mat}/add-debug-info.d.ts +4 -4
  226. package/node/{mat/find-mat → find-mat}/add-debug-info.js +6 -6
  227. package/node/find-mat/add-debug-info.js.map +1 -0
  228. package/node/{mat/find-mat → find-mat}/create-initial-cp-graph.d.ts +5 -5
  229. package/node/{mat/find-mat → find-mat}/create-initial-cp-graph.js +5 -6
  230. package/node/find-mat/create-initial-cp-graph.js.map +1 -0
  231. package/node/find-mat/find-mat.d.ts +10 -0
  232. package/node/find-mat/find-mat.js +57 -0
  233. package/node/find-mat/find-mat.js.map +1 -0
  234. package/node/{find-mats.d.ts → find-mat/find-mats.d.ts} +1 -1
  235. package/node/find-mat/find-mats.js +58 -0
  236. package/node/find-mat/find-mats.js.map +1 -0
  237. package/node/find-mat/fix-ordering.d.ts +8 -0
  238. package/node/find-mat/fix-ordering.js +59 -0
  239. package/node/find-mat/fix-ordering.js.map +1 -0
  240. package/node/find-mat/get-dull-corners.d.ts +5 -0
  241. package/node/find-mat/get-dull-corners.js +22 -0
  242. package/node/find-mat/get-dull-corners.js.map +1 -0
  243. package/node/find-mat/get-for-1-prongs-on-loop.d.ts +11 -0
  244. package/node/find-mat/get-for-1-prongs-on-loop.js +28 -0
  245. package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -0
  246. package/node/find-mat/get-for-2-prongs-on-loop.d.ts +11 -0
  247. package/node/find-mat/get-for-2-prongs-on-loop.js +30 -0
  248. package/node/find-mat/get-for-2-prongs-on-loop.js.map +1 -0
  249. package/node/find-mat/get-sharp-corners.d.ts +5 -0
  250. package/node/find-mat/get-sharp-corners.js +21 -0
  251. package/node/find-mat/get-sharp-corners.js.map +1 -0
  252. package/node/find-mat/get-size-params.d.ts +7 -0
  253. package/node/find-mat/get-size-params.js +33 -0
  254. package/node/find-mat/get-size-params.js.map +1 -0
  255. package/node/geometry/circle.js.map +1 -0
  256. package/node/geometry/get-bounding-box-.js.map +1 -0
  257. package/node/{mat/geometry → geometry}/get-closest-square-distance-to-rect.d.ts +1 -1
  258. package/node/{mat/geometry → geometry}/get-closest-square-distance-to-rect.js +1 -1
  259. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -0
  260. package/node/{mat/geometry → geometry}/get-closest-squared-distance-to-rotated-rect.d.ts +1 -1
  261. package/node/{mat/geometry → geometry}/get-closest-squared-distance-to-rotated-rect.js +1 -1
  262. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -0
  263. package/node/get-curve/get-curve-between.d.ts +1 -1
  264. package/node/get-curve/get-curve-between.js +2 -2
  265. package/node/get-curve/get-curve-between.js.map +1 -1
  266. package/node/get-curve/get-edge-direction.d.ts +2 -2
  267. package/node/get-curve/get-edge-direction.js +2 -4
  268. package/node/get-curve/get-edge-direction.js.map +1 -1
  269. package/node/index.d.ts +24 -20
  270. package/node/index.js +21 -16
  271. package/node/index.js.map +1 -1
  272. package/node/loop/get-max-coordinate.d.ts +1 -1
  273. package/node/loop/get-max-coordinate.js +1 -1
  274. package/node/mat/add-to-cp-graph.d.ts +8 -7
  275. package/node/mat/add-to-cp-graph.js +6 -4
  276. package/node/mat/add-to-cp-graph.js.map +1 -1
  277. package/node/mat/bezier-piece.d.ts +2 -2
  278. package/node/mat/create-new-cp-tree.d.ts +3 -3
  279. package/node/mat/create-new-cp-tree.js +5 -7
  280. package/node/mat/create-new-cp-tree.js.map +1 -1
  281. package/node/mat/elem-type-two-prong.d.ts +1 -1
  282. package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
  283. package/node/mat/get-boundary-piece-beziers.js +4 -4
  284. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  285. package/node/{get-branches.d.ts → mat/get-branches.d.ts} +1 -1
  286. package/node/{get-branches.js → mat/get-branches.js} +7 -6
  287. package/node/mat/get-branches.js.map +1 -0
  288. package/node/mat/get-largest-vertex.d.ts +2 -2
  289. package/node/mat/get-largest-vertex.js +1 -1
  290. package/node/mat/get-largest-vertex.js.map +1 -1
  291. package/node/mat/get-neighboring-cps.d.ts +6 -4
  292. package/node/mat/get-neighboring-cps.js +5 -3
  293. package/node/mat/get-neighboring-cps.js.map +1 -1
  294. package/node/mat/get-two-prong-type.d.ts +1 -1
  295. package/node/mat/get-two-prong-type.js +1 -1
  296. package/node/mat/get-two-prong-type.js.map +1 -1
  297. package/node/mat/is-another-cp-closeby.d.ts +9 -8
  298. package/node/mat/is-another-cp-closeby.js +21 -29
  299. package/node/mat/is-another-cp-closeby.js.map +1 -1
  300. package/node/{mat.d.ts → mat/mat.d.ts} +2 -2
  301. package/node/mat/mat.js.map +1 -0
  302. package/node/mat/simplify-mat-map-only.d.ts +1 -1
  303. package/node/mat/simplify-mat-map-only.js +4 -3
  304. package/node/mat/simplify-mat-map-only.js.map +1 -1
  305. package/node/{simplify-mat.d.ts → mat/simplify-mat.d.ts} +3 -5
  306. package/node/{simplify-mat.js → mat/simplify-mat.js} +11 -13
  307. package/node/mat/simplify-mat.js.map +1 -0
  308. package/node/mat/trim-mat.d.ts +1 -1
  309. package/node/mat/trim-mat.js +1 -1
  310. package/node/mat/trim-mat.js.map +1 -1
  311. package/node/point-on-shape/calc-pos-order.d.ts +13 -0
  312. package/node/point-on-shape/calc-pos-order.js +27 -0
  313. package/node/point-on-shape/calc-pos-order.js.map +1 -0
  314. package/node/point-on-shape/compare-poss.d.ts +10 -0
  315. package/node/point-on-shape/compare-poss.js +18 -0
  316. package/node/point-on-shape/compare-poss.js.map +1 -0
  317. package/node/point-on-shape/create-pos.d.ts +4 -0
  318. package/node/point-on-shape/create-pos.js +12 -0
  319. package/node/point-on-shape/create-pos.js.map +1 -0
  320. package/node/point-on-shape/get-osculating-circle.d.ts +10 -0
  321. package/node/point-on-shape/get-osculating-circle.js +25 -0
  322. package/node/point-on-shape/get-osculating-circle.js.map +1 -0
  323. package/node/point-on-shape/get-pos-corner.d.ts +7 -0
  324. package/node/point-on-shape/get-pos-corner.js +9 -0
  325. package/node/point-on-shape/get-pos-corner.js.map +1 -0
  326. package/node/point-on-shape/is-pos-corner.d.ts +6 -0
  327. package/node/point-on-shape/is-pos-corner.js +8 -0
  328. package/node/point-on-shape/is-pos-corner.js.map +1 -0
  329. package/node/point-on-shape/is-pos-dull-corner.d.ts +6 -0
  330. package/node/point-on-shape/is-pos-dull-corner.js +14 -0
  331. package/node/point-on-shape/is-pos-dull-corner.js.map +1 -0
  332. package/node/point-on-shape/is-pos-quite-sharp-corner.d.ts +6 -0
  333. package/node/point-on-shape/is-pos-quite-sharp-corner.js +14 -0
  334. package/node/point-on-shape/is-pos-quite-sharp-corner.js.map +1 -0
  335. package/node/point-on-shape/is-pos-sharp-corner.d.ts +6 -0
  336. package/node/point-on-shape/is-pos-sharp-corner.js +14 -0
  337. package/node/point-on-shape/is-pos-sharp-corner.js.map +1 -0
  338. package/node/point-on-shape/point-on-shape.d.ts +11 -0
  339. package/node/point-on-shape/point-on-shape.js +2 -0
  340. package/node/point-on-shape/point-on-shape.js.map +1 -0
  341. package/node/point-on-shape/pos-to-human-string.d.ts +8 -0
  342. package/node/point-on-shape/pos-to-human-string.js +12 -0
  343. package/node/point-on-shape/pos-to-human-string.js.map +1 -0
  344. package/node/{mat/to-scale-axis → sat}/add-debug-info.d.ts +2 -2
  345. package/node/{mat/to-scale-axis → sat}/add-debug-info.js +1 -1
  346. package/node/sat/add-debug-info.js.map +1 -0
  347. package/node/{mat/to-scale-axis → sat}/cull-non-cycles.d.ts +3 -3
  348. package/node/{mat/to-scale-axis → sat}/cull-non-cycles.js +6 -6
  349. package/node/sat/cull-non-cycles.js.map +1 -0
  350. package/node/{mat/to-scale-axis → sat}/cull.d.ts +3 -3
  351. package/node/{mat/to-scale-axis → sat}/cull.js +4 -4
  352. package/node/sat/cull.js.map +1 -0
  353. package/node/{mat → sat}/get-leaves.d.ts +2 -2
  354. package/node/sat/get-leaves.js +14 -0
  355. package/node/sat/get-leaves.js.map +1 -0
  356. package/node/{to-scale-axis.d.ts → sat/to-scale-axis.d.ts} +2 -2
  357. package/node/{to-scale-axis.js → sat/to-scale-axis.js} +11 -10
  358. package/node/sat/to-scale-axis.js.map +1 -0
  359. package/node/svg/get-loop-bounds.d.ts +7 -7
  360. package/node/svg/get-loop-bounds.js +11 -7
  361. package/node/svg/get-loop-bounds.js.map +1 -1
  362. package/node/svg/get-min-y-pos.d.ts +4 -4
  363. package/node/svg/get-min-y-pos.js +1 -1
  364. package/node/svg/get-shape-bounds.d.ts +6 -5
  365. package/node/svg/get-shape-bounds.js +6 -2
  366. package/node/svg/get-shape-bounds.js.map +1 -1
  367. package/node/sweep-line/sweep-line.d.ts +1 -1
  368. package/node/sweep-line/sweep-line.js +4 -4
  369. package/node/sweep-line/sweep-line.js.map +1 -1
  370. package/package.json +10 -10
  371. package/src/closest-boundary-point/closest-points-on-curve-precise.ts +75 -0
  372. package/src/closest-boundary-point/closest-points-on-curve.ts +72 -0
  373. package/src/closest-boundary-point/cull-bezier-pieces.ts +35 -0
  374. package/src/{mat/closest-boundary-point → closest-boundary-point}/cull-by-loose-bounding-box.ts +4 -3
  375. package/src/{mat/closest-boundary-point → closest-boundary-point}/cull-by-tight-boundary-box.ts +2 -2
  376. package/src/closest-boundary-point/dd-deflate-with-running-error.ts +88 -0
  377. package/src/closest-boundary-point/foot-and-endpoint-info.ts +16 -0
  378. package/src/{mat/closest-boundary-point → closest-boundary-point}/get-best-distance-squared.ts +3 -4
  379. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +69 -0
  380. package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +70 -0
  381. package/src/closest-boundary-point/get-p-from-box.ts +14 -0
  382. package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +122 -0
  383. package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +75 -0
  384. package/src/{contact-point.ts → contact-point/contact-point.ts} +4 -6
  385. package/src/{compare-curvatures-at-interface.ts → corner/compare-curvatures-at-interface.ts} +2 -2
  386. package/src/{mat → corner}/corner.ts +1 -1
  387. package/src/{curve.ts → corner/get-corner.ts} +10 -49
  388. package/src/{get-interface-ccw.ts → corner/get-interface-ccw.ts} +28 -35
  389. package/src/cp-node/clone.ts +17 -6
  390. package/src/cp-node/cp-node.ts +422 -0
  391. package/src/cp-node/create-cp-node.ts +21 -0
  392. package/src/cp-node/enhance-cp-node.ts +27 -0
  393. package/src/{get-boundary-bezier-parts-to-next.ts → cp-node/get-boundary-bezier-parts-to-next.ts} +3 -3
  394. package/src/{get-boundary-beziers-to-next.ts → cp-node/get-boundary-beziers-to-next.ts} +2 -2
  395. package/src/cp-node/get-cp-node-ordering.ts +17 -0
  396. package/src/{get-curve-to-next.ts → cp-node/get-curve-to-next.ts} +1 -1
  397. package/src/cp-node/remove.ts +1 -1
  398. package/src/cp-node/traverse-cp.ts +35 -0
  399. package/src/{traverse-edges.ts → cp-node/traverse-edges.ts} +5 -5
  400. package/src/{traverse-vertices.ts → cp-node/traverse-vertices.ts} +5 -5
  401. package/src/curve/curve.ts +46 -0
  402. package/src/debug/cp-node-for-debugging.ts +2 -2
  403. package/src/debug/debug-elem-types.ts +8 -8
  404. package/src/debug/debug.ts +11 -11
  405. package/src/debug/functions/draw-elem/bounding-hull.ts +5 -3
  406. package/src/debug/functions/draw-elem/branch.ts +4 -4
  407. package/src/debug/functions/draw-elem/culls.ts +3 -3
  408. package/src/debug/functions/draw-elem/draw-circle-percent.ts +1 -1
  409. package/src/debug/functions/draw-elem/draw-elem.ts +10 -6
  410. package/src/debug/functions/draw-elem/dull-corner.ts +10 -6
  411. package/src/debug/functions/draw-elem/leaves.ts +2 -2
  412. package/src/debug/functions/draw-elem/loop.ts +4 -3
  413. package/src/debug/functions/draw-elem/loops.ts +1 -2
  414. package/src/debug/functions/draw-elem/loose-bounding-box.ts +8 -3
  415. package/src/debug/functions/draw-elem/mat.ts +16 -8
  416. package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
  417. package/src/debug/functions/draw-elem/min-y.ts +4 -9
  418. package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +10 -2
  419. package/src/debug/functions/draw-elem/one-prong.ts +12 -15
  420. package/src/debug/functions/draw-elem/sharp-corner.ts +10 -6
  421. package/src/debug/functions/draw-elem/three-prong.ts +13 -11
  422. package/src/debug/functions/draw-elem/tight-bounding-box.ts +9 -3
  423. package/src/debug/functions/draw-elem/two-prong.ts +12 -8
  424. package/src/debug/functions/draw-elem/vertex.ts +12 -11
  425. package/src/debug/functions/general.ts +10 -10
  426. package/src/debug/functions/three-prong.ts +16 -20
  427. package/src/debug/functions/two-prong.ts +89 -77
  428. package/src/debug/three-prong-for-debugging.ts +17 -16
  429. package/src/debug/two-prong-for-debugging.ts +7 -7
  430. package/src/error-analysis/gamma.ts +41 -0
  431. package/src/{mat/find-mat → find-2-prong}/add-1-prong.ts +19 -16
  432. package/src/{mat/find-mat → find-2-prong}/add-2-prong.ts +45 -91
  433. package/src/find-2-prong/add-debug-info.ts +49 -0
  434. package/src/{mat/find-mat/find-2-prong → find-2-prong}/cull-bezier-pieces.ts +9 -11
  435. package/src/find-2-prong/find-2-prong.ts +191 -0
  436. package/src/{mat/find-mat → find-2-prong}/find-and-add-2-prongs-on-all-paths.ts +12 -9
  437. package/src/find-2-prong/find-and-add-2-prongs.ts +88 -0
  438. package/src/{mat/find-mat → find-2-prong}/find-and-add-hole-closing-2-prongs.ts +7 -7
  439. package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +77 -0
  440. package/src/{mat/find-mat/find-2-prong → find-2-prong}/find-equidistant-point-on-line.ts +1 -1
  441. package/src/find-2-prong/get-initial-bezier-pieces.ts +61 -0
  442. package/src/find-2-prong/pyth-trips.ts +146 -0
  443. package/src/find-2-prong/reduce-radius.ts +98 -0
  444. package/src/find-2-prong/squared-distance-between-dd.ts +25 -0
  445. package/src/find-2-prong/x-for-debugging.ts +13 -0
  446. package/src/find-3-prong.ts/add-3-prong.ts +110 -0
  447. package/src/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-better-x.ts +5 -5
  448. package/src/{mat/find-mat/find-3-prong → find-3-prong.ts}/calc-initial-3-prong-center.ts +11 -12
  449. package/src/{mat/find-mat/find-3-prong → find-3-prong.ts}/find-3-prong-for-delta3s.ts +28 -28
  450. package/src/find-3-prong.ts/find-3-prong.ts +148 -0
  451. package/src/find-3-prong.ts/find-and-add-3-prongs.ts +111 -0
  452. package/src/find-3-prong.ts/find-and-add-all-3-prongs.ts +109 -0
  453. package/src/find-3-prong.ts/get-closest-points.ts +24 -0
  454. package/src/{mat/find-mat → find-mat}/add-debug-info.ts +10 -10
  455. package/src/{mat/find-mat → find-mat}/create-initial-cp-graph.ts +11 -12
  456. package/src/find-mat/find-mat.ts +89 -0
  457. package/src/find-mat/find-mats.ts +83 -0
  458. package/src/find-mat/fix-ordering.ts +69 -0
  459. package/src/find-mat/get-dull-corners.ts +34 -0
  460. package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -0
  461. package/src/find-mat/get-for-2-prongs-on-loop.ts +44 -0
  462. package/src/find-mat/get-sharp-corners.ts +33 -0
  463. package/src/find-mat/get-size-params.ts +34 -0
  464. package/src/{mat/find-mat → find-mat}/get-total-by.ts +4 -4
  465. package/src/{mat/geometry → geometry}/get-closest-square-distance-to-rect.ts +1 -1
  466. package/src/{mat/geometry → geometry}/get-closest-squared-distance-to-rotated-rect.ts +2 -2
  467. package/src/get-curve/get-curve-between.ts +7 -7
  468. package/src/get-curve/get-edge-direction.ts +11 -11
  469. package/src/index.ts +64 -21
  470. package/src/loop/get-max-coordinate.ts +1 -1
  471. package/src/mat/add-to-cp-graph.ts +15 -12
  472. package/src/mat/bezier-piece.ts +2 -2
  473. package/src/mat/cmp-cp-on-delta.ts +6 -3
  474. package/src/mat/create-new-cp-tree.ts +6 -9
  475. package/src/mat/elem-type-two-prong.ts +1 -1
  476. package/src/mat/get-boundary-piece-beziers.ts +7 -7
  477. package/src/{get-branches.ts → mat/get-branches.ts} +8 -8
  478. package/src/mat/get-edges-as-array.ts +2 -2
  479. package/src/mat/get-largest-three-prong.ts +3 -3
  480. package/src/mat/get-largest-vertex.ts +2 -2
  481. package/src/mat/get-neighboring-cps.ts +9 -6
  482. package/src/mat/get-two-prong-type.ts +1 -1
  483. package/src/mat/is-another-cp-closeby.ts +29 -44
  484. package/src/{mat.ts → mat/mat.ts} +2 -2
  485. package/src/mat/simplify-mat-map-only.ts +5 -5
  486. package/src/{simplify-mat.ts → mat/simplify-mat.ts} +12 -14
  487. package/src/mat/trim-mat.ts +3 -3
  488. package/src/point-on-shape/calc-pos-order.ts +35 -0
  489. package/src/point-on-shape/compare-poss.ts +26 -0
  490. package/src/point-on-shape/create-pos.ts +21 -0
  491. package/src/point-on-shape/get-osculating-circle.ts +39 -0
  492. package/src/point-on-shape/get-pos-corner.ts +16 -0
  493. package/src/point-on-shape/is-pos-corner.ts +12 -0
  494. package/src/point-on-shape/is-pos-dull-corner.ts +16 -0
  495. package/src/point-on-shape/is-pos-quite-dull-corner.ts +17 -0
  496. package/src/point-on-shape/is-pos-quite-sharp-corner.ts +17 -0
  497. package/src/point-on-shape/is-pos-sharp-corner.ts +17 -0
  498. package/src/point-on-shape/point-on-shape.ts +15 -0
  499. package/src/point-on-shape/pos-to-human-string.ts +16 -0
  500. package/src/{mat/to-scale-axis → sat}/add-debug-info.ts +3 -3
  501. package/src/{mat/to-scale-axis → sat}/cull-non-cycles.ts +7 -7
  502. package/src/{mat/to-scale-axis → sat}/cull.ts +6 -6
  503. package/src/{mat → sat}/get-leaves.ts +4 -4
  504. package/src/{mat/to-scale-axis → sat}/t-tree.ts +2 -2
  505. package/src/{to-scale-axis.ts → sat/to-scale-axis.ts} +16 -16
  506. package/src/{mat/to-scale-axis → sat}/traverse-spacial-tree.ts +5 -5
  507. package/src/svg/get-loop-bounds.ts +22 -17
  508. package/src/svg/get-min-y-pos.ts +3 -3
  509. package/src/svg/get-shape-bounds.ts +12 -9
  510. package/src/sweep-line/are-boxes-intersecting.ts +1 -1
  511. package/src/sweep-line/sweep-line.ts +7 -7
  512. package/tsconfig.json +3 -7
  513. package/wallaby.mjs +32 -0
  514. package/node/circle.js.map +0 -1
  515. package/node/compare-curvatures-at-interface.js.map +0 -1
  516. package/node/contact-point.js.map +0 -1
  517. package/node/cp-node.d.ts +0 -202
  518. package/node/cp-node.js +0 -321
  519. package/node/cp-node.js.map +0 -1
  520. package/node/curve.js.map +0 -1
  521. package/node/find-mats.js +0 -123
  522. package/node/find-mats.js.map +0 -1
  523. package/node/get-boundary-bezier-parts-to-next.js.map +0 -1
  524. package/node/get-boundary-beziers-to-next.js.map +0 -1
  525. package/node/get-bounding-box-.js.map +0 -1
  526. package/node/get-branches.js.map +0 -1
  527. package/node/get-curve-to-next.js.map +0 -1
  528. package/node/get-interface-ccw.js.map +0 -1
  529. package/node/loop.d.ts +0 -16
  530. package/node/loop.js +0 -35
  531. package/node/loop.js.map +0 -1
  532. package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +0 -14
  533. package/node/mat/closest-boundary-point/closest-points-on-curve.js +0 -73
  534. package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +0 -1
  535. package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +0 -9
  536. package/node/mat/closest-boundary-point/cull-bezier-pieces.js +0 -20
  537. package/node/mat/closest-boundary-point/cull-bezier-pieces.js.map +0 -1
  538. package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
  539. package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
  540. package/node/mat/closest-boundary-point/get-best-distance-squared.js.map +0 -1
  541. package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +0 -17
  542. package/node/mat/closest-boundary-point/get-close-boundary-points.js +0 -81
  543. package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +0 -1
  544. package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +0 -18
  545. package/node/mat/closest-boundary-point/get-closest-boundary-point.js +0 -41
  546. package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +0 -1
  547. package/node/mat/find-mat/add-1-prong.d.ts +0 -12
  548. package/node/mat/find-mat/add-1-prong.js.map +0 -1
  549. package/node/mat/find-mat/add-2-prong.js.map +0 -1
  550. package/node/mat/find-mat/add-3-prong.js +0 -55
  551. package/node/mat/find-mat/add-3-prong.js.map +0 -1
  552. package/node/mat/find-mat/add-debug-info.js.map +0 -1
  553. package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +0 -11
  554. package/node/mat/find-mat/create-get-interesting-points-on-loop.js +0 -52
  555. package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +0 -1
  556. package/node/mat/find-mat/create-initial-cp-graph.js.map +0 -1
  557. package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +0 -8
  558. package/node/mat/find-mat/find-2-prong/add-debug-info.js.map +0 -1
  559. package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +0 -11
  560. package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +0 -30
  561. package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js.map +0 -1
  562. package/node/mat/find-mat/find-2-prong/find-2-prong.js +0 -233
  563. package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +0 -1
  564. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +0 -9
  565. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +0 -40
  566. package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js.map +0 -1
  567. package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +0 -11
  568. package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +0 -38
  569. package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js.map +0 -1
  570. package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +0 -9
  571. package/node/mat/find-mat/find-2-prong/x-for-debugging.js.map +0 -1
  572. package/node/mat/find-mat/find-3-prong/calc-better-x.js.map +0 -1
  573. package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js.map +0 -1
  574. package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js.map +0 -1
  575. package/node/mat/find-mat/find-3-prong/find-3-prong.js.map +0 -1
  576. package/node/mat/find-mat/find-3-prong/get-closest-points.js +0 -17
  577. package/node/mat/find-mat/find-3-prong/get-closest-points.js.map +0 -1
  578. package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +0 -15
  579. package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js.map +0 -1
  580. package/node/mat/find-mat/find-and-add-2-prongs.js +0 -74
  581. package/node/mat/find-mat/find-and-add-2-prongs.js.map +0 -1
  582. package/node/mat/find-mat/find-and-add-3-prongs.js +0 -147
  583. package/node/mat/find-mat/find-and-add-3-prongs.js.map +0 -1
  584. package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js.map +0 -1
  585. package/node/mat/find-mat/get-potential-2-prongs.d.ts +0 -4
  586. package/node/mat/find-mat/get-potential-2-prongs.js +0 -17
  587. package/node/mat/find-mat/get-potential-2-prongs.js.map +0 -1
  588. package/node/mat/find-mat/get-sharp-corners.d.ts +0 -4
  589. package/node/mat/find-mat/get-sharp-corners.js +0 -18
  590. package/node/mat/find-mat/get-sharp-corners.js.map +0 -1
  591. package/node/mat/geometry/get-closest-square-distance-to-rect.js.map +0 -1
  592. package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +0 -1
  593. package/node/mat/get-contact-circles-at-interface.d.ts +0 -8
  594. package/node/mat/get-contact-circles-at-interface.js +0 -21
  595. package/node/mat/get-contact-circles-at-interface.js.map +0 -1
  596. package/node/mat/get-leaves.js +0 -13
  597. package/node/mat/get-leaves.js.map +0 -1
  598. package/node/mat/to-scale-axis/add-debug-info.js.map +0 -1
  599. package/node/mat/to-scale-axis/cull-non-cycles.js.map +0 -1
  600. package/node/mat/to-scale-axis/cull.js.map +0 -1
  601. package/node/mat.js.map +0 -1
  602. package/node/point-on-shape.d.ts +0 -73
  603. package/node/point-on-shape.js +0 -168
  604. package/node/point-on-shape.js.map +0 -1
  605. package/node/simplify-mat.js.map +0 -1
  606. package/node/to-scale-axis.js.map +0 -1
  607. package/node/traverse-edges.js.map +0 -1
  608. package/node/traverse-vertices.js.map +0 -1
  609. package/src/cp-node.ts +0 -388
  610. package/src/find-mats.ts +0 -171
  611. package/src/loop.ts +0 -56
  612. package/src/mat/closest-boundary-point/closest-point-on-curve-old.ts_ +0 -88
  613. package/src/mat/closest-boundary-point/closest-point-on-curve.ts_ +0 -95
  614. package/src/mat/closest-boundary-point/closest-points-on-curve.ts +0 -84
  615. package/src/mat/closest-boundary-point/cull-bezier-pieces.ts +0 -38
  616. package/src/mat/closest-boundary-point/get-close-boundary-points.ts +0 -107
  617. package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +0 -64
  618. package/src/mat/find-mat/add-3-prong.ts +0 -75
  619. package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +0 -73
  620. package/src/mat/find-mat/find-2-prong/add-debug-info.ts +0 -46
  621. package/src/mat/find-mat/find-2-prong/find-2-prong.ts +0 -316
  622. package/src/mat/find-mat/find-2-prong/get-initial-bezier-pieces.ts +0 -52
  623. package/src/mat/find-mat/find-2-prong/x-for-debugging.ts +0 -13
  624. package/src/mat/find-mat/find-3-prong/find-3-prong.ts +0 -106
  625. package/src/mat/find-mat/find-3-prong/get-closest-points.ts +0 -28
  626. package/src/mat/find-mat/find-and-add-2-prongs.ts +0 -108
  627. package/src/mat/find-mat/find-and-add-3-prongs.ts +0 -218
  628. package/src/mat/find-mat/get-potential-2-prongs.ts +0 -24
  629. package/src/mat/find-mat/get-sharp-corners.ts +0 -25
  630. package/src/mat/find-mat/get-total-abs-curvature.ts +0 -17
  631. package/src/mat/get-contact-circles-at-interface.ts +0 -26
  632. package/src/mat/to-scale-axis/add-to-tree.ts +0 -66
  633. package/src/mat/to-scale-axis/calc-groups.ts +0 -82
  634. package/src/mat/to-scale-axis/create-spacial-tree.ts +0 -41
  635. package/src/mat/to-scale-axis/get-engulfed-vertices.ts +0 -135
  636. package/src/point-on-shape.ts +0 -231
  637. package/src/svg/get-curvature-at-interface.ts +0 -55
  638. /package/node/{compare-curvatures-at-interface.d.ts → corner/compare-curvatures-at-interface.d.ts} +0 -0
  639. /package/node/{mat → corner}/corner.js +0 -0
  640. /package/node/{get-interface-ccw.d.ts → corner/get-interface-ccw.d.ts} +0 -0
  641. /package/node/{get-boundary-bezier-parts-to-next.d.ts → cp-node/get-boundary-bezier-parts-to-next.d.ts} +0 -0
  642. /package/node/{get-curve-to-next.d.ts → cp-node/get-curve-to-next.d.ts} +0 -0
  643. /package/node/{traverse-edges.d.ts → cp-node/traverse-edges.d.ts} +0 -0
  644. /package/node/{traverse-vertices.d.ts → cp-node/traverse-vertices.d.ts} +0 -0
  645. /package/node/{mat/find-mat/find-2-prong → find-2-prong}/x-for-debugging.js +0 -0
  646. /package/node/{circle.d.ts → geometry/circle.d.ts} +0 -0
  647. /package/node/{circle.js → geometry/circle.js} +0 -0
  648. /package/node/{get-bounding-box-.d.ts → geometry/get-bounding-box-.d.ts} +0 -0
  649. /package/node/{get-bounding-box-.js → geometry/get-bounding-box-.js} +0 -0
  650. /package/node/{mat.js → mat/mat.js} +0 -0
  651. /package/src/{circle.ts → geometry/circle.ts} +0 -0
  652. /package/src/{get-bounding-box-.ts → geometry/get-bounding-box-.ts} +0 -0
@@ -1,20 +1,20 @@
1
- import { CpNode } from '../cp-node.js';
2
- import { IPointOnShape } from '../point-on-shape.js';
3
- import { Circle } from '../circle.js';
1
+ import { CpNode } from '../cp-node/cp-node.js';
2
+ import { PointOnShape } from '../point-on-shape/point-on-shape.js';
3
+ import { Circle } from '../geometry/circle.js';
4
4
  import { BezierPiece } from '../mat/bezier-piece.js';
5
5
  import { Generated } from './debug.js';
6
- /** @hidden */
6
+ /** @internal */
7
7
  interface TwoProngForDebugging {
8
8
  generated: Generated;
9
9
  bezierPieces: BezierPiece[];
10
- pos: IPointOnShape;
10
+ pos: PointOnShape;
11
11
  δ: CpNode[];
12
12
  z: number[];
13
13
  circle: Circle;
14
14
  xs: {
15
15
  x: number[];
16
- y: IPointOnShape;
17
- z: IPointOnShape;
16
+ y: PointOnShape;
17
+ z: PointOnShape;
18
18
  t: number;
19
19
  }[];
20
20
  failed: boolean;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The canonical floating point error function, γ.
3
+ *
4
+ * * roughly `=== n * (Number.EPSILON / 2)`
5
+ * * see e.g. [Algorithms for Accurate, Validated and Fast Polynomial Evaluation](https://hal.archives-ouvertes.fr/hal-00285603/document)
6
+ * @param n the parameter - typically a small positive integer, e.g. for
7
+ * polynomial evaluation this === 2*d + 1, where d is the degree of the
8
+ * polynomial
9
+ *
10
+ * @doc
11
+ */
12
+ declare function γ(n: number): number;
13
+ /**
14
+ * The canonical, once compensated (implying double-double precision),
15
+ * floating point error function.
16
+ *
17
+ * * roughly `=== n * (Number.EPSILON / 2)**2`
18
+ * * see e.g. [Algorithms for Accurate, Validated and Fast Polynomial Evaluation](https://hal.archives-ouvertes.fr/hal-00285603/document)
19
+ * @param n the parameter - typically a small positive integer, e.g. for
20
+ * polynomial evaluation this === 2*d + 1, where d is the degree of the
21
+ * polynomial
22
+ *
23
+ * @doc
24
+ */
25
+ declare function γγ(n: number): number;
26
+ export { γ, γγ };
@@ -0,0 +1,35 @@
1
+ const u = Number.EPSILON / 2;
2
+ const uu = u * u;
3
+ /**
4
+ * The canonical floating point error function, γ.
5
+ *
6
+ * * roughly `=== n * (Number.EPSILON / 2)`
7
+ * * see e.g. [Algorithms for Accurate, Validated and Fast Polynomial Evaluation](https://hal.archives-ouvertes.fr/hal-00285603/document)
8
+ * @param n the parameter - typically a small positive integer, e.g. for
9
+ * polynomial evaluation this === 2*d + 1, where d is the degree of the
10
+ * polynomial
11
+ *
12
+ * @doc
13
+ */
14
+ function γ(n) {
15
+ const nu = n * u;
16
+ return nu / (1 - nu);
17
+ }
18
+ /**
19
+ * The canonical, once compensated (implying double-double precision),
20
+ * floating point error function.
21
+ *
22
+ * * roughly `=== n * (Number.EPSILON / 2)**2`
23
+ * * see e.g. [Algorithms for Accurate, Validated and Fast Polynomial Evaluation](https://hal.archives-ouvertes.fr/hal-00285603/document)
24
+ * @param n the parameter - typically a small positive integer, e.g. for
25
+ * polynomial evaluation this === 2*d + 1, where d is the degree of the
26
+ * polynomial
27
+ *
28
+ * @doc
29
+ */
30
+ function γγ(n) {
31
+ const nuu = n * uu;
32
+ return nuu / (1 - nuu);
33
+ }
34
+ export { γ, γγ };
35
+ //# sourceMappingURL=gamma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gamma.js","sourceRoot":"","sources":["../../src/error-analysis/gamma.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;AAC7B,MAAM,EAAE,GAAG,CAAC,GAAC,CAAC,CAAC;AAGf;;;;;;;;;;GAUG;AACH,SAAS,CAAC,CAAC,CAAS;IAChB,MAAM,EAAE,GAAG,CAAC,GAAC,CAAC,CAAC;IAEf,OAAO,EAAE,GAAC,CAAC,CAAC,GAAC,EAAE,CAAC,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,EAAE,CAAC,CAAS;IACjB,MAAM,GAAG,GAAG,CAAC,GAAC,EAAE,CAAC;IAEjB,OAAO,GAAG,GAAC,CAAC,CAAC,GAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAGD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { LlRbTree } from 'flo-ll-rb-tree';
2
+ import { Loop } from 'flo-boolean';
3
+ import { CpNode } from '../cp-node/cp-node.js';
4
+ import { PointOnShape } from '../point-on-shape/point-on-shape.js';
5
+ /**
6
+ * @hidden
7
+ * Add a 1-prong to the MAT.
8
+ * @param cpGraphs
9
+ * @param pos
10
+ */
11
+ declare function add1Prong(radius: number, center: number[], cpGraphs: Map<Loop, LlRbTree<CpNode>>, pos: PointOnShape): void;
12
+ export { add1Prong };
@@ -1,13 +1,14 @@
1
- import { getOsculatingCircle, calcPosOrder, isPosDullCorner } from '../../point-on-shape.js';
2
- import { addToCpGraph } from '../add-to-cp-graph.js';
3
- import { isAnotherCpCloseby } from '../is-another-cp-closeby.js';
1
+ import { addToCpGraph } from '../mat/add-to-cp-graph.js';
2
+ import { isAnotherCpCloseby } from '../mat/is-another-cp-closeby.js';
3
+ import { isPosDullCorner } from '../point-on-shape/is-pos-dull-corner.js';
4
+ import { calcPosOrder } from '../point-on-shape/calc-pos-order.js';
4
5
  /**
5
6
  * @hidden
6
7
  * Add a 1-prong to the MAT.
7
8
  * @param cpGraphs
8
9
  * @param pos
9
10
  */
10
- function add1Prong(maxOsculatingCircleRadius, cpGraphs, pos) {
11
+ function add1Prong(radius, center, cpGraphs, pos) {
11
12
  //if (PointOnShape.isDullCorner(pos)) {
12
13
  if (isPosDullCorner(pos)) {
13
14
  // This is a 1-prong at a dull corner.
@@ -21,22 +22,21 @@ function add1Prong(maxOsculatingCircleRadius, cpGraphs, pos) {
21
22
  // Afterthought: there is a better way - split points by two prongs.
22
23
  //toRemove.push(posNode); // this!
23
24
  if (typeof _debug_ !== 'undefined') {
24
- _debug_.generated.elems.oneProngAtDullCorner.push(pos);
25
+ // _debug_.generated.elems.oneProngAtDullCorner.push(pos);
25
26
  }
26
27
  return;
27
28
  }
28
- //let circle = PointOnShape.getOsculatingCircle(maxOsculatingCircleRadius, pos);
29
- const circle = getOsculatingCircle(maxOsculatingCircleRadius, pos);
30
- //const order = PointOnShape.calcOrder(circle, pos);
29
+ // const circle = getOsculatingCircle(maxOsculatingCircleRadius, pos);
30
+ const circle = { radius, center };
31
31
  const order = calcPosOrder(circle, pos);
32
32
  // Make sure there isn't already a ContactPoint close by - it can cause
33
33
  // floating point stability issues.
34
- if (isAnotherCpCloseby(cpGraphs, pos, circle, order, 0, 1000, 'magenta')) {
34
+ if (isAnotherCpCloseby(cpGraphs, pos, circle, order, 0, 1000)) {
35
35
  return;
36
36
  }
37
- addToCpGraph(circle, [-0.5, +0.5], cpGraphs, [pos, pos]);
37
+ const cpNodes = addToCpGraph(circle, [-0.5, +0.5], cpGraphs, [pos, pos]);
38
38
  if (typeof _debug_ !== 'undefined') {
39
- _debug_.generated.elems.oneProng.push(pos);
39
+ _debug_.generated.elems.oneProng.push(cpNodes);
40
40
  }
41
41
  }
42
42
  export { add1Prong };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-1-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/add-1-prong.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;A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';
3
- import { CpNode } from '../../cp-node.js';
4
- import { Circle } from '../../circle.js';
5
- import { IPointOnShape } from '../../point-on-shape.js';
2
+ import { Loop } from 'flo-boolean';
3
+ import { CpNode } from '../cp-node/cp-node.js';
4
+ import { Circle } from '../geometry/circle.js';
5
+ import { PointOnShape } from '../point-on-shape/point-on-shape.js';
6
6
  /**
7
- * @hidden
7
+ * @internal
8
8
  * Adds a 2-prong contact circle to the shape.
9
9
  * @param cpGraphs
10
10
  * @param circle Circle containing the 2 contact points
@@ -14,8 +14,5 @@ import { IPointOnShape } from '../../point-on-shape.js';
14
14
  * @param extreme The maximum coordinate value used to calculate floating point
15
15
  * tolerances.
16
16
  */
17
- declare function add2Prong(cpGraphs: Map<Loop, LlRbTree<CpNode>>, circle: Circle, posSource: IPointOnShape, posAntipodes: {
18
- pos: IPointOnShape;
19
- d: number;
20
- }[], holeClosing: boolean, extreme: number): CpNode;
17
+ declare function add2Prong(cpGraphs: Map<Loop, LlRbTree<CpNode>>, circle: Circle, posSource: PointOnShape, posAntipodes: PointOnShape[], holeClosing: boolean, extreme: number): CpNode | undefined;
21
18
  export { add2Prong };
@@ -1,10 +1,10 @@
1
- import { exponent } from 'big-float-ts';
2
- import { CpNode } from '../../cp-node.js';
3
- import { PointOnShape, calcPosOrder } from '../../point-on-shape.js';
4
- import { isAnotherCpCloseby } from '../is-another-cp-closeby.js';
5
- import { getNeighbouringPoints } from '../get-neighboring-cps.js';
1
+ import { insertCpNode } from '../cp-node/cp-node.js';
2
+ import { calcPosOrder } from '../point-on-shape/calc-pos-order.js';
3
+ import { createPos } from '../point-on-shape/create-pos.js';
4
+ import { isAnotherCpCloseby } from '../mat/is-another-cp-closeby.js';
5
+ import { getNeighbouringPoints } from '../mat/get-neighboring-cps.js';
6
6
  /**
7
- * @hidden
7
+ * @internal
8
8
  * Adds a 2-prong contact circle to the shape.
9
9
  * @param cpGraphs
10
10
  * @param circle Circle containing the 2 contact points
@@ -15,33 +15,25 @@ import { getNeighbouringPoints } from '../get-neighboring-cps.js';
15
15
  * tolerances.
16
16
  */
17
17
  function add2Prong(cpGraphs, circle, posSource, posAntipodes, holeClosing, extreme) {
18
- //let orderSource = PointOnShape.calcOrder(circle, posSource);
19
- const orderSource = calcPosOrder(circle, posSource);
20
- const orderAntipodes = posAntipodes.map(posAntipode => {
21
- //console.log(circle.center)
22
- //return PointOnShape.calcOrder(circle, posAntipode.pos);
23
- return calcPosOrder(circle, posAntipode.pos);
24
- });
25
18
  let t_s = posSource.t;
26
- let curve;
27
19
  if (t_s === 0) {
28
20
  t_s = 1;
29
- curve = posSource.curve.prev;
30
- posSource = new PointOnShape(curve, t_s);
21
+ posSource = createPos(posSource.curve.prev, t_s, true);
31
22
  }
23
+ const orderSource = calcPosOrder(circle, posSource);
24
+ const orderAntipodes = posAntipodes.map(posAntipode => calcPosOrder(circle, posAntipode));
32
25
  // Make sure there isn't already a ContactPoint close by - it can cause
33
26
  // floating point stability issues.
34
- // TODO - possibly combine n-prongs in this case
35
27
  let isCloseByAntipodes = false;
36
28
  for (let i = 0; i < posAntipodes.length; i++) {
37
29
  const posAntipode = posAntipodes[i];
38
30
  const orderAntipode = orderAntipodes[i];
39
- if (isAnotherCpCloseby(cpGraphs, posAntipode.pos, circle, orderAntipode, 0, extreme, 'red')) {
31
+ if (!!isAnotherCpCloseby(cpGraphs, posAntipode, circle, orderAntipode, 0, extreme)) {
40
32
  isCloseByAntipodes = true;
41
33
  break;
42
34
  }
43
35
  }
44
- if (isAnotherCpCloseby(cpGraphs, posSource, circle, orderSource, 0, extreme, 'red') ||
36
+ if (!!isAnotherCpCloseby(cpGraphs, posSource, circle, orderSource, 0, extreme) ||
45
37
  isCloseByAntipodes) {
46
38
  if (typeof _debug_ !== 'undefined') {
47
39
  if (holeClosing) {
@@ -62,22 +54,24 @@ function add2Prong(cpGraphs, circle, posSource, posAntipodes, holeClosing, extre
62
54
  for (let i = 0; i < posAntipodes.length; i++) {
63
55
  const posAntipode = posAntipodes[i];
64
56
  const orderAntipode = orderAntipodes[i];
65
- const cpAntipode = { pointOnShape: posAntipode.pos, circle, order: orderAntipode, order2: 0 };
57
+ const cpAntipode = {
58
+ pointOnShape: posAntipode, circle, order: orderAntipode, order2: 0
59
+ };
66
60
  cpAntipodes.push(cpAntipode);
67
- const loopAntipode = posAntipode.pos.curve.loop;
61
+ const loopAntipode = posAntipode.curve.loop;
68
62
  loopAntipodes.push(loopAntipode);
69
63
  const cpTreeAntipode = cpGraphs.get(loopAntipode);
70
64
  cpTreeAntipodes.push(cpTreeAntipode);
71
- const deltaAntipode = getNeighbouringPoints(cpTreeAntipode, posAntipode.pos, orderAntipode, 0);
65
+ const deltaAntipode = getNeighbouringPoints(cpTreeAntipode, posAntipode, orderAntipode, 0);
72
66
  deltaAntipodes.push(deltaAntipode);
73
- newCpAntipodes.push(CpNode.insert(holeClosing, false, cpTreeAntipode, cpAntipode, deltaAntipode[0]));
67
+ newCpAntipodes.push(insertCpNode(holeClosing, false, cpTreeAntipode, cpAntipode, deltaAntipode[0]));
74
68
  }
75
69
  // Source
76
70
  const cpSource = { pointOnShape: posSource, circle, order: orderSource, order2: 0 };
77
71
  const loopSource = posSource.curve.loop;
78
72
  const cpTreeSource = cpGraphs.get(loopSource);
79
73
  const deltaSource = getNeighbouringPoints(cpTreeSource, posSource, orderSource, 0);
80
- const newCpSource = CpNode.insert(holeClosing, false, cpTreeSource, cpSource, deltaSource[0]);
74
+ const newCpSource = insertCpNode(holeClosing, false, cpTreeSource, cpSource, deltaSource[0]);
81
75
  // Connect graph
82
76
  if (newCpAntipodes.length === 1) {
83
77
  newCpSource.prevOnCircle = newCpAntipodes[0];
@@ -101,12 +95,12 @@ function add2Prong(cpGraphs, circle, posSource, posAntipodes, holeClosing, extre
101
95
  }
102
96
  }
103
97
  if (holeClosing) {
104
- // TODO - important - take care of case where there are more than 1 antipode
98
+ // TODO - take care of case where there are more than 1 antipode
105
99
  // Duplicate ContactPoints
106
- const cpB2 = { pointOnShape: posAntipodes[0].pos, circle, order: cpAntipodes[0].order, order2: +1 };
107
- const newCpB2Node = CpNode.insert(true, false, cpTreeAntipodes[0], cpB2, newCpAntipodes[0]);
100
+ const cpB2 = { pointOnShape: posAntipodes[0], circle, order: cpAntipodes[0].order, order2: +1 };
101
+ const newCpB2Node = insertCpNode(true, false, cpTreeAntipodes[0], cpB2, newCpAntipodes[0]);
108
102
  const cpB1 = { pointOnShape: posSource, circle, order: cpSource.order, order2: -1 };
109
- const newCpB1Node = CpNode.insert(true, false, cpTreeSource, cpB1, newCpSource.prev);
103
+ const newCpB1Node = insertCpNode(true, false, cpTreeSource, cpB1, newCpSource.prev);
110
104
  // Connect graph
111
105
  newCpB1Node.prevOnCircle = newCpB2Node;
112
106
  newCpB1Node.nextOnCircle = newCpB2Node;
@@ -133,60 +127,18 @@ function add2Prong(cpGraphs, circle, posSource, posAntipodes, holeClosing, extre
133
127
  }
134
128
  return newCpSource;
135
129
  }
136
- /** @hidden */
137
- function scale(n, exp) {
138
- return n * (2 ** -(exp + 1));
139
- }
140
- /** @hidden */
141
- function getSize(x, y) {
142
- // Get size of a
143
- if (x > 0) {
144
- if (x > 0.5) {
145
- return y; // ~ -0.7 -> 0.7, i.e. -(sqrt(2)/2) -> +(sqrt(2)/2)
146
- }
147
- else {
148
- if (y < 0) {
149
- return x - 2; // ~ -2.0 -> -1.3
150
- }
151
- else {
152
- return -x + 2; // ~ 1.3 -> 2.0
153
- }
154
- }
155
- }
156
- else {
157
- if (x < -0.5) {
158
- return -y + 4; // ~ 3.3 -> 4.7
159
- }
160
- else {
161
- if (y < 0) {
162
- return x + 6; // ~ 5.3 -> 6.0
163
- }
164
- else {
165
- return -x + 2; // ~ 2 -> 2.7
166
- }
167
- }
168
- }
169
- }
170
- /** @hidden */
130
+ /** @internal */
171
131
  function byAngle(circle) {
172
132
  const c = circle.center;
173
- const r = circle.radius;
174
- const exp = exponent(r);
175
133
  return function (_a, _b) {
176
134
  let a = _a.cp.pointOnShape.p;
177
135
  let b = _b.cp.pointOnShape.p;
178
136
  // Move onto origin
179
137
  a = [a[0] - c[0], a[1] - c[1]];
180
138
  b = [b[0] - c[0], b[1] - c[1]];
181
- // Scale
182
- const ax = scale(a[0], exp);
183
- const ay = scale(a[1], exp);
184
- const bx = scale(b[0], exp);
185
- const by = scale(b[1], exp);
186
- // Get 'size'
187
- const sa = getSize(ax, ay);
188
- const sb = getSize(bx, by);
189
- return sb - sa;
139
+ const a_ = Math.atan2(a[1], a[0]);
140
+ const b_ = Math.atan2(b[1], b[0]);
141
+ return b_ - a_;
190
142
  };
191
143
  }
192
144
  export { add2Prong };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-2-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/add-2-prong.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAKtE;;;;;;;;;;GAUG;AACH,SAAS,SAAS,CAChB,QAA0C,EACpC,MAAsB,EACtB,SAA4B,EAClC,YAA8B,EAC9B,WAAuB,EACvB,OAAsB;IAEvB,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC;IACtB,IAAI,GAAG,KAAK,CAAC,EAAE;QACd,GAAG,GAAG,CAAC,CAAC;QACR,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;KACvD;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CACtC,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,WA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AAI,CAAC,WAAW,EAAE;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;SAAC;QACxC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC1B;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAGD,gBAAgB;AAChB,SAAS,OAAO,CAAC,MAAc;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IAExB,OAAO,UAAS,EAAU,EAAE,EAAU;QACrC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAE7B,mBAAmB;QACnB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/B,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAElC,OAAO,EAAE,GAAG,EAAE,CAAC;IAChB,CAAC,CAAA;AACF,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { PointOnShape } from '../point-on-shape/point-on-shape.js';
2
+ import { Circle } from '../geometry/circle.js';
3
+ import { CpNode } from '../cp-node/cp-node.js';
4
+ import { BezierPiece } from '../mat/bezier-piece.js';
5
+ import { TXForDebugging } from './x-for-debugging.js';
6
+ /** @internal */
7
+ declare function addDebugInfo(bezierPieces: BezierPiece[], failed: boolean, x: number[], y: PointOnShape, z: PointOnShape, circle: Circle, δ: CpNode[], xs: TXForDebugging[], holeClosing: boolean): void;
8
+ export { addDebugInfo };
@@ -1,10 +1,11 @@
1
- import { getTwoProngType } from '../../get-two-prong-type.js';
2
- /** @hidden */
3
- function addDebugInfo(bezierPieces, failed, pos, circle, z, δ, xs, holeClosing) {
1
+ import { getTwoProngType } from '../mat/get-two-prong-type.js';
2
+ /** @internal */
3
+ function addDebugInfo(bezierPieces, failed, x, y, z, circle, δ, xs, holeClosing) {
4
+ xs.push({ x, y, z, t: y.t });
4
5
  const twoProng = {
5
6
  generated: _debug_.generated,
6
7
  bezierPieces,
7
- pos,
8
+ pos: y,
8
9
  δ,
9
10
  z: z ? z.p : undefined,
10
11
  circle,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-debug-info.js","sourceRoot":"","sources":["../../src/find-2-prong/add-debug-info.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D,gBAAgB;AAChB,SAAS,YAAY,CACb,YAA2B,EAC3B,MAAe,EACf,CAAW,EACX,CAAe,EACf,CAAe,EACf,MAAc,EACd,CAAW,EACX,EAAoB,EACpB,WAAoB;IAExB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE7B,MAAM,QAAQ,GAAyB;QAC/B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY;QACZ,GAAG,EAAE,CAAC;QACN,CAAC;QACD,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAU;QACvB,MAAM;QACN,EAAE;QACF,MAAM;QACN,WAAW;QACX,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,SAAU;KACzB,CAAC;IAEF,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAsB,CAAC;IACpE,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { BezierPiece } from '../mat/bezier-piece.js';
2
+ /**
3
+ * @internal
4
+ * Cull all bezierPieces not within given radius of a given point.
5
+ * @param extreme
6
+ * @param bezierPieces
7
+ * @param p
8
+ * @param rSquared
9
+ */
10
+ declare function cullBezierPieces2(bezierPieces: BezierPiece[], p: number[], rSquared: number): BezierPiece[];
11
+ export { cullBezierPieces2 };
@@ -0,0 +1,28 @@
1
+ import { getClosestSquareDistanceToRect } from '../geometry/get-closest-square-distance-to-rect.js';
2
+ import { getBoundingBox_ } from '../geometry/get-bounding-box-.js';
3
+ /**
4
+ * @internal
5
+ * Cull all bezierPieces not within given radius of a given point.
6
+ * @param extreme
7
+ * @param bezierPieces
8
+ * @param p
9
+ * @param rSquared
10
+ */
11
+ function cullBezierPieces2(bezierPieces, p, rSquared) {
12
+ const TOLERANCE = 1 + 2 ** -10;
13
+ if (bezierPieces.length <= 1) {
14
+ return bezierPieces;
15
+ }
16
+ const newPieces = [];
17
+ for (const bezierPiece of bezierPieces) {
18
+ const ps = bezierPiece.curve.ps;
19
+ const rect = getBoundingBox_(ps);
20
+ const bd = getClosestSquareDistanceToRect(rect, p);
21
+ if (bd <= TOLERANCE * rSquared) {
22
+ newPieces.push(bezierPiece);
23
+ }
24
+ }
25
+ return newPieces;
26
+ }
27
+ export { cullBezierPieces2 };
28
+ //# sourceMappingURL=cull-bezier-pieces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cull-bezier-pieces.js","sourceRoot":"","sources":["../../src/find-2-prong/cull-bezier-pieces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AAEpG,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAClB,YAA2B,EAC3B,CAAW,EACX,QAAgB;IAEpB,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,IAAE,CAAC,EAAE,CAAC;IAE7B,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC1B,OAAO,YAAY,CAAC;KACvB;IAGD,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;QACpC,MAAM,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QAEhC,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;QACjC,MAAM,EAAE,GAAG,8BAA8B,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,EAAE,IAAI,SAAS,GAAC,QAAQ,EAAE;YAC1B,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC/B;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1,18 +1,17 @@
1
1
  import { LlRbTree } from 'flo-ll-rb-tree';
2
- import { CpNode } from '../../../cp-node.js';
3
- import { Loop } from '../../../loop.js';
4
- import { Circle } from '../../../circle.js';
5
- import { IPointOnShape } from '../../../point-on-shape.js';
2
+ import { CpNode } from '../cp-node/cp-node.js';
3
+ import { Loop } from 'flo-boolean';
4
+ import { Circle } from '../geometry/circle.js';
5
+ import { PointOnShape } from '../point-on-shape/point-on-shape.js';
6
6
  /**
7
- * @hidden
7
+ * @internal
8
8
  * Adds a 2-prong to the MAT. The first point on the shape boundary is given and
9
9
  * the second one is found by the algorithm.
10
10
  *
11
11
  * A 2-prong is defined as a MAT circle that touches the shape at exactly 2
12
12
  * points.
13
13
  *
14
- * Before any 2-prongs are added the entire shape is our δΩ (1-prongs do not
15
- * reduce the boundary).
14
+ * Before any 2-prongs are added the entire shape is our δΩ.
16
15
  *
17
16
  * As per the paper by Choi, Choi, Moon and Wee:
18
17
  * "The starting point of this algorithm is a choice of a circle Br(x)
@@ -27,11 +26,8 @@ import { IPointOnShape } from '../../../point-on-shape.js';
27
26
  * @param isHoleClosing True if this is a hole-closing two-prong, false otherwise
28
27
  * @param k The loop array index
29
28
  */
30
- declare function find2Prong(loops: Loop[], extreme: number, squaredDiagonalLength: number, cpTrees: Map<Loop, LlRbTree<CpNode>>, y: IPointOnShape, isHoleClosing: boolean, k: number): {
29
+ declare function find2Prong(angle: number, loops: Loop[], extreme: number, squaredDiagonalLength: number, cpTrees: Map<Loop, LlRbTree<CpNode>>, y: PointOnShape, isHoleClosing: boolean, k: number, for1Prong: boolean): {
31
30
  circle: Circle;
32
- zs: {
33
- pos: IPointOnShape;
34
- d: number;
35
- }[];
36
- };
31
+ zs: PointOnShape[];
32
+ } | undefined;
37
33
  export { find2Prong };
@@ -0,0 +1,144 @@
1
+ import { distanceBetween, fromTo, interpolate, rotate, translate } from 'flo-vector2d';
2
+ import { getOsculatingCircle } from '../point-on-shape/get-osculating-circle.js';
3
+ import { addDebugInfo } from './add-debug-info.js';
4
+ import { findEquidistantPointOnLineDd } from './find-equidistant-point-on-line-dd.js';
5
+ import { getInitialBezierPieces } from './get-initial-bezier-pieces.js';
6
+ import { getCloseBoundaryPointsCertified } from '../closest-boundary-point/get-close-boundary-points-certified.js';
7
+ import { reduceRadius } from './reduce-radius.js';
8
+ import { squaredDistanceBetweenDd } from './squared-distance-between-dd.js';
9
+ import { cullBezierPieces2 } from './cull-bezier-pieces.js';
10
+ import { add1Prong } from './add-1-prong.js';
11
+ import { createPos } from '../point-on-shape/create-pos.js';
12
+ const { sqrt, abs, sin, cos } = Math;
13
+ /**
14
+ * @internal
15
+ * Adds a 2-prong to the MAT. The first point on the shape boundary is given and
16
+ * the second one is found by the algorithm.
17
+ *
18
+ * A 2-prong is defined as a MAT circle that touches the shape at exactly 2
19
+ * points.
20
+ *
21
+ * Before any 2-prongs are added the entire shape is our δΩ.
22
+ *
23
+ * As per the paper by Choi, Choi, Moon and Wee:
24
+ * "The starting point of this algorithm is a choice of a circle Br(x)
25
+ * centered at an interior point x which contains two boundary portions c and
26
+ * d of dΩ as in Fig. 19."
27
+ * In fact, we (and they) start by fixing one point on the boundary beforehand.
28
+ * @param loops A shape represented by path loops
29
+ * @param extreme The extreme coordinate value of the shape
30
+ * @param squaredDiagonalLength The squared diagonal length of the shape
31
+ * bounding box.
32
+ * @param y The source point of the 2-prong to be found
33
+ * @param isHoleClosing True if this is a hole-closing two-prong, false otherwise
34
+ * @param k The loop array index
35
+ */
36
+ function find2Prong(angle, loops, extreme, squaredDiagonalLength, cpTrees, y, isHoleClosing, k, for1Prong) {
37
+ const MAX_ITERATIONS = 25;
38
+ const squaredSeperationTolerance = ((2 ** -21) * extreme) ** 2;
39
+ const errorTolerance = (2 ** -46) * extreme;
40
+ const maxOsculatingCircleRadius = sqrt(squaredDiagonalLength);
41
+ const minCurvature = 1 / maxOsculatingCircleRadius;
42
+ let xO; // the original x to mitigate drift
43
+ const p = y.p;
44
+ let rO;
45
+ if (isHoleClosing) {
46
+ xO = [p[0], p[1] - maxOsculatingCircleRadius];
47
+ rO = maxOsculatingCircleRadius;
48
+ }
49
+ else {
50
+ if (angle === 0) {
51
+ ({ center: xO, radius: rO } = getOsculatingCircle(minCurvature, y));
52
+ }
53
+ else {
54
+ ({ center: xO, radius: rO } = getOsculatingCircle(minCurvature, y, true));
55
+ const v = fromTo(y.p, xO);
56
+ const v_ = rotate(sin(angle), cos(angle))(v);
57
+ xO = translate(y.p)(v_);
58
+ }
59
+ }
60
+ // The boundary piece that should contain the other point of
61
+ // the 2-prong circle. (Defined by start and end points).
62
+ const { bezierPieces, δ } = getInitialBezierPieces(angle, isHoleClosing, k, loops, cpTrees, y, { center: xO, radius: rO });
63
+ /** The center of the two-prong (successively refined) */
64
+ let x = xO;
65
+ // The lines below is an optimization.
66
+ const r_ = sqrt(reduceRadius(extreme, bezierPieces, p, xO));
67
+ if (rO > r_) {
68
+ x = interpolate(p, xO, r_ / rO);
69
+ }
70
+ /** Trace the convergence (for debugging). */
71
+ const xs = [];
72
+ /** The antipode of the two-prong (successively refined) */
73
+ let zs = undefined;
74
+ let z = undefined;
75
+ let bezierPieces_ = bezierPieces;
76
+ let i = 0;
77
+ while (i < MAX_ITERATIONS) {
78
+ const xy = squaredDistanceBetweenDd(x, y.p);
79
+ if (i < 5) {
80
+ bezierPieces_ = cullBezierPieces2(bezierPieces_, x, xy);
81
+ }
82
+ zs = getCloseBoundaryPointsCertified(bezierPieces_, x, y.curve, y.t, for1Prong && i == 0 && rO !== 1 / minCurvature, angle).map(info => createPos(info.curve, info.t, false));
83
+ z = zs[0];
84
+ if (z === undefined) {
85
+ addDebugInfo2(isHoleClosing);
86
+ return undefined;
87
+ }
88
+ const xz = squaredDistanceBetweenDd(x, z.p);
89
+ const yz = squaredDistanceBetweenDd(y.p, z.p);
90
+ // if on first try
91
+ if (i === 0) {
92
+ if (rO < (1 - 2 ** -6) * sqrt(xz)) {
93
+ add1Prong(rO, xO, cpTrees, y);
94
+ return undefined;
95
+ }
96
+ // return undefined;
97
+ }
98
+ if (typeof _debug_ !== 'undefined') {
99
+ xs.push({ x, y, z: createPos(z.curve, z.t, false), t: y.t });
100
+ }
101
+ if (!isHoleClosing) {
102
+ if (yz <= squaredSeperationTolerance) {
103
+ // if (typeof _debug_ !== 'undefined') { console.log(`failed: seperation too small - ${sqrt(yz)}`); }
104
+ return undefined;
105
+ }
106
+ }
107
+ // Find the point on the line connecting y with x that is
108
+ // equidistant from y and z. This will be our next x.
109
+ const nextX = findEquidistantPointOnLineDd(x, y.p, z.p);
110
+ const error = abs(sqrt(xy) - sqrt(xz));
111
+ // if (xy < xz) { return undefined; }
112
+ x = nextX;
113
+ if (error < errorTolerance) {
114
+ break;
115
+ }
116
+ i++;
117
+ if (i === MAX_ITERATIONS) {
118
+ // Convergence was too slow.
119
+ if (typeof _debug_ !== 'undefined') {
120
+ console.log('failed (slow): max iterations reached');
121
+ }
122
+ return undefined;
123
+ }
124
+ }
125
+ // const zs_ = zs;
126
+ // console.log(zs.length)
127
+ // const zPos = createPos(z.curve, z.t, false);
128
+ const circle = { center: x, radius: distanceBetween(x, z.p) };
129
+ if (typeof _debug_ !== 'undefined') {
130
+ addDebugInfo(bezierPieces, false, x, y, z, circle, δ, xs, isHoleClosing);
131
+ }
132
+ // return { circle, zs: zs_ };
133
+ return { circle, zs: zs };
134
+ }
135
+ function addDebugInfo2(isHoleClosing) {
136
+ if (typeof _debug_ !== 'undefined') {
137
+ const elems = _debug_.generated.elems;
138
+ const elem = isHoleClosing ? elems.twoProng_holeClosing : elems.twoProng_regular;
139
+ const elemStr = isHoleClosing ? 'hole-closing: ' + elem.length : 'regular: ' + elem.length;
140
+ console.log('failed: no closest point - ' + elemStr);
141
+ }
142
+ }
143
+ export { find2Prong };
144
+ //# sourceMappingURL=find-2-prong.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-2-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/find-2-prong.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAKvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,wBAA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