flo-mat 4.0.2 → 4.1.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 (294) hide show
  1. package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +106 -0
  2. package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +73 -0
  3. package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +5 -2
  4. package/__tests__/helpers/close-to.ts +5 -5
  5. package/__tests__/specific-cases/load-svg/load-svg.ts +30 -0
  6. package/__tests__/specific-cases/specific-cases.spec.ts +170 -0
  7. package/__tests__/specific-cases/test-svgs/achispado.svg +5052 -0
  8. package/browser/index.js +5129 -8785
  9. package/browser/index.min.js +1 -1
  10. package/{jest.config.cjs → jest.config.ts} +8 -3
  11. package/node/closest-boundary-point/get-close-boundary-points-certified.js +3 -2
  12. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  13. package/node/corner/get-corner.js +1 -1
  14. package/node/corner/get-corner.js.map +1 -1
  15. package/node/cp-node/fs/get-all-on-loop-by-loop.d.ts +11 -0
  16. package/node/cp-node/fs/get-all-on-loop-by-loop.js +42 -0
  17. package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -0
  18. package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +1 -0
  19. package/node/cp-node/fs/get-boundary-beziers-to-next.js +1 -59
  20. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  21. package/node/cp-node/fs/get-edge-direction.d.ts +3 -1
  22. package/node/cp-node/fs/get-edge-direction.js +5 -3
  23. package/node/cp-node/fs/get-edge-direction.js.map +1 -1
  24. package/node/cp-node/fs/get-mat-curve-between.js +6 -6
  25. package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
  26. package/node/cp-node/fs/is-fully-terminating.js +12 -0
  27. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  28. package/node/cp-node/fs/is-on-same-loop.d.ts +3 -0
  29. package/node/cp-node/fs/is-on-same-loop.js +6 -0
  30. package/node/cp-node/fs/is-on-same-loop.js.map +1 -0
  31. package/node/debug/debug.d.ts +8 -22
  32. package/node/debug/debug.js +12 -50
  33. package/node/debug/debug.js.map +1 -1
  34. package/node/find-2-prong/add-1-prong.js +1 -4
  35. package/node/find-2-prong/add-1-prong.js.map +1 -1
  36. package/node/find-2-prong/find-2-prong.js +24 -10
  37. package/node/find-2-prong/find-2-prong.js.map +1 -1
  38. package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -1
  39. package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -2
  40. package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
  41. package/node/find-2-prong/get-medial/get-closest-points.d.ts +7 -1
  42. package/node/find-2-prong/get-medial/get-closest-points.js +60 -14
  43. package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
  44. package/node/find-2-prong/reduce-radius.d.ts +3 -1
  45. package/node/find-2-prong/reduce-radius.js +8 -6
  46. package/node/find-2-prong/reduce-radius.js.map +1 -1
  47. package/node/find-3-prong/calc-better-x.js +1 -3
  48. package/node/find-3-prong/calc-better-x.js.map +1 -1
  49. package/node/find-3-prong/calc-initial-3-prong-center.js +1 -2
  50. package/node/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
  51. package/node/find-3-prong/find-3-prong-for-delta3s.js +1 -4
  52. package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
  53. package/node/find-3-prong/find-3-prong.js.map +1 -1
  54. package/node/find-3-prong/find-and-add-3-prong.js +0 -14
  55. package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
  56. package/node/find-mat/find-mat.js +2 -2
  57. package/node/find-mat/find-mat.js.map +1 -1
  58. package/node/find-mat/find-mats.js.map +1 -1
  59. package/node/find-mat/get-dull-corners-on-loop.js +3 -2
  60. package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
  61. package/node/find-mat/get-for-1-prongs-on-loop.js +6 -3
  62. package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
  63. package/node/find-mat/get-for-2-prongs-on-loop.js +5 -1
  64. package/node/find-mat/get-for-2-prongs-on-loop.js.map +1 -1
  65. package/node/find-mat/get-meta.d.ts +4 -6
  66. package/node/find-mat/get-meta.js +12 -26
  67. package/node/find-mat/get-meta.js.map +1 -1
  68. package/node/find-mat/get-sharp-corners.js +4 -2
  69. package/node/find-mat/get-sharp-corners.js.map +1 -1
  70. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.d.ts +21 -0
  71. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js +46 -0
  72. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js.map +1 -0
  73. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.d.ts +28 -0
  74. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js +97 -0
  75. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js.map +1 -0
  76. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.d.ts +28 -0
  77. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js +109 -0
  78. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js.map +1 -0
  79. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.d.ts +29 -0
  80. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js +123 -0
  81. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js.map +1 -0
  82. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.d.ts +30 -0
  83. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js +177 -0
  84. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js.map +1 -0
  85. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.d.ts +29 -0
  86. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +156 -0
  87. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -0
  88. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.d.ts +28 -0
  89. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js +40 -0
  90. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js.map +1 -0
  91. package/node/index.d.ts +6 -10
  92. package/node/index.js +5 -6
  93. package/node/index.js.map +1 -1
  94. package/node/point-on-shape/point-on-shape.d.ts +2 -0
  95. package/node/point-on-shape/to-p.d.ts +1 -1
  96. package/node/point-on-shape/to-p.js +1 -1
  97. package/node/point-on-shape/to-p.js.map +1 -1
  98. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.d.ts +4 -0
  99. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +15 -0
  100. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -0
  101. package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +10 -0
  102. package/node/reconstruct-from-mat/reconstruct-from-mat.js +160 -0
  103. package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -0
  104. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +12 -0
  105. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +46 -0
  106. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -0
  107. package/node/sat/add-debug-info.js +1 -2
  108. package/node/sat/add-debug-info.js.map +1 -1
  109. package/node/svg/get-loop-bounds.js +6 -2
  110. package/node/svg/get-loop-bounds.js.map +1 -1
  111. package/node/utils/map-deep.d.ts +15 -0
  112. package/node/utils/map-deep.js +34 -0
  113. package/node/utils/map-deep.js.map +1 -0
  114. package/package.json +14 -8
  115. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +3 -2
  116. package/src/corner/get-corner.ts +1 -1
  117. package/src/cp-node/fs/get-all-on-loop-by-loop.ts +56 -0
  118. package/src/cp-node/fs/get-all-on-loop.ts +1 -1
  119. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +1 -72
  120. package/src/cp-node/fs/get-edge-direction.ts +8 -4
  121. package/src/cp-node/fs/get-mat-curve-between.ts +6 -6
  122. package/src/cp-node/fs/is-fully-terminating.ts +16 -0
  123. package/src/cp-node/fs/is-on-same-loop.ts +15 -0
  124. package/src/debug/debug.ts +27 -87
  125. package/src/find-2-prong/add-1-prong.ts +1 -5
  126. package/src/find-2-prong/find-2-prong.ts +37 -14
  127. package/src/find-2-prong/get-medial/get-antipodal-points.ts +3 -2
  128. package/src/find-2-prong/get-medial/get-closest-points-d.ts +213 -0
  129. package/src/find-2-prong/get-medial/get-closest-points.ts +74 -13
  130. package/src/find-2-prong/reduce-radius.ts +8 -5
  131. package/src/find-3-prong/calc-better-x.ts +1 -3
  132. package/src/find-3-prong/calc-initial-3-prong-center.ts +1 -2
  133. package/src/find-3-prong/find-3-prong-for-delta3s.ts +1 -4
  134. package/src/find-3-prong/find-3-prong.ts +0 -1
  135. package/src/find-3-prong/find-and-add-3-prong.ts +1 -15
  136. package/src/find-mat/find-mat.ts +3 -2
  137. package/src/find-mat/find-mats.ts +0 -1
  138. package/src/find-mat/get-dull-corners-on-loop.ts +4 -3
  139. package/src/find-mat/get-for-1-prongs-on-loop.ts +8 -3
  140. package/src/find-mat/get-for-2-prongs-on-loop.ts +6 -1
  141. package/src/find-mat/get-meta.ts +14 -38
  142. package/src/find-mat/get-sharp-corners.ts +5 -1
  143. package/src/get-medial-curve/__pycache__/get-cubic-self-medial-curve.cpython-313.pyc +0 -0
  144. package/src/get-medial-curve/get-cubic-self-medial-curve.py +419 -0
  145. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0-with-running-err.ts +76 -0
  146. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.ts +61 -0
  147. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.ts +116 -0
  148. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.ts +129 -0
  149. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.ts +142 -0
  150. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.ts +199 -0
  151. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +177 -0
  152. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs.ts +48 -0
  153. package/src/get-medial-points/double-double/error-bound-calc.txt +72 -0
  154. package/src/index.ts +7 -11
  155. package/src/point-on-shape/point-on-shape.ts +3 -0
  156. package/src/point-on-shape/to-p.ts +2 -2
  157. package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +24 -0
  158. package/src/reconstruct-from-mat/reconstruct-from-mat.ts +226 -0
  159. package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +62 -0
  160. package/src/sat/add-debug-info.ts +1 -2
  161. package/src/svg/get-loop-bounds.ts +11 -3
  162. package/src/utils/clip.ts +13 -0
  163. package/src/utils/map-deep.ts +75 -0
  164. package/src/utils/map-map.ts +33 -0
  165. package/wallaby.mjs +4 -4
  166. package/node/debug/debug-elem-types.d.ts +0 -26
  167. package/node/debug/debug-elem-types.js +0 -22
  168. package/node/debug/debug-elem-types.js.map +0 -1
  169. package/node/debug/functions/draw/draw-beziers-as-single-path.d.ts +0 -2
  170. package/node/debug/functions/draw/draw-beziers-as-single-path.js +0 -30
  171. package/node/debug/functions/draw/draw-beziers-as-single-path.js.map +0 -1
  172. package/node/debug/functions/draw/xmlns.d.ts +0 -2
  173. package/node/debug/functions/draw/xmlns.js +0 -3
  174. package/node/debug/functions/draw/xmlns.js.map +0 -1
  175. package/node/debug/functions/draw-elem/bounding-hull.d.ts +0 -3
  176. package/node/debug/functions/draw-elem/bounding-hull.js +0 -8
  177. package/node/debug/functions/draw-elem/bounding-hull.js.map +0 -1
  178. package/node/debug/functions/draw-elem/draw-branch.d.ts +0 -4
  179. package/node/debug/functions/draw-elem/draw-branch.js +0 -26
  180. package/node/debug/functions/draw-elem/draw-branch.js.map +0 -1
  181. package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +0 -3
  182. package/node/debug/functions/draw-elem/draw-circle-percent.js +0 -13
  183. package/node/debug/functions/draw-elem/draw-circle-percent.js.map +0 -1
  184. package/node/debug/functions/draw-elem/draw-cp-node.d.ts +0 -4
  185. package/node/debug/functions/draw-elem/draw-cp-node.js +0 -26
  186. package/node/debug/functions/draw-elem/draw-cp-node.js.map +0 -1
  187. package/node/debug/functions/draw-elem/draw-cull.d.ts +0 -3
  188. package/node/debug/functions/draw-elem/draw-cull.js +0 -9
  189. package/node/debug/functions/draw-elem/draw-cull.js.map +0 -1
  190. package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +0 -4
  191. package/node/debug/functions/draw-elem/draw-dull-corner.js +0 -10
  192. package/node/debug/functions/draw-elem/draw-dull-corner.js.map +0 -1
  193. package/node/debug/functions/draw-elem/draw-elem.d.ts +0 -10
  194. package/node/debug/functions/draw-elem/draw-elem.js +0 -39
  195. package/node/debug/functions/draw-elem/draw-elem.js.map +0 -1
  196. package/node/debug/functions/draw-elem/draw-leaves.d.ts +0 -4
  197. package/node/debug/functions/draw-elem/draw-leaves.js +0 -34
  198. package/node/debug/functions/draw-elem/draw-leaves.js.map +0 -1
  199. package/node/debug/functions/draw-elem/draw-loop.d.ts +0 -4
  200. package/node/debug/functions/draw-elem/draw-loop.js +0 -11
  201. package/node/debug/functions/draw-elem/draw-loop.js.map +0 -1
  202. package/node/debug/functions/draw-elem/draw-loops.d.ts +0 -4
  203. package/node/debug/functions/draw-elem/draw-loops.js +0 -6
  204. package/node/debug/functions/draw-elem/draw-loops.js.map +0 -1
  205. package/node/debug/functions/draw-elem/draw-loose-bounding-box.d.ts +0 -3
  206. package/node/debug/functions/draw-elem/draw-loose-bounding-box.js +0 -10
  207. package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +0 -1
  208. package/node/debug/functions/draw-elem/draw-mat.d.ts +0 -4
  209. package/node/debug/functions/draw-elem/draw-mat.js +0 -34
  210. package/node/debug/functions/draw-elem/draw-mat.js.map +0 -1
  211. package/node/debug/functions/draw-elem/draw-max-vertex.d.ts +0 -4
  212. package/node/debug/functions/draw-elem/draw-max-vertex.js +0 -9
  213. package/node/debug/functions/draw-elem/draw-max-vertex.js.map +0 -1
  214. package/node/debug/functions/draw-elem/draw-min-y.d.ts +0 -4
  215. package/node/debug/functions/draw-elem/draw-min-y.js +0 -10
  216. package/node/debug/functions/draw-elem/draw-min-y.js.map +0 -1
  217. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.d.ts +0 -4
  218. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js +0 -22
  219. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +0 -1
  220. package/node/debug/functions/draw-elem/draw-one-prong.d.ts +0 -4
  221. package/node/debug/functions/draw-elem/draw-one-prong.js +0 -13
  222. package/node/debug/functions/draw-elem/draw-one-prong.js.map +0 -1
  223. package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +0 -4
  224. package/node/debug/functions/draw-elem/draw-sharp-corner.js +0 -10
  225. package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +0 -1
  226. package/node/debug/functions/draw-elem/draw-three-prong.d.ts +0 -4
  227. package/node/debug/functions/draw-elem/draw-three-prong.js +0 -26
  228. package/node/debug/functions/draw-elem/draw-three-prong.js.map +0 -1
  229. package/node/debug/functions/draw-elem/draw-tight-bounding-box.d.ts +0 -3
  230. package/node/debug/functions/draw-elem/draw-tight-bounding-box.js +0 -8
  231. package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +0 -1
  232. package/node/debug/functions/draw-elem/draw-two-prong.d.ts +0 -4
  233. package/node/debug/functions/draw-elem/draw-two-prong.js +0 -49
  234. package/node/debug/functions/draw-elem/draw-two-prong.js.map +0 -1
  235. package/node/debug/functions/draw-elem/draw-vertex.d.ts +0 -4
  236. package/node/debug/functions/draw-elem/draw-vertex.js +0 -13
  237. package/node/debug/functions/draw-elem/draw-vertex.js.map +0 -1
  238. package/node/debug/functions/general.d.ts +0 -48
  239. package/node/debug/functions/general.js +0 -53
  240. package/node/debug/functions/general.js.map +0 -1
  241. package/node/find-3-prong/timed-cc.d.ts +0 -3
  242. package/node/find-3-prong/timed-cc.js +0 -5
  243. package/node/find-3-prong/timed-cc.js.map +0 -1
  244. package/node/point-on-shape/pos-to-human-string.d.ts +0 -8
  245. package/node/point-on-shape/pos-to-human-string.js +0 -12
  246. package/node/point-on-shape/pos-to-human-string.js.map +0 -1
  247. package/node/utils/time-function-call.d.ts +0 -14
  248. package/node/utils/time-function-call.js +0 -32
  249. package/node/utils/time-function-call.js.map +0 -1
  250. package/src/debug/debug-elem-types.ts +0 -43
  251. package/src/debug/elem-type-two-prong.ts +0 -8
  252. package/src/debug/functions/cmp-cp-on-delta.ts +0 -54
  253. package/src/debug/functions/draw-elem/bounding-hull.ts +0 -18
  254. package/src/debug/functions/draw-elem/culls.ts +0 -39
  255. package/src/debug/functions/draw-elem/draw-branch.ts +0 -37
  256. package/src/debug/functions/draw-elem/draw-circle-percent.ts +0 -23
  257. package/src/debug/functions/draw-elem/draw-cp-node.ts +0 -46
  258. package/src/debug/functions/draw-elem/draw-cull.ts +0 -21
  259. package/src/debug/functions/draw-elem/draw-dull-corner.ts +0 -21
  260. package/src/debug/functions/draw-elem/draw-elem.ts +0 -64
  261. package/src/debug/functions/draw-elem/draw-leaves.ts +0 -51
  262. package/src/debug/functions/draw-elem/draw-loop.ts +0 -16
  263. package/src/debug/functions/draw-elem/draw-loops.ts +0 -10
  264. package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +0 -21
  265. package/src/debug/functions/draw-elem/draw-mat.ts +0 -43
  266. package/src/debug/functions/draw-elem/draw-max-vertex.ts +0 -15
  267. package/src/debug/functions/draw-elem/draw-min-y.ts +0 -18
  268. package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +0 -40
  269. package/src/debug/functions/draw-elem/draw-one-prong.ts +0 -25
  270. package/src/debug/functions/draw-elem/draw-sharp-corner.ts +0 -21
  271. package/src/debug/functions/draw-elem/draw-three-prong.ts +0 -44
  272. package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +0 -18
  273. package/src/debug/functions/draw-elem/draw-two-prong.ts +0 -68
  274. package/src/debug/functions/draw-elem/draw-vertex.ts +0 -27
  275. package/src/debug/functions/draw-elem/dull-corner.ts +0 -21
  276. package/src/debug/functions/draw-elem/leaves.ts +0 -20
  277. package/src/debug/functions/draw-elem/loop.ts +0 -16
  278. package/src/debug/functions/draw-elem/loops.ts +0 -10
  279. package/src/debug/functions/draw-elem/loose-bounding-box.ts +0 -21
  280. package/src/debug/functions/draw-elem/mat.ts +0 -47
  281. package/src/debug/functions/draw-elem/max-vertex.ts +0 -15
  282. package/src/debug/functions/draw-elem/min-y.ts +0 -18
  283. package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +0 -26
  284. package/src/debug/functions/draw-elem/one-prong.ts +0 -23
  285. package/src/debug/functions/draw-elem/sharp-corner.ts +0 -20
  286. package/src/debug/functions/draw-elem/three-prong.ts +0 -30
  287. package/src/debug/functions/draw-elem/tight-bounding-box.ts +0 -18
  288. package/src/debug/functions/draw-elem/two-prong.ts +0 -50
  289. package/src/debug/functions/draw-elem/vertex.ts +0 -51
  290. package/src/debug/functions/general.ts +0 -79
  291. package/src/debug/functions/three-prong.ts +0 -249
  292. package/src/debug/functions/two-prong.ts +0 -203
  293. package/src/find-2-prong/add-debug-info.ts +0 -45
  294. package/src/find-3-prong/timed-cc.ts +0 -9
@@ -1,25 +1,8 @@
1
- // import { TriMapFs } from '../utils/tri-map.js';
2
1
  import { getBoundingHull, getBoundingBoxTight } from 'flo-bezier3';
3
2
  import { getBoundingBox$ } from '../geometry/get-bounding-box-.js';
4
3
  import { getCorner } from '../corner/get-corner.js';
5
4
  let timingStart;
6
5
  /** @internal */
7
- function getPointToCpNode(loops, cpTrees) {
8
- timingStart = performance.now();
9
- // const pointToCpNode: TriMap<Loop,number,number,CpNode> = new Map();
10
- // for (const loop of loops) {
11
- // // Populate `posMap`
12
- // const cpTree = cpTrees.get(loop)!;
13
- // const cpNodes = cpTree.toArrayInOrder();
14
- // for (const cpNode of cpNodes) {
15
- // const { p, t } = cpNode.pointOnShape;
16
- // TriMapFs.set(pointToCpNode,loop,p[0],p[1],cpNode);
17
- // }
18
- // }
19
- // return pointToCpNode;
20
- return undefined;
21
- }
22
- /** @internal */
23
6
  function getPartialMeta(loops) {
24
7
  const looseBoundingBoxes = [];
25
8
  const tightBoundingBoxes = [];
@@ -52,33 +35,36 @@ function getPartialMeta(loops) {
52
35
  dullCorners
53
36
  };
54
37
  }
38
+ function addDebugInfo1() {
39
+ if (typeof _debug_ === 'undefined') {
40
+ return;
41
+ }
42
+ timingStart = performance.now();
43
+ }
55
44
  /** @internal */
56
45
  function addDebugInfo2() {
57
46
  if (typeof _debug_ === 'undefined') {
58
47
  return;
59
48
  }
60
- const timing = _debug_.generated.timing;
61
49
  const now = performance.now();
62
- timing.holeClosers += now - timingStart;
50
+ _debug_.timing.holeClosers += now - timingStart;
63
51
  timingStart = now;
64
52
  }
53
+ /** @internal */
65
54
  function addDebugInfo3() {
66
55
  if (typeof _debug_ === 'undefined') {
67
56
  return;
68
57
  }
69
- const generated = _debug_.generated;
70
- const timing = generated.timing;
71
58
  const now = performance.now();
72
- timing.oneAnd2Prongs += now - timingStart;
59
+ _debug_.timing.oneAnd2Prongs += now - timingStart;
73
60
  timingStart = now;
74
61
  }
62
+ /** @internal */
75
63
  function addDebugInfo4() {
76
64
  if (typeof _debug_ === 'undefined') {
77
65
  return;
78
66
  }
79
- const generated = _debug_.generated;
80
- const timing = generated.timing;
81
- timing.threeProngs += performance.now() - timingStart;
67
+ _debug_.timing.threeProngs += performance.now() - timingStart;
82
68
  }
83
- export { getPointToCpNode, getPartialMeta, addDebugInfo2, addDebugInfo3, addDebugInfo4 };
69
+ export { getPartialMeta, addDebugInfo1, addDebugInfo2, addDebugInfo3, addDebugInfo4 };
84
70
  //# sourceMappingURL=get-meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-meta.js","sourceRoot":"","sources":["../../src/find-mat/get-meta.ts"],"names":[],"mappings":"AAMA,kDAAkD;AAClD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAOpD,IAAI,WAAmB,CAAC;AAGxB,gBAAgB;AAChB,SAAS,gBAAgB,CACjB,KAAa,EACb,OAAkC;IAEtC,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAEhC,sEAAsE;IAEtE,8BAA8B;IAC9B,2BAA2B;IAC3B,yCAAyC;IACzC,+CAA+C;IAC/C,sCAAsC;IACtC,gDAAgD;IAChD,6DAA6D;IAC7D,QAAQ;IACR,IAAI;IAEJ,wBAAwB;IACxB,OAAO,SAAU,CAAA;AACrB,CAAC;AAGD,gBAAgB;AAChB,SAAS,cAAc,CACf,KAAa;IAUjB,MAAM,kBAAkB,GAAiB,EAAE,CAAC;IAC5C,MAAM,kBAAkB,GAAiB,EAAE,CAAC;IAC5C,MAAM,aAAa,GAAiB,EAAE,CAAC;IACvC,MAAM,YAAY,GAAY,EAAE,CAAC;IACjC,MAAM,WAAW,GAAY,EAAE,CAAC;IAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,EAAE,IAAI,CAAE,CAAC;YAExC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzB,MAAM,gBAAgB,GAAG,eAAe,CAAC,E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AAG,WAAW,CAAC;IAClD,WAAW,GAAG,GAAG,CAAC;AACtB,CAAC;AAGD,gBAAgB;AAChB,SAAS,aAAa;IAClB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAE/C,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;AAClE,CAAC;AAGD,OAAO,EACH,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EAChB,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { controlPointLinesLength } from 'flo-bezier3';
2
- import { toP } from '../point-on-shape/to-p.js';
3
2
  import { getCorner } from '../corner/get-corner.js';
4
3
  /** @internal */
5
4
  function getSharpCornersOnLoop(minBezLength) {
@@ -11,7 +10,10 @@ function getSharpCornersOnLoop(minBezLength) {
11
10
  continue;
12
11
  }
13
12
  if (getCorner(curve.ps, curve.next.ps).isQuiteSharp) {
14
- sharpCorners.push({ curve, t: 1, isSource: true, p: toP(curve.ps, 1) });
13
+ const { ps } = curve;
14
+ const p = ps[ps.length - 1];
15
+ const pDd = [[0, p[0]], [0, p[1]]];
16
+ sharpCorners.push({ curve, t: 1, isSource: true, p, pDd });
15
17
  }
16
18
  }
17
19
  return sharpCorners;
@@ -1 +1 @@
1
- {"version":3,"file":"get-sharp-corners.js","sourceRoot":"","sources":["../../src/find-mat/get-sharp-corners.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,gBAAgB;AAChB,SAAS,qBAAqB,CACtB,YAAoB;IAExB,OAAO,CAAC,IAAU,EAAqB,EAAE;QACrC,MAAM,YAAY,GAAsB,EAAE,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,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AED,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC;gBAClD,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;gBAErB,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAC5B,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;YAC/D,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACxB,CAAC,CAAA;AACL,CAAC;AAID,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the coefficients `a0` and `b0` for the linear equation
3
+ * `a0⋅t + b0 = 0`, so the ray parameter can be recovered as `t = -b0/a0`.
4
+ * That parameter value makes `q(t) = p + t⋅v` equidistant from `p` and `P`.
5
+ *
6
+ * Let `p` be a fixed point in the plane.\
7
+ * Let `v` be a direction vector defining the ray `q(t) = p + t⋅v`.\
8
+ * Let `P` be another point.\
9
+ *
10
+ * In other words, this function returns the coefficients needed to solve for
11
+ * the ray parameter of the medial point on the ray.
12
+ *
13
+ * @param p base point
14
+ * @param v ray direction from `p`
15
+ * @param P another "target" point, e.g. `[1,2]`
16
+ */
17
+ declare function ddGetMedialPointCoeffsBez0(p: number[][], v: number[][], P: number[]): {
18
+ a0: number[];
19
+ b0: number[];
20
+ };
21
+ export { ddGetMedialPointCoeffsBez0 };
@@ -0,0 +1,46 @@
1
+ import { ddAddDd, ddMultDd, ddMultBy2, ddDiffDouble } from 'double-double';
2
+ const qaq = ddAddDd;
3
+ const qmq = ddMultDd;
4
+ const qm2 = ddMultBy2;
5
+ const qdd = ddDiffDouble;
6
+ // TODO - move all these upstream to flo-bezier3
7
+ /**
8
+ * Returns the coefficients `a0` and `b0` for the linear equation
9
+ * `a0⋅t + b0 = 0`, so the ray parameter can be recovered as `t = -b0/a0`.
10
+ * That parameter value makes `q(t) = p + t⋅v` equidistant from `p` and `P`.
11
+ *
12
+ * Let `p` be a fixed point in the plane.\
13
+ * Let `v` be a direction vector defining the ray `q(t) = p + t⋅v`.\
14
+ * Let `P` be another point.\
15
+ *
16
+ * In other words, this function returns the coefficients needed to solve for
17
+ * the ray parameter of the medial point on the ray.
18
+ *
19
+ * @param p base point
20
+ * @param v ray direction from `p`
21
+ * @param P another "target" point, e.g. `[1,2]`
22
+ */
23
+ function ddGetMedialPointCoeffsBez0(p, v, P) {
24
+ // -----------------------------------------------------
25
+ // See get-medial-points.md for implementation details.
26
+ // -----------------------------------------------------
27
+ const [px, py] = p;
28
+ const [vx, vy] = v;
29
+ const [x0, y0] = P;
30
+ // Constant bezier in power basis: b(s) = c
31
+ // u(s) = p - b(s) = u0
32
+ // const u0x = px - x0;
33
+ // const u0y = py - y0;
34
+ const u0x = qdd(px, x0);
35
+ const u0y = qdd(py, y0);
36
+ // E2(s,t): |t⋅v|² - |u(s) + t⋅v|² = 0
37
+ // => 2⋅(v⋅u(s))⋅t + |u(s)|² = 0
38
+ // => A(s)⋅t + B(s) = 0
39
+ // const a0 = 2*(vx*u0x + vy*u0y);
40
+ // const b0 = u0x*u0x + u0y*u0y;
41
+ const a0 = qaq(qmq(qm2(vx), u0x), qmq(qm2(vy), u0y));
42
+ const b0 = qaq(qmq(u0x, u0x), qmq(u0y, u0y));
43
+ return { a0, b0 };
44
+ }
45
+ export { ddGetMedialPointCoeffsBez0 };
46
+ //# sourceMappingURL=dd-get-medial-point-coeffs-bez0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-get-medial-point-coeff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AE,EAAE,CAAC;AACtB,CAAC;AAGD,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Returns the polynomial coefficients used to recover ray parameter values `t`
3
+ * for a ray `q(t) = p + t⋅v` and an order-1 bezier curve `ps`.
4
+ *
5
+ * The returned polynomials encode the medial-condition equations in `s` and
6
+ * `t`. For any valid solution, `t` is recovered by eliminating `s` and solving
7
+ * the resulting ray equation, or equivalently by using the linear form
8
+ * `A(s)⋅t + B(s) = 0`, which gives `t = -B(s)/A(s)`.
9
+ *
10
+ * More specifically, the returned values represent:
11
+ * * `A` and `B`: the coefficients of `E2(s,t) = A(s)⋅t + B(s)`
12
+ * * `C` and `D`: the coefficients of `E1(s,t) = C(s)⋅t + D(s)`
13
+ * * `H`: the eliminated polynomial `A(s)⋅D(s) - B(s)⋅C(s)` whose roots are
14
+ * candidate `s` values for medial points
15
+ *
16
+ * @param p base point
17
+ * @param v ray direction vector starting from `p`
18
+ * @param ps order 1 bezier control points, i.e. a line segment
19
+ * given as an array of control points, e.g. `[[0,0],[2,1]]`
20
+ */
21
+ declare function ddGetMedialPointCoeffsBez1(p: number[][], v: number[][], ps: number[][]): {
22
+ A: number[][];
23
+ B: number[][];
24
+ C: number[][];
25
+ D: number[][];
26
+ H: number[][];
27
+ };
28
+ export { ddGetMedialPointCoeffsBez1 };
@@ -0,0 +1,97 @@
1
+ import { twoDiff, ddAddDd, ddMultDd, ddNegativeOf, ddMultByNeg2, ddDiffDouble, ddMultBy2 } from 'double-double';
2
+ const td = twoDiff;
3
+ const qaq = ddAddDd;
4
+ const qmq = ddMultDd;
5
+ const qno = ddNegativeOf;
6
+ const qmn2 = ddMultByNeg2;
7
+ const qm2 = ddMultBy2;
8
+ const qdd = ddDiffDouble;
9
+ /**
10
+ * Returns the polynomial coefficients used to recover ray parameter values `t`
11
+ * for a ray `q(t) = p + t⋅v` and an order-1 bezier curve `ps`.
12
+ *
13
+ * The returned polynomials encode the medial-condition equations in `s` and
14
+ * `t`. For any valid solution, `t` is recovered by eliminating `s` and solving
15
+ * the resulting ray equation, or equivalently by using the linear form
16
+ * `A(s)⋅t + B(s) = 0`, which gives `t = -B(s)/A(s)`.
17
+ *
18
+ * More specifically, the returned values represent:
19
+ * * `A` and `B`: the coefficients of `E2(s,t) = A(s)⋅t + B(s)`
20
+ * * `C` and `D`: the coefficients of `E1(s,t) = C(s)⋅t + D(s)`
21
+ * * `H`: the eliminated polynomial `A(s)⋅D(s) - B(s)⋅C(s)` whose roots are
22
+ * candidate `s` values for medial points
23
+ *
24
+ * @param p base point
25
+ * @param v ray direction vector starting from `p`
26
+ * @param ps order 1 bezier control points, i.e. a line segment
27
+ * given as an array of control points, e.g. `[[0,0],[2,1]]`
28
+ */
29
+ function ddGetMedialPointCoeffsBez1(p, v, ps) {
30
+ // -----------------------------------------------------
31
+ // See get-medial-points.md for implementation details.
32
+ // -----------------------------------------------------
33
+ const [px, py] = p;
34
+ const [vx, vy] = v;
35
+ const [[x0, y0], [x1, y1]] = ps;
36
+ // Linear bezier in power basis: b(s) = b*s + c
37
+ // We can also use: `const [[bx,by], [cx,cy]] = toPowerBasis1(ps)`
38
+ // const bx = x1 - x0;
39
+ // const by = y1 - y0;
40
+ const bx = td(x1, x0);
41
+ const by = td(y1, y0);
42
+ // u(s) = p - b(s) = u1*s + u0
43
+ // const u0x = px - x0;
44
+ // const u0y = py - y0;
45
+ const u0x = qdd(px, x0);
46
+ const u0y = qdd(py, y0);
47
+ // b'(s) = w(s) = w0
48
+ // -----------------------------------------------------
49
+ // E1(s,t): (u(s) + t⋅v) ⋅ b'(s) = 0
50
+ // => C(s)⋅t + D(s) = 0
51
+ // const c0 = vx*bx + vy*by;
52
+ const c0 = qaq(qmq(vx, bx), qmq(vy, by));
53
+ // -----------------------------------------------------
54
+ // -----------------------------------------------------
55
+ // const d1 = -(bx*bx + by*by);
56
+ // const d0 = bx*u0x + by*u0y;
57
+ // const d1 = qmd(-1,qaq(qmq(bx,bx),qmq(by,by)));
58
+ const d1 = qno(qaq(qmq(bx, bx), qmq(by, by)));
59
+ const d0 = qaq(qmq(bx, u0x), qmq(by, u0y));
60
+ // -----------------------------------------------------
61
+ // -----------------------------------------------------
62
+ // E2(s,t): |t⋅v|² - |u(s) + t⋅v|² = 0
63
+ // => 2⋅(v⋅u(s))⋅t + |u(s)|² = 0
64
+ // => A(s)⋅t + B(s) = 0
65
+ // const a1 = -2*c0;
66
+ // const a0 = 2*(vx*u0x + vy*u0y);
67
+ const a1 = qmn2(c0);
68
+ const a0 = qaq(qmq(qm2(vx), u0x), qmq(qm2(vy), u0y));
69
+ // -----------------------------------------------------
70
+ // -----------------------------------------------------
71
+ // const b2 = -d1;
72
+ // const b1 = -2*d0;
73
+ // const b0 = u0x*u0x + u0y*u0y;
74
+ const b2 = qno(d1);
75
+ const b1 = qmn2(d0);
76
+ const b0 = qaq(qmq(u0x, u0x), qmq(u0y, u0y));
77
+ // -----------------------------------------------------
78
+ // Eliminate t from:
79
+ // A(s)⋅t + B(s) = 0
80
+ // C(s)⋅t + D(s) = 0
81
+ // by taking A(s)⋅D(s) - B(s)⋅C(s) = 0 (degree ≤ 2 in s)
82
+ // const H2 = b2*c0;
83
+ // const H1 = a0*d1;
84
+ // const H0 = a0*d0 - b0*c0;
85
+ const H2 = qmq(b2, c0);
86
+ const H1 = qmq(a0, d1);
87
+ const H0 = qaq(qmq(a0, d0), qno(qmq(b0, c0)));
88
+ return {
89
+ A: [a1, a0],
90
+ B: [b2, b1, b0],
91
+ C: [c0],
92
+ D: [d1, d0],
93
+ H: [H2, H1, H0]
94
+ };
95
+ }
96
+ export { ddGetMedialPointCoeffsBez1 };
97
+ //# sourceMappingURL=dd-get-medial-point-coeffs-bez1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-get-medial-point-coeffs-bez1.js","sourceRoot":"","sources":["../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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EAAE,GAAG,GAAG,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;IACtB,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,EAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5C,OAAO;QACH,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;QACX,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;QACf,CAAC,EAAE,CAAC,EAAE,CAAC;QACP,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;QACX,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;KAClB,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Returns polynomial coefficients for the same-curve quadratic medial-point
3
+ * case, where `p = b(t)` on the same quadratic bezier `ps` and `v` is normal
4
+ * to the curve at that parameter `t`.
5
+ *
6
+ * The returned coefficients encode:
7
+ * * `A`, `B`: `E2(s, τ) = (s - t)^2⋅(A(s)⋅τ + B(s))`
8
+ // * * `C`, `D`: `E1(s, τ) = C(s)⋅τ + D(s)`
9
+ * * `H`: the reduced eliminant in `s`
10
+ *
11
+ * Here `τ` is the ray parameter in `q(τ) = p + τ⋅v`.
12
+ * For a candidate root `s` of `H`, recover `τ` from
13
+ * `A(s)⋅τ + B(s) = 0`, i.e. `τ = -B(s)/A(s)` when `A(s) ≠ 0`.
14
+ *
15
+ * In this same-curve setup, the full eliminant has the form
16
+ * `H_full(s) = (s - t)^4*(l1*s + l0)`. This function returns only the reduced
17
+ * factor `H(s) = l1*s + l0` (the repeated `(s - t)^4` factor is omitted).
18
+ *
19
+ * @param t parameter on `ps` where `p = b(t)`
20
+ * @param v ray direction from `p`; assumed normal to `ps` at `t`
21
+ * @param ps order 2 bezier control points, e.g. `[[0,0],[1,1],[2,1]]`
22
+ */
23
+ declare function ddGetMedialPointCoeffsBez2_SameCurve(t: number, v: number[][], ps: number[][]): {
24
+ A: number[][];
25
+ B: number[][];
26
+ H: number[][];
27
+ };
28
+ export { ddGetMedialPointCoeffsBez2_SameCurve };
@@ -0,0 +1,109 @@
1
+ import { toPowerBasisDd } from 'flo-bezier3';
2
+ import { ddMultDouble2, ddAddDd, ddMultDd, ddNegativeOf, ddMultBy2 } from 'double-double';
3
+ const qmd = ddMultDouble2;
4
+ const qaq = ddAddDd;
5
+ const qmq = ddMultDd;
6
+ const qno = ddNegativeOf;
7
+ const qm2 = ddMultBy2;
8
+ /**
9
+ * Returns polynomial coefficients for the same-curve quadratic medial-point
10
+ * case, where `p = b(t)` on the same quadratic bezier `ps` and `v` is normal
11
+ * to the curve at that parameter `t`.
12
+ *
13
+ * The returned coefficients encode:
14
+ * * `A`, `B`: `E2(s, τ) = (s - t)^2⋅(A(s)⋅τ + B(s))`
15
+ // * * `C`, `D`: `E1(s, τ) = C(s)⋅τ + D(s)`
16
+ * * `H`: the reduced eliminant in `s`
17
+ *
18
+ * Here `τ` is the ray parameter in `q(τ) = p + τ⋅v`.
19
+ * For a candidate root `s` of `H`, recover `τ` from
20
+ * `A(s)⋅τ + B(s) = 0`, i.e. `τ = -B(s)/A(s)` when `A(s) ≠ 0`.
21
+ *
22
+ * In this same-curve setup, the full eliminant has the form
23
+ * `H_full(s) = (s - t)^4*(l1*s + l0)`. This function returns only the reduced
24
+ * factor `H(s) = l1*s + l0` (the repeated `(s - t)^4` factor is omitted).
25
+ *
26
+ * @param t parameter on `ps` where `p = b(t)`
27
+ * @param v ray direction from `p`; assumed normal to `ps` at `t`
28
+ * @param ps order 2 bezier control points, e.g. `[[0,0],[1,1],[2,1]]`
29
+ */
30
+ function ddGetMedialPointCoeffsBez2_SameCurve(t, v, ps) {
31
+ // -----------------------------------------------------
32
+ // See get-medial-points.md for implementation details.
33
+ // -----------------------------------------------------
34
+ // Quadratic bezier in power basis: b(s) = a⋅s² + b⋅s + c
35
+ const [[ax, bx], [ay, by]] = toPowerBasisDd(ps);
36
+ const [vx, vy] = v;
37
+ // Same-curve assumption with explicit parameter `t`:
38
+ // p = b(t) => u0 = p - c = t*(a*t + b).
39
+ // const g0x = ax*t + bx;
40
+ // const g0y = ay*t + by;
41
+ const g0x = qaq(qmd(t, ax), bx);
42
+ const g0y = qaq(qmd(t, ay), by);
43
+ // Reuse core quadratic-form terms to reduce repeated multiplications.
44
+ // const br2 = ax*ax + ay*ay;
45
+ // const ab = ax*bx + ay*by;
46
+ // const bb = bx*bx + by*by;
47
+ // const ag = ax*g0x + ay*g0y;
48
+ const br2 = qaq(qmq(ax, ax), qmq(ay, ay));
49
+ const ab = qaq(qmq(ax, bx), qmq(ay, by));
50
+ const ag = qaq(qmq(ax, g0x), qmq(ay, g0y));
51
+ // -----------------------------------------------------
52
+ // E1(s,t): (u(s) + t⋅v) ⋅ b'(s) = 0
53
+ // => C(s)⋅t + D(s) = 0
54
+ // const c1 = 2*(vx*ax + vy*ay);
55
+ const c1 = qm2(qaq(qmq(vx, ax), qmq(vy, ay)));
56
+ // v is normal at parameter t, so C(t) = v⋅w(t) = 0.
57
+ // Since C(s) = c1*s + c0, enforce c0 = -c1*t exactly.
58
+ // const c0 = -c1*t;
59
+ // const d3 = -2*br2;
60
+ // const d2 = -3*ab;
61
+ // const d1 = 2*t*ag - bb;
62
+ // p = b(t) => D(t) = u(t)⋅w(t) = 0.
63
+ // const d0 = -t*(t*(d3*t + d2) + d1);
64
+ // -----------------------------------------------------
65
+ // -----------------------------------------------------
66
+ // E2(s,t): |t⋅v|² - |u(s) + t⋅v|² = 0
67
+ // => 2⋅(v⋅u(s))⋅t + |u(s)|² = 0
68
+ // => (s - t)^2⋅(A(s)⋅t + B(s)) = 0
69
+ // Return only the reduced constant A(s) = ar0.
70
+ // const ar0 = -c1;
71
+ const ar0 = qno(c1);
72
+ // Full B(s) factorizes as: B_full(s) = (s - t)^2*B_reduced(s).
73
+ // Return only B_reduced(s) = br2*s^2 + br1*s + br0.
74
+ // const br1 = 2*ag;
75
+ // const br0 = g0x*g0x + g0y*g0y;
76
+ const br1 = qm2(ag);
77
+ const br0 = qaq(qmq(g0x, g0x), qmq(g0y, g0y));
78
+ // -----------------------------------------------------
79
+ // Eliminate t from:
80
+ // A(s)⋅t + B(s) = 0
81
+ // C(s)⋅t + D(s) = 0
82
+ // by taking A(s)⋅D(s) - B(s)⋅C(s) = 0 (degree ≤ 5 in s)
83
+ // For this same-curve quadratic case:
84
+ // d3 = -2*b4, d2 = -(3/2)*b3, a2 = -c1, a1 = -2*c0.
85
+ // Therefore H5 and H4 reduce to:
86
+ // H5 = b4*c1
87
+ // H4 = 3*b4*c0 + (1/2)*b3*c1
88
+ // const H5 = br2*c1;
89
+ const H5 = qmq(br2, c1);
90
+ // In the same-curve quadratic case the full eliminant has the form
91
+ // H_full(s) = (s - t)^4*(l1*s + l0).
92
+ // Match the leading coefficients of H_full(s):
93
+ // H5 = l1
94
+ // H4 = l0 - 4*t*l1
95
+ // const l1 = H5;
96
+ // const l0 = H4 + 4*t*l1;
97
+ // Using c0 = -c1*t and b3 = 2*ab, this simplifies to l0 = c1*(br2*t + ab).
98
+ // const l0 = c1*(br2*t + ab);
99
+ const l0 = qmq(c1, qaq(qmd(t, br2), ab));
100
+ return {
101
+ A: [ar0],
102
+ B: [br2, br1, br0],
103
+ // C: [c1, c0],
104
+ // D: [d3, d2, d1, d0],
105
+ H: [H5, l0]
106
+ };
107
+ }
108
+ export { ddGetMedialPointCoeffsBez2_SameCurve };
109
+ //# sourceMappingURL=dd-get-medial-point-coeffs-bez2-same-curve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-get-medial-point-coeffs-bez2-same-curve.js","sourceRoot":"","sources":["../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,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,CAAC,EAAC,GAAG,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC;IAEtC,OAAO;QACH,CAAC,EAAE,CAAC,GAAG,CAAC;QACR,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QAClB,eAAe;QACf,uBAAuB;QACvB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;KACd,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,oCAAoC,EAAE,CAAA"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Returns the polynomial coefficients for the ray parameter `t` and the
3
+ * curve parameter `s` that encode the medial condition for `q(t) = p + t⋅v`
4
+ * and a quadratic bezier curve `ps`.
5
+ *
6
+ * The returned coefficients describe the equations whose common solutions
7
+ * satisfy:
8
+ * * `q(t)` is equidistant from `p` and the nearest point on `ps`
9
+ * * that common distance is locally minimal among such candidates
10
+ *
11
+ * More specifically, this function returns:
12
+ * * `A` and `B`: the coefficients of `E2(s,t) = A(s)⋅t + B(s)`
13
+ * * `C` and `D`: the coefficients of `E1(s,t) = C(s)⋅t + D(s)`
14
+ * * `H`: the eliminated polynomial `A(s)⋅D(s) - B(s)⋅C(s)` whose roots are
15
+ * candidate `s` values for medial points
16
+ *
17
+ * @param p base point
18
+ * @param v ray direction from `p`
19
+ * @param ps quadratic bezier control points, i.e. an order 2 bezier curve
20
+ * given as an array of control points, e.g. `[[0,0],[1,1],[2,1]]`
21
+ */
22
+ declare function ddGetMedialPointCoeffsBez2(p: number[][], v: number[][], ps: number[][]): {
23
+ A: number[][];
24
+ B: number[][];
25
+ C: number[][];
26
+ D: number[][];
27
+ H: number[][];
28
+ };
29
+ export { ddGetMedialPointCoeffsBez2 };
@@ -0,0 +1,123 @@
1
+ import { toPowerBasisDd } from 'flo-bezier3';
2
+ import { ddMultDouble2, ddAddDd, ddMultDd, ddNegativeOf, ddMultByNeg2, ddMultBy2, ddDiffDouble } from 'double-double';
3
+ const qmd = ddMultDouble2;
4
+ const qaq = ddAddDd;
5
+ const qmq = ddMultDd;
6
+ const qno = ddNegativeOf;
7
+ const qmn2 = ddMultByNeg2;
8
+ const qm2 = ddMultBy2;
9
+ const qdd = ddDiffDouble;
10
+ /**
11
+ * Returns the polynomial coefficients for the ray parameter `t` and the
12
+ * curve parameter `s` that encode the medial condition for `q(t) = p + t⋅v`
13
+ * and a quadratic bezier curve `ps`.
14
+ *
15
+ * The returned coefficients describe the equations whose common solutions
16
+ * satisfy:
17
+ * * `q(t)` is equidistant from `p` and the nearest point on `ps`
18
+ * * that common distance is locally minimal among such candidates
19
+ *
20
+ * More specifically, this function returns:
21
+ * * `A` and `B`: the coefficients of `E2(s,t) = A(s)⋅t + B(s)`
22
+ * * `C` and `D`: the coefficients of `E1(s,t) = C(s)⋅t + D(s)`
23
+ * * `H`: the eliminated polynomial `A(s)⋅D(s) - B(s)⋅C(s)` whose roots are
24
+ * candidate `s` values for medial points
25
+ *
26
+ * @param p base point
27
+ * @param v ray direction from `p`
28
+ * @param ps quadratic bezier control points, i.e. an order 2 bezier curve
29
+ * given as an array of control points, e.g. `[[0,0],[1,1],[2,1]]`
30
+ */
31
+ function ddGetMedialPointCoeffsBez2(p, v, ps) {
32
+ // -----------------------------------------------------
33
+ // See get-medial-points.md for implementation details.
34
+ // -----------------------------------------------------
35
+ const [px, py] = p;
36
+ const [vx, vy] = v;
37
+ const [[x0, y0]] = ps;
38
+ // Quadratic bezier in power basis: b(s) = a⋅s² + b⋅s + c
39
+ const [[ax, bx], [ay, by]] = toPowerBasisDd(ps);
40
+ // u(s) = p - b(s) = u2⋅s² + u1⋅s + u0
41
+ // const u0x = px - x0;
42
+ // const u0y = py - y0;
43
+ const u0x = qdd(px, x0);
44
+ const u0y = qdd(py, y0);
45
+ // Shared dot products.
46
+ // const c1 = 2*(vx*ax + vy*ay);
47
+ // const c0 = vx*bx + vy*by;
48
+ // const vu0 = vx*u0x + vy*u0y;
49
+ // const b4 = ax*ax + ay*ay;
50
+ // const ab = ax*bx + ay*by;
51
+ // const bb = bx*bx + by*by;
52
+ // const u0a = u0x*ax + u0y*ay;
53
+ // const d0 = u0x*bx + u0y*by;
54
+ // const b0 = u0x*u0x + u0y*u0y;
55
+ const c1 = qm2(qaq(qmq(vx, ax), qmq(vy, ay)));
56
+ const c0 = qaq(qmq(vx, bx), qmq(vy, by));
57
+ const vu0 = qaq(qmq(vx, u0x), qmq(vy, u0y));
58
+ const b4 = qaq(qmq(ax, ax), qmq(ay, ay));
59
+ const ab = qaq(qmq(bx, ax), qmq(by, ay));
60
+ const bb = qaq(qmq(bx, bx), qmq(by, by));
61
+ const u0a = qaq(qmq(u0x, ax), qmq(u0y, ay));
62
+ const d0 = qaq(qmq(bx, u0x), qmq(by, u0y));
63
+ const b0 = qaq(qmq(u0x, u0x), qmq(u0y, u0y));
64
+ // -----------------------------------------------------
65
+ // E1(s,t): (u(s) + t⋅v) ⋅ b'(s) = 0
66
+ // => C(s)⋅t + D(s) = 0
67
+ // -----------------------------------------------------
68
+ // -----------------------------------------------------
69
+ // const d3 = -2*b4;
70
+ // const d2 = -3*ab;
71
+ // const d1 = 2*u0a - bb;
72
+ const d3 = qmn2(b4);
73
+ const d2 = qmd(-3, ab);
74
+ const d1 = qaq(qm2(u0a), qno(bb));
75
+ // -----------------------------------------------------
76
+ // -----------------------------------------------------
77
+ // E2(s,t): |t⋅v|² - |u(s) + t⋅v|² = 0
78
+ // => 2⋅(v⋅u(s))⋅t + |u(s)|² = 0
79
+ // => A(s)⋅t + B(s) = 0
80
+ // const a2 = -c1;
81
+ // const a1 = -2*c0;
82
+ // const a0 = 2*vu0;
83
+ const a2 = qno(c1);
84
+ const a1 = qmn2(c0);
85
+ const a0 = qm2(vu0);
86
+ // -----------------------------------------------------
87
+ // -----------------------------------------------------
88
+ // const b3 = 2*ab;
89
+ // const b2 = -d1;
90
+ // const b1 = -2*d0;
91
+ const b3 = qm2(ab);
92
+ const b2 = qno(d1);
93
+ const b1 = qmn2(d0);
94
+ // -----------------------------------------------------
95
+ // Eliminate t from:
96
+ // A(s)⋅t + B(s) = 0
97
+ // C(s)⋅t + D(s) = 0
98
+ // by taking A(s)⋅D(s) - B(s)⋅C(s) = 0 (degree ≤ 5 in s)
99
+ // Using:
100
+ // a2 = -c1, d3 = -2*b4, d1 = -b2, b1 = -2*d0
101
+ // we can compute H = A⋅D - B⋅C directly.
102
+ // const H5 = b4*c1;
103
+ // const H4 = ab*c1 + 3*b4*c0;
104
+ // const H3 = 4*(ab*c0 - vu0*b4);
105
+ // const H2 = c1*d0 + c0*b2 - 6*vu0*ab;
106
+ // const H1 = -2*vu0*b2 - c1*b0;
107
+ // const H0 = 2*vu0*d0 - c0*b0;
108
+ const H5 = qmq(b4, c1);
109
+ const H4 = qaq(qmq(ab, c1), qmd(3, qmq(b4, c0)));
110
+ const H3 = qm2(qm2(qaq(qmq(ab, c0), qno(qmq(vu0, b4)))));
111
+ const H2 = qaq(qaq(qmq(c1, d0), qmq(c0, b2)), qno(qmd(6, qmq(vu0, ab))));
112
+ const H1 = qaq(qmn2(qmq(vu0, b2)), qno(qmq(c1, b0)));
113
+ const H0 = qaq(qm2(qmq(vu0, d0)), qno(qmq(c0, b0)));
114
+ return {
115
+ A: [a2, a1, a0],
116
+ B: [b4, b3, b2, b1, b0],
117
+ C: [c1, c0],
118
+ D: [d3, d2, d1, d0],
119
+ H: [H5, H4, H3, H2, H1, H0]
120
+ };
121
+ }
122
+ export { ddGetMedialPointCoeffsBez2 };
123
+ //# sourceMappingURL=dd-get-medial-point-coeffs-bez2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-get-medial-point-coeffs-bez2.js","sourceRoot":"","sources":["../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE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