flo-mat 3.0.9 → 3.0.11

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 (261) hide show
  1. package/__tests__/jsog/check-jsog-eql-calc.spec.ts +81 -0
  2. package/__tests__/jsog/decode-jsog.ts +85 -0
  3. package/__tests__/jsog/get-mats1.ts +41 -0
  4. package/__tests__/{cp-node/fs → jsog}/mat-dummys.ts +51 -564
  5. package/__tests__/jsog/to-jsog-breath-first.ts +107 -0
  6. package/__tests__/jsog/to-jsog-depth-first.ts +55 -0
  7. package/browser/index.js +280 -236
  8. package/browser/index.min.js +1 -1
  9. package/node/add-n-prong.ts/join-spokes.js.map +1 -1
  10. package/node/closest-boundary-point/cull-bezier-pieces.d.ts +5 -4
  11. package/node/closest-boundary-point/cull-bezier-pieces.js +9 -8
  12. package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
  13. package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +2 -2
  14. package/node/closest-boundary-point/cull-by-loose-bounding-box.js +8 -8
  15. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
  16. package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +2 -2
  17. package/node/closest-boundary-point/cull-by-tight-boundary-box.js +8 -8
  18. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
  19. package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
  20. package/node/closest-boundary-point/get-best-distance-squared.d.ts +1 -1
  21. package/node/closest-boundary-point/get-best-distance-squared.js +6 -6
  22. package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -1
  23. package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +2 -2
  24. package/node/closest-boundary-point/get-close-boundary-points-certified.js +7 -7
  25. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  26. package/node/contact-point/contact-point.js.map +1 -1
  27. package/node/corner/get-corner.js.map +1 -1
  28. package/node/corner/get-interface-ccw.js.map +1 -1
  29. package/node/cp-node/cp-node-fs.d.ts +2 -1
  30. package/node/cp-node/cp-node-fs.js +1 -2
  31. package/node/cp-node/cp-node-fs.js.map +1 -1
  32. package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
  33. package/node/cp-node/fs/cp-node-comparator.js +6 -0
  34. package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
  35. package/node/cp-node/fs/find-first.js.map +1 -1
  36. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  37. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +1 -1
  38. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +11 -16
  39. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
  40. package/node/cp-node/fs/get-boundary-beziers-between.js +4 -6
  41. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  42. package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +10 -1
  43. package/node/cp-node/fs/get-boundary-beziers-to-next.js +70 -35
  44. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  45. package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
  46. package/node/cp-node/fs/get-branch.js.map +1 -1
  47. package/node/cp-node/fs/get-children.js.map +1 -1
  48. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  49. package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
  50. package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
  51. package/node/cp-node/fs/get-prong-count.js.map +1 -1
  52. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  53. package/node/cp-node/fs/get-salience.js +2 -2
  54. package/node/cp-node/fs/get-salience.js.map +1 -1
  55. package/node/cp-node/fs/get-speed.js +0 -1
  56. package/node/cp-node/fs/get-speed.js.map +1 -1
  57. package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
  58. package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
  59. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  60. package/node/cp-node/fs/is-one-prong.js.map +1 -1
  61. package/node/cp-node/fs/is-sharp.js.map +1 -1
  62. package/node/cp-node/fs/is-terminating.js.map +1 -1
  63. package/node/cp-node/fs/traverse-cp.js.map +1 -1
  64. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  65. package/node/cp-node/fs/traverse-vertices.js.map +1 -1
  66. package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
  67. package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
  68. package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
  69. package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
  70. package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
  71. package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
  72. package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
  73. package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
  74. package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
  75. package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
  76. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
  77. package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
  78. package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
  79. package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
  80. package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
  81. package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
  82. package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
  83. package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
  84. package/node/debug/functions/general.js.map +1 -1
  85. package/node/find-2-prong/add-1-prong.js.map +1 -1
  86. package/node/find-2-prong/cull-bezier-pieces.d.ts +4 -4
  87. package/node/find-2-prong/cull-bezier-pieces.js +9 -9
  88. package/node/find-2-prong/cull-bezier-pieces.js.map +1 -1
  89. package/node/find-2-prong/find-2-prong.js +8 -8
  90. package/node/find-2-prong/find-2-prong.js.map +1 -1
  91. package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
  92. package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -2
  93. package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
  94. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
  95. package/node/find-2-prong/reduce-radius.d.ts +1 -1
  96. package/node/find-2-prong/reduce-radius.js +5 -5
  97. package/node/find-2-prong/reduce-radius.js.map +1 -1
  98. package/node/find-3-prong.ts/calc-better-x.d.ts +2 -2
  99. package/node/find-3-prong.ts/calc-better-x.js +3 -3
  100. package/node/find-3-prong.ts/calc-better-x.js.map +1 -1
  101. package/node/find-3-prong.ts/calc-initial-3-prong-center.d.ts +2 -2
  102. package/node/find-3-prong.ts/calc-initial-3-prong-center.js +3 -3
  103. package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -1
  104. package/node/find-3-prong.ts/find-3-prong-for-delta3s.d.ts +2 -2
  105. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js +16 -16
  106. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -1
  107. package/node/find-3-prong.ts/find-3-prong.js +2 -2
  108. package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
  109. package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
  110. package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
  111. package/node/find-3-prong.ts/get-closest-points.d.ts +2 -2
  112. package/node/find-3-prong.ts/get-closest-points.js +4 -4
  113. package/node/find-3-prong.ts/get-closest-points.js.map +1 -1
  114. package/node/find-mat/find-mats.js.map +1 -1
  115. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
  116. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
  117. package/node/index.d.ts +35 -1
  118. package/node/index.js +36 -1
  119. package/node/index.js.map +1 -1
  120. package/node/mat/create-new-cp-tree.js.map +1 -1
  121. package/node/mat/get-boundary-piece-beziers.js +7 -7
  122. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  123. package/node/mat/get-largest-vertex.js.map +1 -1
  124. package/node/mat/trim-mat.js.map +1 -1
  125. package/node/memoize-primitive.js.map +1 -1
  126. package/node/sat/add-debug-info.js.map +1 -1
  127. package/node/sat/cull.d.ts +7 -5
  128. package/node/sat/cull.js +7 -4
  129. package/node/sat/cull.js.map +1 -1
  130. package/node/sat/get-leaves.js.map +1 -1
  131. package/node/sat/to-scale-axis.d.ts +3 -2
  132. package/node/sat/to-scale-axis.js +3 -2
  133. package/node/sat/to-scale-axis.js.map +1 -1
  134. package/node/svg/get-loop-bounds.js.map +1 -1
  135. package/node/svg/get-min-y-pos.js.map +1 -1
  136. package/node/sweep-line/sweep-line.js.map +1 -1
  137. package/package.json +6 -6
  138. package/src/add-n-prong.ts/join-spokes.ts +11 -11
  139. package/src/closest-boundary-point/cull-bezier-pieces.ts +12 -11
  140. package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +8 -8
  141. package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +8 -8
  142. package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
  143. package/src/closest-boundary-point/get-best-distance-squared.ts +6 -6
  144. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +41 -41
  145. package/src/contact-point/contact-point.ts +13 -13
  146. package/src/corner/get-corner.ts +39 -39
  147. package/src/corner/get-interface-ccw.ts +3 -3
  148. package/src/cp-node/cp-node-fs.ts +132 -135
  149. package/src/cp-node/cp-node.ts +30 -30
  150. package/src/cp-node/fs/clone.ts +4 -4
  151. package/src/cp-node/fs/cp-node-comparator.ts +13 -0
  152. package/src/cp-node/fs/find-first.ts +6 -6
  153. package/src/cp-node/fs/get-all-on-loop.ts +1 -1
  154. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +12 -18
  155. package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -7
  156. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +79 -53
  157. package/src/cp-node/fs/get-branch-beziers.ts +1 -1
  158. package/src/cp-node/fs/get-branch.ts +1 -1
  159. package/src/cp-node/fs/get-children.ts +8 -8
  160. package/src/cp-node/fs/get-first-exit.ts +11 -11
  161. package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
  162. package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
  163. package/src/cp-node/fs/get-prong-count.ts +8 -8
  164. package/src/cp-node/fs/get-real-prong-count.ts +3 -3
  165. package/src/cp-node/fs/get-salience.ts +2 -2
  166. package/src/cp-node/fs/get-speed.ts +1 -6
  167. package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
  168. package/src/cp-node/fs/is-fully-terminating.ts +3 -3
  169. package/src/cp-node/fs/is-one-prong.ts +8 -8
  170. package/src/cp-node/fs/is-sharp.ts +1 -1
  171. package/src/cp-node/fs/is-terminating.ts +1 -1
  172. package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
  173. package/src/cp-node/fs/traverse-all-forward.ts +11 -11
  174. package/src/cp-node/fs/traverse-cp.ts +19 -17
  175. package/src/cp-node/fs/traverse-edges.ts +10 -10
  176. package/src/cp-node/fs/traverse-vertices.ts +17 -17
  177. package/src/curve/curve.ts +26 -26
  178. package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
  179. package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
  180. package/src/debug/functions/draw-elem/culls.ts +2 -2
  181. package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
  182. package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
  183. package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
  184. package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
  185. package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
  186. package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
  187. package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
  188. package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
  189. package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
  190. package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
  191. package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
  192. package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
  193. package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
  194. package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
  195. package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
  196. package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
  197. package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
  198. package/src/debug/functions/draw-elem/leaves.ts +2 -2
  199. package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
  200. package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
  201. package/src/debug/functions/draw-elem/min-y.ts +2 -2
  202. package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
  203. package/src/debug/functions/draw-elem/one-prong.ts +1 -1
  204. package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
  205. package/src/debug/functions/draw-elem/three-prong.ts +19 -19
  206. package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
  207. package/src/debug/functions/draw-elem/two-prong.ts +44 -44
  208. package/src/debug/functions/draw-elem/vertex.ts +28 -28
  209. package/src/debug/functions/general.ts +18 -18
  210. package/src/debug/functions/three-prong.ts +184 -184
  211. package/src/debug/functions/two-prong.ts +201 -201
  212. package/src/debug/two-prong-for-debugging.ts +26 -26
  213. package/src/find-2-prong/add-1-prong.ts +25 -25
  214. package/src/find-2-prong/add-debug-info.ts +38 -38
  215. package/src/find-2-prong/cull-bezier-pieces.ts +10 -10
  216. package/src/find-2-prong/find-2-prong.ts +158 -158
  217. package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
  218. package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
  219. package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
  220. package/src/find-2-prong/reduce-radius.ts +5 -5
  221. package/src/find-3-prong.ts/calc-better-x.ts +3 -3
  222. package/src/find-3-prong.ts/calc-initial-3-prong-center.ts +3 -3
  223. package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +17 -17
  224. package/src/find-3-prong.ts/find-3-prong.ts +23 -23
  225. package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
  226. package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
  227. package/src/find-3-prong.ts/get-closest-points.ts +4 -4
  228. package/src/find-mat/add-2-prongs-by-error.ts +8 -8
  229. package/src/find-mat/find-mats.ts +49 -49
  230. package/src/find-mat/fix-ordering.ts +2 -2
  231. package/src/find-mat/get-total-by.ts +12 -12
  232. package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
  233. package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
  234. package/src/get-curve/get-curve-between.ts +1 -1
  235. package/src/index.ts +41 -4
  236. package/src/mat/cmp-cp-on-delta.ts +1 -1
  237. package/src/mat/create-new-cp-tree.ts +12 -12
  238. package/src/mat/get-boundary-piece-beziers.ts +7 -7
  239. package/src/mat/get-edges-as-array.ts +9 -9
  240. package/src/mat/get-largest-3-prong.ts +8 -8
  241. package/src/mat/get-largest-three-prong.ts +5 -5
  242. package/src/mat/get-largest-vertex.ts +6 -6
  243. package/src/mat/get-two-prong-type.ts +9 -9
  244. package/src/mat/trim-mat.ts +1 -1
  245. package/src/memoize-primitive.ts +14 -14
  246. package/src/sat/add-debug-info.ts +4 -4
  247. package/src/sat/cull-by-salience.ts +1 -1
  248. package/src/sat/cull.ts +10 -7
  249. package/src/sat/get-leaves.ts +0 -1
  250. package/src/sat/to-scale-axis.ts +18 -17
  251. package/src/svg/get-extreme.ts +8 -8
  252. package/src/svg/get-loop-bounds.ts +84 -84
  253. package/src/svg/get-min-y-pos.ts +1 -1
  254. package/src/sweep-line/sweep-line.ts +23 -23
  255. package/src/utils/bezier-piece-to-bezier.ts +7 -7
  256. package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
  257. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.d.ts +0 -3
  258. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js +0 -6
  259. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js.map +0 -1
  260. package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +0 -70
  261. package/src/cp-node/fs/cp-nodes-to-boundary-beziers.ts +0 -10
package/browser/index.js CHANGED
@@ -1,25 +1,3 @@
1
- /******/ // The require scope
2
- /******/ var __webpack_require__ = {};
3
- /******/
4
- /************************************************************************/
5
- /******/ /* webpack/runtime/define property getters */
6
- /******/ (() => {
7
- /******/ // define getter functions for harmony exports
8
- /******/ __webpack_require__.d = (exports, definition) => {
9
- /******/ for(var key in definition) {
10
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
11
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
12
- /******/ }
13
- /******/ }
14
- /******/ };
15
- /******/ })();
16
- /******/
17
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
18
- /******/ (() => {
19
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
20
- /******/ })();
21
- /******/
22
- /************************************************************************/
23
1
 
24
2
  ;// ./node_modules/flo-boolean/node/loop/loop-from-beziers.js
25
3
  /**
@@ -914,48 +892,6 @@ function floydWarshall(graph) {
914
892
  // INF INF INF 0
915
893
  // floydWarshall(graph);//?
916
894
 
917
- ;// ./src/point-on-shape/compare-poss.ts
918
- /**
919
- * Compares two `PointOnShape`s according to their cyclic ordering imposed
920
- * by their relative positions on the shape boundary.
921
- * @param a The first `PointOnShape`.
922
- * @param b The second `PointOnShape`.
923
- * @internal
924
- */
925
- function comparePoss(a, b) {
926
- let res;
927
- res = a.curve.idx - b.curve.idx;
928
- if (res !== 0) {
929
- return res;
930
- }
931
- res = a.t - b.t;
932
- return res;
933
- }
934
-
935
-
936
- ;// ./src/contact-point/contact-point.ts
937
-
938
- /**
939
- * Primarily for internal use.
940
- *
941
- * Compares the two contact points according to their order along the shape
942
- * boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
943
- * @param a The first contact point.
944
- * @param b The second contact point.
945
- */
946
- function compareCps(a, b) {
947
- let res = comparePoss(a.pointOnShape, b.pointOnShape);
948
- if (res !== 0) {
949
- return res;
950
- }
951
- res = a.order - b.order;
952
- if (res !== 0) {
953
- return res;
954
- }
955
- return a.order2 - b.order2;
956
- }
957
-
958
-
959
895
  ;// ./src/cp-node/fs/get-all-on-loop.ts
960
896
  function getAllOnLoop(cpNode) {
961
897
  const cpStart = cpNode;
@@ -3167,7 +3103,7 @@ const cubicDegenPoint = { order: 3, realOrder: 0, collinear: true, nodeType: 'n/
3167
3103
  * possible planar polynomial bezier curves (of order <= 3) are represented and
3168
3104
  * all options are mutually exclusive.
3169
3105
  */
3170
- const classifications = {
3106
+ const classifications = (/* unused pure expression or super */ null && ({
3171
3107
  point,
3172
3108
  lineGeneral,
3173
3109
  lineDegenPoint,
@@ -3184,7 +3120,7 @@ const classifications = {
3184
3120
  cubicDegenCollinearQuad,
3185
3121
  cubicDegenLine,
3186
3122
  cubicDegenPoint
3187
- };
3123
+ }));
3188
3124
  function classify_isPoint(ps) {
3189
3125
  return classify(ps) === point;
3190
3126
  }
@@ -3233,7 +3169,7 @@ function isCubicDegenLine(ps) {
3233
3169
  function isCubicDegenPoint(ps) {
3234
3170
  return classify(ps) === cubicDegenPoint;
3235
3171
  }
3236
- const classification = {
3172
+ const classification = (/* unused pure expression or super */ null && ({
3237
3173
  isPoint: classify_isPoint,
3238
3174
  isLineGeneral,
3239
3175
  isLineDegenPoint,
@@ -3250,7 +3186,7 @@ const classification = {
3250
3186
  isCubicDegenCollinearQuad,
3251
3187
  isCubicDegenLine,
3252
3188
  isCubicDegenPoint,
3253
- };
3189
+ }));
3254
3190
  /**
3255
3191
  * Returns a classification of the given bezier curve.
3256
3192
  *
@@ -6454,7 +6390,6 @@ function getRealProngCount(cpNode) {
6454
6390
 
6455
6391
 
6456
6392
 
6457
- const { min, abs: get_speed_abs } = Math;
6458
6393
  const getSpeed$ = memoize(getSpeed);
6459
6394
  function getSpeed(cpNode) {
6460
6395
  if (getRealProngCount(cpNode) !== 2) {
@@ -6820,79 +6755,109 @@ function getBoundaryBezierPartsToNext(cpNode) {
6820
6755
  if (curveThis.loop !== curveNext.loop) {
6821
6756
  // It is a hole-closer going over to the other loop - a kind of terminal
6822
6757
  // CpNode.
6823
- return undefined;
6758
+ // return undefined;
6759
+ return [];
6824
6760
  }
6825
6761
  const bezierPieces = [];
6826
6762
  if (curveNext === curveThis) {
6827
- bezierPieces.push({
6828
- ps: posThis.curve.ps,
6829
- ts: [posThis.t, posNext.t]
6830
- });
6763
+ bezierPieces.push({ ps: posThis.curve.ps, ts: [posThis.t, posNext.t] });
6831
6764
  }
6832
6765
  else {
6833
- bezierPieces.push({
6834
- ps: posThis.curve.ps,
6835
- ts: [posThis.t, 1]
6836
- });
6837
- addSkippedBeziers(bezierPieces, posThis.curve, posNext.curve, posNext.t);
6766
+ bezierPieces.push({ ps: posThis.curve.ps, ts: [posThis.t, 1] });
6767
+ addSkippedBezierPiecess(bezierPieces, posThis.curve, posNext.curve, posNext.t);
6838
6768
  }
6839
6769
  return bezierPieces;
6840
6770
  }
6841
6771
  /**
6842
- * @internal
6843
6772
  * Adds pieces of skipped beziers.
6773
+ * @internal
6844
6774
  */
6845
- function addSkippedBeziers(bezierPieces, curveStart, curveEnd, t1) {
6775
+ function addSkippedBezierPiecess(bezierPieces, curveStart, curveEnd, t1) {
6846
6776
  let curveThis = curveStart;
6847
6777
  do {
6848
6778
  curveThis = curveThis.next;
6849
- const bezierPart = curveThis === curveEnd
6850
- ? { ps: curveThis.ps, ts: [0, t1] }
6851
- : { ps: curveThis.ps, ts: [0, 1] };
6852
- bezierPieces.push(bezierPart);
6779
+ const tEnd = curveThis === curveEnd ? t1 : 1;
6780
+ bezierPieces.push({
6781
+ ps: curveThis.ps, ts: [0, tEnd]
6782
+ });
6853
6783
  } while (curveThis !== curveEnd);
6854
6784
  }
6855
6785
 
6856
6786
 
6857
6787
  ;// ./src/cp-node/fs/get-boundary-beziers-to-next.ts
6858
6788
 
6859
- function getBoundaryBeziersToNext(cpNode) {
6860
- const cpThis = cpNode;
6861
- const cpNext = cpNode.next;
6862
- const posThis = cpThis.cp.pointOnShape;
6863
- const posNext = cpNext.cp.pointOnShape;
6864
- const curveThis = posThis.curve;
6865
- const curveNext = posNext.curve;
6866
- if (curveThis.loop !== curveNext.loop) {
6867
- // It is a hole-closer going over to the other loop - a kind of terminal
6868
- // CpNode.
6869
- // return undefined!;
6870
- return [];
6871
- }
6872
- const beziers = [];
6873
- if (curveNext === curveThis) {
6874
- beziers.push(fromTo(posThis.curve.ps, posThis.t, posNext.t));
6875
- }
6876
- else {
6877
- beziers.push(fromTo(posThis.curve.ps, posThis.t, 1));
6878
- get_boundary_beziers_to_next_addSkippedBeziers(beziers, posThis.curve, posNext.curve, posNext.t);
6879
- }
6880
- return beziers;
6881
- }
6789
+
6882
6790
  /**
6883
- * Adds pieces of skipped beziers.
6884
- * @internal
6885
- */
6886
- function get_boundary_beziers_to_next_addSkippedBeziers(beziers, curveStart, curveEnd, t1) {
6887
- let curveThis = curveStart;
6888
- do {
6889
- curveThis = curveThis.next;
6890
- const tEnd = curveThis === curveEnd ? t1 : 1;
6891
- beziers.push(
6892
- // qqq from0ToT(curveThis.ps, tEnd)
6893
- fromTo(curveThis.ps, 0, tEnd));
6894
- } while (curveThis !== curveEnd);
6791
+ // * Returns the boundary beziers between this `CpNode` and the next
6792
+ // * one.
6793
+ // *
6794
+ // * * returns `[]` if the next `CpNode` is on a different loop,
6795
+ // * as this is a hole-closer and there are no boundary beziers between them.
6796
+ // *
6797
+ // * @param cpNode
6798
+ // */
6799
+ function getBoundaryBeziersToNext(cpNode) {
6800
+ return getBoundaryBezierPartsToNext(cpNode).map(bp => fromTo(bp.ps, bp.ts[0], bp.ts[1]));
6895
6801
  }
6802
+ // /**
6803
+ // * Returns the boundary beziers between this `CpNode` and the next
6804
+ // * one.
6805
+ // *
6806
+ // * * returns `[]` if the next `CpNode` is on a different loop,
6807
+ // * as this is a hole-closer and there are no boundary beziers between them.
6808
+ // *
6809
+ // * @param cpNode
6810
+ // */
6811
+ // function getBoundaryBeziersToNext(
6812
+ // cpNode: CpNode): number[][][] {
6813
+ // const cpThis = cpNode;
6814
+ // const cpNext = cpNode.next;
6815
+ // const posThis = cpThis.cp.pointOnShape;
6816
+ // const posNext = cpNext.cp.pointOnShape;
6817
+ // const curveThis = posThis.curve;
6818
+ // const curveNext = posNext.curve;
6819
+ // if (curveThis.loop !== curveNext.loop) {
6820
+ // // It is a hole-closer going over to the other loop - a kind of terminal
6821
+ // // CpNode.
6822
+ // // return undefined!;
6823
+ // return [];
6824
+ // }
6825
+ // const beziers: number[][][] = [];
6826
+ // if (curveNext === curveThis) {
6827
+ // beziers.push(
6828
+ // fromTo(posThis.curve.ps, posThis.t, posNext.t)
6829
+ // );
6830
+ // } else {
6831
+ // beziers.push(
6832
+ // fromTo(posThis.curve.ps, posThis.t, 1)
6833
+ // );
6834
+ // addSkippedBeziers(
6835
+ // beziers,
6836
+ // posThis.curve,
6837
+ // posNext.curve,
6838
+ // posNext.t
6839
+ // );
6840
+ // }
6841
+ // return beziers;
6842
+ // }
6843
+ // /**
6844
+ // * Adds pieces of skipped beziers.
6845
+ // * @internal
6846
+ // */
6847
+ // function addSkippedBeziers(
6848
+ // beziers: number[][][],
6849
+ // curveStart: Curve,
6850
+ // curveEnd: Curve,
6851
+ // t1: number) {
6852
+ // let curveThis = curveStart;
6853
+ // do {
6854
+ // curveThis = curveThis.next;
6855
+ // const tEnd = curveThis === curveEnd ? t1 : 1;
6856
+ // beziers.push(
6857
+ // fromTo(curveThis.ps, 0, tEnd)
6858
+ // );
6859
+ // } while (curveThis !== curveEnd);
6860
+ // }
6896
6861
 
6897
6862
 
6898
6863
  ;// ./src/cp-node/fs/remove-cp-node.ts
@@ -7039,13 +7004,6 @@ function getBranchBeziers(cpNode) {
7039
7004
  }
7040
7005
 
7041
7006
 
7042
- ;// ./src/cp-node/fs/cp-nodes-to-boundary-beziers.ts
7043
-
7044
- function cpNodesToBoundaryBeziers(cpNodes) {
7045
- return cpNodes.flatMap(getBoundaryBeziersToNext);
7046
- }
7047
-
7048
-
7049
7007
  ;// ./src/cp-node/fs/get-all-between.ts
7050
7008
  /**
7051
7009
  * Returns all `CpNode`s between the two given ones (excluding the last one).
@@ -7093,11 +7051,9 @@ function getAllBetween(cpNodeS, cpNodeE, inclAllIfEqual = true) {
7093
7051
  * include all `CpNode`s around the loop, otherwise include none.
7094
7052
  */
7095
7053
  function getBoundaryBeziersBetween(cpNode1, cpNode2, inclAllIfEqual = true) {
7096
- const allBetween = getAllBetween(cpNode1, cpNode2, inclAllIfEqual);
7097
- return {
7098
- pss: cpNodesToBoundaryBeziers(allBetween.cpNodes),
7099
- hasHoleCloser: allBetween.hasHoleCloser
7100
- };
7054
+ const { cpNodes, hasHoleCloser } = getAllBetween(cpNode1, cpNode2, inclAllIfEqual);
7055
+ const pss = cpNodes.flatMap(getBoundaryBeziersToNext);
7056
+ return { pss, hasHoleCloser };
7101
7057
  }
7102
7058
 
7103
7059
 
@@ -7126,8 +7082,8 @@ function getSalience(cpNode) {
7126
7082
  const bp1 = cpNode1.cp.pointOnShape.p;
7127
7083
  const bp2 = cpNode2.cp.pointOnShape.p;
7128
7084
  const d = distanceBetween(bp1, bp2);
7129
- const { pss: bps, hasHoleCloser } = getBoundaryBeziersBetween(cpNode1, cpNode2);
7130
- const s = sum(bps.map(ps => totalLength(ps)));
7085
+ const { pss, hasHoleCloser } = getBoundaryBeziersBetween(cpNode1, cpNode2);
7086
+ const s = sum(pss.map(ps => totalLength(ps)));
7131
7087
  return hasHoleCloser ? Number.POSITIVE_INFINITY : s / d;
7132
7088
  }
7133
7089
 
@@ -7176,6 +7132,55 @@ function getAllVertices(cpNode) {
7176
7132
  }
7177
7133
 
7178
7134
 
7135
+ ;// ./src/point-on-shape/compare-poss.ts
7136
+ /**
7137
+ * Compares two `PointOnShape`s according to their cyclic ordering imposed
7138
+ * by their relative positions on the shape boundary.
7139
+ * @param a The first `PointOnShape`.
7140
+ * @param b The second `PointOnShape`.
7141
+ * @internal
7142
+ */
7143
+ function comparePoss(a, b) {
7144
+ let res;
7145
+ res = a.curve.idx - b.curve.idx;
7146
+ if (res !== 0) {
7147
+ return res;
7148
+ }
7149
+ res = a.t - b.t;
7150
+ return res;
7151
+ }
7152
+
7153
+
7154
+ ;// ./src/contact-point/contact-point.ts
7155
+
7156
+ /**
7157
+ * Primarily for internal use.
7158
+ *
7159
+ * Compares the two contact points according to their order along the shape
7160
+ * boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
7161
+ * @param a The first contact point.
7162
+ * @param b The second contact point.
7163
+ */
7164
+ function compareCps(a, b) {
7165
+ let res = comparePoss(a.pointOnShape, b.pointOnShape);
7166
+ if (res !== 0) {
7167
+ return res;
7168
+ }
7169
+ res = a.order - b.order;
7170
+ if (res !== 0) {
7171
+ return res;
7172
+ }
7173
+ return a.order2 - b.order2;
7174
+ }
7175
+
7176
+
7177
+ ;// ./src/cp-node/fs/cp-node-comparator.ts
7178
+
7179
+ function cpNodeComparator(a, b) {
7180
+ return compareCps(a.cp, b.cp);
7181
+ }
7182
+
7183
+
7179
7184
  ;// ./src/cp-node/cp-node-fs.ts
7180
7185
 
7181
7186
 
@@ -7212,7 +7217,6 @@ function getAllVertices(cpNode) {
7212
7217
 
7213
7218
 
7214
7219
 
7215
- const cpNodeComparator = (a, b) => compareCps(a.cp, b.cp);
7216
7220
  const CpNodeFs = {
7217
7221
  /**
7218
7222
  * Returns the children of this `CpNode` when seen as a MAT edge. Only
@@ -7312,7 +7316,7 @@ const CpNodeFs = {
7312
7316
  * Compares the order of two `CpNode`s. The order is cyclic and depends
7313
7317
  * on a `CpNode`'s relative position along the shape boundary.
7314
7318
  */
7315
- cpNodeComparator,
7319
+ cpNodeComparator: cpNodeComparator,
7316
7320
  /**
7317
7321
  * For debugging
7318
7322
  * @param cpNode
@@ -8263,7 +8267,7 @@ const all_roots_certified_eEstimate = eEstimate;
8263
8267
  const all_roots_certified_hornerWithRunningError = hornerWithRunningError;
8264
8268
  const all_roots_certified_eSign = eSign;
8265
8269
  const all_roots_certified_max = Math.max;
8266
- const all_roots_certified_min = Math.min;
8270
+ const min = Math.min;
8267
8271
  const all_roots_certified_abs = Math.abs;
8268
8272
  const all_roots_certified_eps = Number.EPSILON;
8269
8273
  const onePlusEps = 1 + all_roots_certified_eps;
@@ -8639,7 +8643,7 @@ function allRootsCertified(p, lb = 0, ub = 1, pE, getPExact, returnUndefinedForZ
8639
8643
  mult *= d * onePlusEps;
8640
8644
  }
8641
8645
  // maxDdP is now calculated
8642
- const AMinMax = A_ > 0 ? all_roots_certified_min(_A, A_) : all_roots_certified_max(_A, A_);
8646
+ const AMinMax = A_ > 0 ? min(_A, A_) : all_roots_certified_max(_A, A_);
8643
8647
  const δ = 2 * Number.EPSILON * all_roots_certified_max(1, all_roots_certified_abs(a_));
8644
8648
  const dMax = maxDdP * (2 * δ); // since the first derivative === 0 somewhere in [_a,a_]
8645
8649
  const yShift = A_ > 0 ? -dMax * 2 * δ : dMax * 2 * δ;
@@ -25567,8 +25571,9 @@ const DualSetFs = { has, add: dual_set_add, remove };
25567
25571
 
25568
25572
  const { isOnSameCircle: cull_isOnSameCircle } = CpNodeFs;
25569
25573
  /**
25574
+ * Returns the set of non-trivial forward edges starting from the given `CpNode`.
25570
25575
  *
25571
- * @param cpStart
25576
+ * @param cpStart the start `CpNode`
25572
25577
  */
25573
25578
  function getNonTrivialForwardEdges(cpStart) {
25574
25579
  let cpNode = cpStart;
@@ -25586,12 +25591,14 @@ function getNonTrivialForwardEdges(cpStart) {
25586
25591
  return cps;
25587
25592
  }
25588
25593
  /**
25589
- * @internal
25590
25594
  * Returns the set of Vertices passing the following test: walk the MAT tree and
25591
25595
  * keep all Vertices not in the current cull set and any Vertices that have a
25592
25596
  * non-culled node further down the line toward the tree leaves.
25593
- * @param culls The CpNodes (referred to by circles) that should be culled.
25594
- * @param maxCpNode The start CpNode which must reprsesent the maximal vertex.
25597
+ *
25598
+ * @param culls the `CpNode`s (referred to by circles) that should be culled
25599
+ * @param maxCpNode the start `CpNode` which must represent the maximal vertex
25600
+ *
25601
+ * @internal
25595
25602
  */
25596
25603
  function cull(culls, maxCpNode) {
25597
25604
  const leaves = getLeaves(maxCpNode);
@@ -25741,8 +25748,9 @@ function getSatCulls(cpNode, s) {
25741
25748
  * boundary of the shape. The SAT is a simplification of the MAT that preserves
25742
25749
  * less detail the higher the applied scale factor. The severity at which noise
25743
25750
  * are removed depends on the local scale of the shape.
25744
- * @param mat The Medial Axis Transform (`Mat`) on which to apply the SAT.
25745
- * @param s The scale factor >= 1 (e.g. 1.3)
25751
+ *
25752
+ * @param mat the Medial Axis Transform (MAT) on which to apply the SAT
25753
+ * @param s the scale factor >= 1 (e.g. 1.3)
25746
25754
  */
25747
25755
  function toScaleAxis(mat, s) {
25748
25756
  let timingStart = 0;
@@ -26254,13 +26262,13 @@ function getPotentialClosestPointsOnCurveCertified(pow, curve, x, tRange = [0, 1
26254
26262
  * Finds an initial distance such that the closest point can not be further than
26255
26263
  * this distance away.
26256
26264
  */
26257
- function getBestDistanceSquared(bezierPieces, p) {
26265
+ function getBestDistanceSquared(curvePieces, p) {
26258
26266
  let bestSquaredDistance = Number.POSITIVE_INFINITY;
26259
- for (let i = 0; i < bezierPieces.length; i++) {
26260
- const bezierPiece = bezierPieces[i];
26261
- const ps = bezierPiece.curve.ps;
26262
- const p1 = evalDeCasteljau(ps, bezierPiece.ts[0]);
26263
- const p2 = evalDeCasteljau(ps, bezierPiece.ts[1]);
26267
+ for (let i = 0; i < curvePieces.length; i++) {
26268
+ const curvePiece = curvePieces[i];
26269
+ const ps = curvePiece.curve.ps;
26270
+ const p1 = evalDeCasteljau(ps, curvePiece.ts[0]);
26271
+ const p2 = evalDeCasteljau(ps, curvePiece.ts[1]);
26264
26272
  const d = Math.min(squaredDistanceBetween(p, p1), squaredDistanceBetween(p, p2));
26265
26273
  if (d < bestSquaredDistance) {
26266
26274
  bestSquaredDistance = d;
@@ -26335,22 +26343,22 @@ const get_bounding_box_getBoundingBox$ = memoize(getBoundingBox);
26335
26343
  * @internal
26336
26344
  * When checking distances, ignore all those with closest possible distance
26337
26345
  * further than 'bestSquaredDistance', i.e. cull them.
26338
- * @param bezierPieces
26346
+ * @param curvePieces
26339
26347
  * @param p
26340
26348
  * @param dSquared
26341
26349
  */
26342
- function cullByLooseBoundingBox(bezierPieces, p, dSquared) {
26343
- const candidateBezierPieces = [];
26344
- for (let i = 0; i < bezierPieces.length; i++) {
26345
- const bezierPiece = bezierPieces[i];
26346
- const ps = bezierPiece.curve.ps;
26350
+ function cullByLooseBoundingBox(curvePieces, p, dSquared) {
26351
+ const candidateCurvePieces = [];
26352
+ for (let i = 0; i < curvePieces.length; i++) {
26353
+ const curvePiece = curvePieces[i];
26354
+ const ps = curvePiece.curve.ps;
26347
26355
  const boundingBox = get_bounding_box_getBoundingBox$(ps);
26348
26356
  const d = getClosestSquareDistanceToRect(boundingBox, p);
26349
26357
  if (d <= dSquared) {
26350
- candidateBezierPieces.push(bezierPiece);
26358
+ candidateCurvePieces.push(curvePiece);
26351
26359
  }
26352
26360
  }
26353
- return candidateBezierPieces;
26361
+ return candidateCurvePieces;
26354
26362
  }
26355
26363
 
26356
26364
 
@@ -26402,22 +26410,22 @@ const getBoundingBoxTight_ = memoize(getBoundingBoxTight);
26402
26410
  * @internal
26403
26411
  * When checking distances, ignore all those with closest possible distance
26404
26412
  * further than 'bestSquaredDistance', i.e. cull them.
26405
- * @param bezierPieces
26413
+ * @param curvePieces
26406
26414
  * @param p
26407
26415
  * @param bestSquaredDistance
26408
26416
  */
26409
- function cullByTightBoundingBox(bezierPieces, p, bestSquaredDistance) {
26410
- const candidateBezierPieces = [];
26411
- for (let i = 0; i < bezierPieces.length; i++) {
26412
- const bezierPiece = bezierPieces[i];
26413
- const ps = bezierPiece.curve.ps;
26417
+ function cullByTightBoundingBox(curvePieces, p, bestSquaredDistance) {
26418
+ const candidateCurvePieces = [];
26419
+ for (let i = 0; i < curvePieces.length; i++) {
26420
+ const curvePiece = curvePieces[i];
26421
+ const ps = curvePiece.curve.ps;
26414
26422
  const tightBoundingBox = getBoundingBoxTight_(ps);
26415
26423
  const d = getClosestSquaredDistanceToRotatedRect(tightBoundingBox, p);
26416
26424
  if (d <= bestSquaredDistance) {
26417
- candidateBezierPieces.push(bezierPiece);
26425
+ candidateCurvePieces.push(curvePiece);
26418
26426
  }
26419
26427
  }
26420
- return candidateBezierPieces;
26428
+ return candidateCurvePieces;
26421
26429
  }
26422
26430
 
26423
26431
 
@@ -26426,16 +26434,17 @@ function cullByTightBoundingBox(bezierPieces, p, bestSquaredDistance) {
26426
26434
 
26427
26435
 
26428
26436
  /**
26429
- * @internal
26430
- * @param bezierPieces
26437
+ * @param curvePieces
26431
26438
  * @param p
26432
26439
  * @param extreme
26440
+ *
26441
+ * @internal
26433
26442
  */
26434
- function cullBezierPieces1(bezierPieces, p) {
26435
- const bestSquaredDistance = getBestDistanceSquared(bezierPieces, p);
26436
- bezierPieces = cullByLooseBoundingBox(bezierPieces, p, bestSquaredDistance);
26437
- bezierPieces = cullByTightBoundingBox(bezierPieces, p, bestSquaredDistance);
26438
- return bezierPieces;
26443
+ function cullCurvePieces1(curvePieces, p) {
26444
+ const bestSquaredDistance = getBestDistanceSquared(curvePieces, p);
26445
+ curvePieces = cullByLooseBoundingBox(curvePieces, p, bestSquaredDistance);
26446
+ curvePieces = cullByTightBoundingBox(curvePieces, p, bestSquaredDistance);
26447
+ return curvePieces;
26439
26448
  }
26440
26449
 
26441
26450
 
@@ -26449,19 +26458,19 @@ function cullBezierPieces1(bezierPieces, p) {
26449
26458
  * bezier pieces, including the beziers actually checked after culling.
26450
26459
  *
26451
26460
  * @param pow
26452
- * @param bezierPieces
26461
+ * @param curvePieces
26453
26462
  * @param x
26454
26463
  * @param touchedCurve
26455
26464
  * @param t
26456
26465
  * @param for1Prong defaults to `false`;
26457
26466
  * @param angle defaults to `0`
26458
26467
  */
26459
- function getCloseBoundaryPointsCertified(pow, bezierPieces, x, touchedCurve = undefined, t = undefined, for1Prong = false, angle = 0) {
26460
- bezierPieces = cullBezierPieces1(bezierPieces, x);
26468
+ function getCloseBoundaryPointsCertified(pow, curvePieces, x, touchedCurve = undefined, t = undefined, for1Prong = false, angle = 0) {
26469
+ curvePieces = cullCurvePieces1(curvePieces, x);
26461
26470
  const pInfoss = [];
26462
- for (let i = 0; i < bezierPieces.length; i++) {
26463
- const bezierPiece = bezierPieces[i];
26464
- const pInfos = getPotentialClosestPointsOnCurveCertified(pow, bezierPiece.curve, x, bezierPiece.ts, touchedCurve, t, for1Prong, angle);
26471
+ for (let i = 0; i < curvePieces.length; i++) {
26472
+ const curvePiece = curvePieces[i];
26473
+ const pInfos = getPotentialClosestPointsOnCurveCertified(pow, curvePiece.curve, x, curvePiece.ts, touchedCurve, t, for1Prong, angle);
26465
26474
  pInfoss.push(...pInfos);
26466
26475
  }
26467
26476
  /** the minimum max interval value */
@@ -26494,14 +26503,14 @@ const { max: calc_initial_3_prong_center_max, ceil, log2 } = Math;
26494
26503
  * must be within the shape.
26495
26504
  * @param δ3s - The three boundary pieces of which we need to find the three
26496
26505
  * 3-prong points.
26497
- * @param bezierPiece3s
26506
+ * @param curvePiece3s
26498
26507
  * @param extreme
26499
26508
  */
26500
- function calcInitial3ProngCenter(maxCoordinate, δ3s, bezierPiece3s) {
26509
+ function calcInitial3ProngCenter(maxCoordinate, δ3s, curvePiece3s) {
26501
26510
  const circle = δ3s[0][0].cp.circle;
26502
26511
  const twoProngCircleCenter = circle.center;
26503
26512
  const pow = calc_initial_3_prong_center_max(0, ceil(log2(maxCoordinate / circle.radius))) + 1; // determines accuracy;
26504
- const pos = getCloseBoundaryPointsCertified(pow, bezierPiece3s[1], twoProngCircleCenter)[0];
26513
+ const pos = getCloseBoundaryPointsCertified(pow, curvePiece3s[1], twoProngCircleCenter)[0];
26505
26514
  const meanPoints = [
26506
26515
  δ3s[0][0].cp.pointOnShape.p,
26507
26516
  pos.p,
@@ -26516,13 +26525,13 @@ function calcInitial3ProngCenter(maxCoordinate, δ3s, bezierPiece3s) {
26516
26525
  /**
26517
26526
  * @internal
26518
26527
  * @param x
26519
- * @param bezierPiece3s
26528
+ * @param curvePiece3s
26520
26529
  * @param extreme
26521
26530
  */
26522
- function getClosestPoints(x, bezierPiece3s) {
26523
- return bezierPiece3s.map(bezierPieces => {
26531
+ function getClosestPoints(x, curvePiece3s) {
26532
+ return curvePiece3s.map(curvePieces => {
26524
26533
  return getCloseBoundaryPointsCertified(5, // TODO - see find-2-prong
26525
- bezierPieces, x)[0];
26534
+ curvePieces, x)[0];
26526
26535
  });
26527
26536
  }
26528
26537
 
@@ -26546,13 +26555,13 @@ function scale(p, c) {
26546
26555
  * Find new x and ps that are a better estimate of the 3-prong circle.
26547
26556
  * The potential function, V, is defined as the distance to the actual 3 prong
26548
26557
  * circle center.
26549
- * @param bezierPiece3s The three boundary pieces, each of which should contain
26558
+ * @param curvePiece3s The three boundary pieces, each of which should contain
26550
26559
  * a point of the 3-prong to be found.
26551
26560
  * @param x The currently best guess at the center of the 3-prong circle.
26552
26561
  * @param vectorToZeroV
26553
26562
  * @param extreme
26554
26563
  */
26555
- function calcBetterX(bezierPiece3s, x, vectorToZeroV) {
26564
+ function calcBetterX(curvePiece3s, x, vectorToZeroV) {
26556
26565
  const V = len(vectorToZeroV);
26557
26566
  let nu = 1;
26558
26567
  let better;
@@ -26563,7 +26572,7 @@ function calcBetterX(bezierPiece3s, x, vectorToZeroV) {
26563
26572
  do {
26564
26573
  const shift = scale(vectorToZeroV, nu);
26565
26574
  newX = translate(shift, x);
26566
- newPoss = getClosestPoints(newX, bezierPiece3s);
26575
+ newPoss = getClosestPoints(newX, curvePiece3s);
26567
26576
  // Point of zero V
26568
26577
  const newCircleCenter = circumCenter(newPoss.map(pos => pos.p));
26569
26578
  const newVectorToZeroV = from_to_fromTo(newX, newCircleCenter);
@@ -26595,11 +26604,11 @@ const calcVectorToZeroV_StraightToIt = from_to_fromTo;
26595
26604
  * Finds a 3-prong using only the 3 given δs.
26596
26605
  * @param δs The boundary pieces
26597
26606
  * @param idx δ identifier
26598
- * @param bezierPiecess
26607
+ * @param curvePiecess
26599
26608
  * @param maxCoordinate The maximum coordinate value used to calculate floating point
26600
26609
  * tolerances.
26601
26610
  */
26602
- function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
26611
+ function find3ProngForDelta3s(δs, idx, k, curvePiecess, maxCoordinate) {
26603
26612
  const TOLERANCE = 2 ** -32 * maxCoordinate;
26604
26613
  const MAX_ITERATIONS = 10;
26605
26614
  const δs_ = [
@@ -26607,34 +26616,34 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
26607
26616
  δs[idx],
26608
26617
  δs[δs.length - 1]
26609
26618
  ];
26610
- const bezierPieces_ = [
26611
- bezierPiecess[0],
26612
- bezierPiecess[idx],
26613
- bezierPiecess[δs.length - 1]
26619
+ const curvePieces_ = [
26620
+ curvePiecess[0],
26621
+ curvePiecess[idx],
26622
+ curvePiecess[δs.length - 1]
26614
26623
  ];
26615
26624
  const δ3ss = [
26616
26625
  [δs_[0], δs_[1], δs_[2]],
26617
26626
  [δs_[1], δs_[2], δs_[0]],
26618
26627
  [δs_[2], δs_[0], δs_[1]],
26619
26628
  ];
26620
- const bezierPiecess_ = [
26621
- [bezierPieces_[0], bezierPieces_[1], bezierPieces_[2]],
26622
- [bezierPieces_[1], bezierPieces_[2], bezierPieces_[0]],
26623
- [bezierPieces_[2], bezierPieces_[0], bezierPieces_[1]],
26629
+ const curvePiecess_ = [
26630
+ [curvePieces_[0], curvePieces_[1], curvePieces_[2]],
26631
+ [curvePieces_[1], curvePieces_[2], curvePieces_[0]],
26632
+ [curvePieces_[2], curvePieces_[0], curvePieces_[1]],
26624
26633
  ];
26625
26634
  const δ3s = δ3ss[k];
26626
- const bezierPiece3s = bezierPiecess_[k];
26635
+ const curvePiece3s = curvePiecess_[k];
26627
26636
  if (find_3_prong_for_delta3s_isSharp(δ3s[0][0])) {
26628
26637
  return undefined;
26629
26638
  }
26630
26639
  let poss = undefined;
26631
26640
  let circumCenter_;
26632
26641
  let j = 0; // Safeguard for slow convergence
26633
- let x = calcInitial3ProngCenter(maxCoordinate, δ3s, bezierPiece3s);
26642
+ let x = calcInitial3ProngCenter(maxCoordinate, δ3s, curvePiece3s);
26634
26643
  let tolerance = Number.POSITIVE_INFINITY;
26635
26644
  while (tolerance > TOLERANCE && j < MAX_ITERATIONS) {
26636
26645
  j++;
26637
- poss = getClosestPoints(x, bezierPiece3s);
26646
+ poss = getClosestPoints(x, curvePiece3s);
26638
26647
  if (!Number.isFinite(x[0]) || !Number.isFinite(x[1])) {
26639
26648
  // TODO - the code can be cleaned up and sped up a lot if we don't
26640
26649
  // use this function as is but instead use δs[0] and δs[2] as is
@@ -26651,7 +26660,7 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
26651
26660
  // loop. This check, for instance, would be eliminated completely.
26652
26661
  return undefined;
26653
26662
  }
26654
- const upds = calcBetterX(bezierPiece3s, x, vectorToZeroV);
26663
+ const upds = calcBetterX(curvePiece3s, x, vectorToZeroV);
26655
26664
  x = upds.newX;
26656
26665
  poss = upds.newPoss;
26657
26666
  const V = len(vectorToZeroV); // The 'potential'
@@ -26712,9 +26721,9 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
26712
26721
  // candidate for the 3-prong.
26713
26722
  //-------------------------------------------------------------------------
26714
26723
  const closestDs = [];
26715
- for (let i = 0; i < bezierPiecess.length; i++) {
26724
+ for (let i = 0; i < curvePiecess.length; i++) {
26716
26725
  const p = getCloseBoundaryPointsCertified(5, // TODO - see find-2-prong
26717
- bezierPiecess[i], x)[0];
26726
+ curvePiecess[i], x)[0];
26718
26727
  closestDs.push(distanceBetween(p.p, x));
26719
26728
  }
26720
26729
  const closestD = Math.min(...closestDs);
@@ -26756,7 +26765,7 @@ const isPosQuiteSharpCorner = memoize((pos) => {
26756
26765
  function getBoundaryPieceBeziers(cpNodes) {
26757
26766
  let cpThis = cpNodes[0];
26758
26767
  const cpEnd = cpNodes[1];
26759
- const bezierPieces = [];
26768
+ const curvePieces = [];
26760
26769
  // As opposed to going around the circle and taking the last exit
26761
26770
  let goStraight = true;
26762
26771
  do {
@@ -26775,28 +26784,28 @@ function getBoundaryPieceBeziers(cpNodes) {
26775
26784
  }
26776
26785
  else if (posNext.curve === posThis.curve &&
26777
26786
  compareCps(cpThis.next.cp, cpThis.cp) > 0) {
26778
- bezierPieces.push({ curve: posThis.curve, ts: [posThis.t, posNext.t] });
26787
+ curvePieces.push({ curve: posThis.curve, ts: [posThis.t, posNext.t] });
26779
26788
  }
26780
26789
  else {
26781
- bezierPieces.push({ curve: posThis.curve, ts: [posThis.t, 1] });
26790
+ curvePieces.push({ curve: posThis.curve, ts: [posThis.t, 1] });
26782
26791
  if (posThis.curve.loop === posNext.curve.loop) {
26783
- get_boundary_piece_beziers_addSkippedBeziers(bezierPieces, posThis.curve, posNext.curve, posNext.t);
26792
+ addSkippedBeziers(curvePieces, posThis.curve, posNext.curve, posNext.t);
26784
26793
  }
26785
26794
  }
26786
26795
  cpThis = cpThis.next;
26787
26796
  } while (cpThis !== cpEnd);
26788
- return bezierPieces;
26797
+ return curvePieces;
26789
26798
  }
26790
26799
  /**
26791
26800
  * @internal
26792
26801
  * Adds pieces of skipped beziers
26793
26802
  */
26794
- function get_boundary_piece_beziers_addSkippedBeziers(bezierPieces, curveStart, curveEnd, t1) {
26803
+ function addSkippedBeziers(curvePieces, curveStart, curveEnd, t1) {
26795
26804
  let curveThis = curveStart;
26796
26805
  do {
26797
26806
  curveThis = curveThis.next;
26798
26807
  const tEnd = curveThis === curveEnd ? t1 : 1;
26799
- bezierPieces.push({ curve: curveThis, ts: [0, tEnd] });
26808
+ curvePieces.push({ curve: curveThis, ts: [0, tEnd] });
26800
26809
  } while (curveThis !== curveEnd);
26801
26810
  }
26802
26811
 
@@ -26812,13 +26821,13 @@ function get_boundary_piece_beziers_addSkippedBeziers(bezierPieces, curveStart,
26812
26821
  * tolerances.
26813
26822
  */
26814
26823
  function find3Prong(δs, extreme) {
26815
- const bezierPiecess = δs.map(getBoundaryPieceBeziers);
26824
+ const curvePiecess = δs.map(getBoundaryPieceBeziers);
26816
26825
  // The best candidate amongst the different 'permutations' of the given δs.
26817
26826
  let threeProng;
26818
26827
  let smallestError = Number.POSITIVE_INFINITY;
26819
26828
  for (let i = 1; i < δs.length - 1; i++) {
26820
26829
  for (let k = 0; k < 3; k++) {
26821
- const threeProngInfo = find3ProngForDelta3s(δs, i, k, bezierPiecess, extreme);
26830
+ const threeProngInfo = find3ProngForDelta3s(δs, i, k, curvePiecess, extreme);
26822
26831
  if (!threeProngInfo) {
26823
26832
  continue;
26824
26833
  }
@@ -27801,7 +27810,7 @@ function findEquidistantPointOnLineDd(x, y, z) {
27801
27810
 
27802
27811
 
27803
27812
  /** @internal */
27804
- function getInitialBezierPieces(angle, isHoleClosing, loop, loops,
27813
+ function getInitialCurvePieces(angle, isHoleClosing, loop, loops,
27805
27814
  // cpTrees: Map<Loop,LlRbTree<CpNode>>,
27806
27815
  meta, y, circle) {
27807
27816
  const { cpTrees } = meta;
@@ -27838,16 +27847,16 @@ meta, y, circle) {
27838
27847
  *
27839
27848
  * Reduces the circle radius initially as an optimization step.
27840
27849
  */
27841
- function reduceRadius(extreme, bezierPieces, p, x) {
27850
+ function reduceRadius(extreme, curvePieces, p, x) {
27842
27851
  const TOLERANCE = 1 + 2 ** -10;
27843
27852
  let minRadius = Number.POSITIVE_INFINITY;
27844
- for (let i = 0; i < bezierPieces.length; i++) {
27845
- const bezierPiece = bezierPieces[i];
27846
- const ps = bezierPiece.curve.ps;
27853
+ for (let i = 0; i < curvePieces.length; i++) {
27854
+ const curvePiece = curvePieces[i];
27855
+ const ps = curvePiece.curve.ps;
27847
27856
  // let min = Number.POSITIVE_INFINITY;
27848
27857
  const num = 2;
27849
27858
  for (let j = 0; j < (num + 1); j++) {
27850
- const p_ = evalDeCasteljau(ps, bezierPiece.ts[j / num]);
27859
+ const p_ = evalDeCasteljau(ps, curvePiece.ts[j / num]);
27851
27860
  const cc = getCircleCenterFrom2PointsAndNormal(extreme, p, x, p_);
27852
27861
  if (cc) {
27853
27862
  let r = squaredDistanceBetween(p, cc);
@@ -27917,24 +27926,24 @@ function squaredDistanceBetweenDd(x, y) {
27917
27926
 
27918
27927
  /**
27919
27928
  * @internal
27920
- * Cull all bezierPieces not within given radius of a given point.
27929
+ * Cull all curvePieces not within given radius of a given point.
27921
27930
  * @param extreme
27922
- * @param bezierPieces
27931
+ * @param curvePieces
27923
27932
  * @param p
27924
27933
  * @param rSquared
27925
27934
  */
27926
- function cullBezierPieces2(bezierPieces, p, rSquared) {
27935
+ function cullCurvePieces2(curvePieces, p, rSquared) {
27927
27936
  const TOLERANCE = 1 + 2 ** -10;
27928
- if (bezierPieces.length <= 1) {
27929
- return bezierPieces;
27937
+ if (curvePieces.length <= 1) {
27938
+ return curvePieces;
27930
27939
  }
27931
27940
  const newPieces = [];
27932
- for (const bezierPiece of bezierPieces) {
27933
- const ps = bezierPiece.curve.ps;
27941
+ for (const curvePiece of curvePieces) {
27942
+ const ps = curvePiece.curve.ps;
27934
27943
  const rect = get_bounding_box_getBoundingBox$(ps);
27935
27944
  const bd = getClosestSquareDistanceToRect(rect, p);
27936
27945
  if (bd <= TOLERANCE * rSquared) {
27937
- newPieces.push(bezierPiece);
27946
+ newPieces.push(curvePiece);
27938
27947
  }
27939
27948
  }
27940
27949
  return newPieces;
@@ -28138,12 +28147,12 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
28138
28147
  const p = y.p;
28139
28148
  // The boundary piece that should contain the other point of
28140
28149
  // the 2-prong circle. (Defined by start and end points).
28141
- let bezierPieces = getInitialBezierPieces(angle, isHoleClosing, loop, loops, meta, y, { center: xO, radius: rO });
28142
- // console.log(bezierPieces.length);
28150
+ let curvePieces = getInitialCurvePieces(angle, isHoleClosing, loop, loops, meta, y, { center: xO, radius: rO });
28151
+ // console.log(curvePieces.length);
28143
28152
  /** The center of the two-prong (successively refined) */
28144
28153
  let x = xO;
28145
28154
  // The lines below is an optimization.
28146
- const r_ = find_2_prong_sqrt(reduceRadius(maxCoordinate, bezierPieces, p, xO));
28155
+ const r_ = find_2_prong_sqrt(reduceRadius(maxCoordinate, curvePieces, p, xO));
28147
28156
  if (rO > r_) {
28148
28157
  x = interpolate(p, xO, r_ / rO);
28149
28158
  }
@@ -28154,11 +28163,11 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
28154
28163
  while (i < MAX_ITERATIONS) {
28155
28164
  const xy = squaredDistanceBetweenDd(x, y.p);
28156
28165
  if (i < 2) {
28157
- bezierPieces = cullBezierPieces2(bezierPieces, x, xy);
28166
+ curvePieces = cullCurvePieces2(curvePieces, x, xy);
28158
28167
  }
28159
28168
  const pow = find_2_prong_max(0, find_2_prong_ceil(find_2_prong_log2(maxCoordinate / xy))) + 1; // determines accuracy
28160
28169
  // console.log(pow);
28161
- const _zs = getCloseBoundaryPointsCertified(pow, bezierPieces, x, y.curve, y.t, for1Prong && i == 0 && rO !== 1 / minCurvature, angle).map(info => createPos(info.curve, info.t, false));
28170
+ const _zs = getCloseBoundaryPointsCertified(pow, curvePieces, x, y.curve, y.t, for1Prong && i == 0 && rO !== 1 / minCurvature, angle).map(info => createPos(info.curve, info.t, false));
28162
28171
  let maxD = Number.NEGATIVE_INFINITY;
28163
28172
  let maxPos = undefined;
28164
28173
  zs = [];
@@ -28216,7 +28225,7 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
28216
28225
  }
28217
28226
  }
28218
28227
  const circle = { center: x, radius: distanceBetween(x, z.p) };
28219
- // if (typeof _debug_ !== 'undefined') { addDebugInfo(bezierPieces, false, x, y, z, circle!, δ!, xs, isHoleClosing); }
28228
+ // if (typeof _debug_ !== 'undefined') { addDebugInfo(curvePieces, false, x, y, z, circle!, δ!, xs, isHoleClosing); }
28220
28229
  // return { circle, zs };
28221
28230
  // zs = zs.filter(z => z !== undefined)
28222
28231
  return { circle, zs: [z] };
@@ -30258,7 +30267,7 @@ function drawCpNode(g, cpNode, classes = 'blue thin2 nofill', delay = 0, scaleFa
30258
30267
  }
30259
30268
  const $cross = crossHair(g, c, 'orange thin10 nofill', 2 * scaleFactor, delay);
30260
30269
  // if (r === 0) {
30261
- // const $cross = crossHair(g, circle.center, 'red thin2 nofill', 0.02*scaleFactor, delay);
30270
+ // const $cross = crossHair(g, circle.center, 'red thin2 nofill', 0.02*scaleFactor, delay);
30262
30271
  // }
30263
30272
  return [...$cps, ...$ls, ...$circle, ...$cross];
30264
30273
  }
@@ -30721,6 +30730,41 @@ function holeCloserNext(pairs, holeCloser) {
30721
30730
 
30722
30731
 
30723
30732
 
30733
+
30734
+
30735
+
30736
+
30737
+
30738
+
30739
+
30740
+
30741
+
30742
+
30743
+
30744
+
30745
+
30746
+
30747
+ // CpNodeFs functions
30748
+
30749
+
30750
+
30751
+
30752
+
30753
+
30754
+
30755
+
30756
+
30757
+
30758
+
30759
+
30760
+
30761
+
30762
+
30763
+
30764
+
30765
+
30766
+
30767
+
30724
30768
 
30725
30769
 
30726
30770
 
@@ -30737,4 +30781,4 @@ function holeCloserNext(pairs, holeCloser) {
30737
30781
 
30738
30782
 
30739
30783
 
30740
- export { CpNodeFs, beziersToSvgPathStr, connectHoleClosers, createInitialCpTree, createPos, debugElemNames, drawBeziersAsSinglePath, drawBranch, drawElemFs, drawElemFsDetailed, drawMat, emptyDebugElems, enableDebugForMat, find2Prong, findAndAdd2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranches, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getFor2ProngsOnLoop, getGraph, getImpliedBoundaryBezierBetween, getPartialMeta, getPathsFromStr, getPointToCpNode, getPotentialClosestPointsOnCurveCertified, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, isVertexSpecial, loopFromBeziers, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, trimMat };
30784
+ export { CpNodeFs, beziersToSvgPathStr, clone, connectHoleClosers, cpNodeComparator, createInitialCpTree, createPos, debugElemNames, drawBeziersAsSinglePath, drawBranch, drawElemFs, drawElemFsDetailed, drawMat, emptyDebugElems, enableDebugForMat, enhanceCpNode, find2Prong, findAndAdd2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, getAllOnCircle, getAllOnLoop, getAllVertices, getBoundaryBezierPartsToNext, getBoundaryBeziersBetween, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranch, getBranchBeziers, getBranches, getChildren, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getEdgeDirection, getFirstExit, getFor2ProngsOnLoop, getGraph, getHoleClosers, getImpliedBoundaryBezierBetween, getInitialDegAngleBetweenMatCurves, getMatCurveBetween, getMatCurveToNext, getMatCurvesBetween, getPartialMeta, getPathsFromStr, getPointToCpNode, getPotentialClosestPointsOnCurveCertified, getProngCount, getRealProngCount, getSalience, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, getSmoothedSpeed$, getSpeed, getVertexForwardChildren, isFullyTerminating, isOnSameCircle, isOneProng, isSharp, isTerminating, isTwoProng, isVertexSpecial, loopFromBeziers, removeVertex, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, traverseCp, traverseEdges, traverseVertices, trimMat };