flo-mat 2.0.1 → 2.0.3
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.
- package/.eslintrc.cjs +69 -0
- package/README.md +9 -27
- package/browser/index.js +29604 -7008
- package/browser/index.min.js +1 -2
- package/node/circle.d.ts +20 -20
- package/node/circle.js +31 -31
- package/node/circle.js.map +1 -1
- package/node/compare-curvatures-at-interface.d.ts +19 -19
- package/node/compare-curvatures-at-interface.js +124 -124
- package/node/compare-curvatures-at-interface.js.map +1 -1
- package/node/contact-point.d.ts +26 -26
- package/node/contact-point.js +25 -25
- package/node/cp-node/clone.d.ts +8 -8
- package/node/cp-node/clone.js +31 -31
- package/node/cp-node/clone.js.map +1 -1
- package/node/cp-node/remove.d.ts +9 -9
- package/node/cp-node/remove.js +19 -19
- package/node/cp-node/remove.js.map +1 -1
- package/node/cp-node.d.ts +202 -202
- package/node/cp-node.js +320 -320
- package/node/cp-node.js.map +1 -1
- package/node/curve.d.ts +46 -46
- package/node/curve.js +88 -88
- package/node/curve.js.map +1 -1
- package/node/debug/cp-node-for-debugging.d.ts +11 -11
- package/node/debug/cp-node-for-debugging.js +1 -1
- package/node/debug/debug-elem-types.d.ts +32 -32
- package/node/debug/debug-elem-types.js +1 -1
- package/node/debug/debug.d.ts +50 -50
- package/node/debug/debug.js +75 -75
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/branch.d.ts +4 -4
- package/node/debug/functions/draw-elem/branch.js +22 -22
- package/node/debug/functions/draw-elem/branch.js.map +1 -1
- package/node/debug/functions/draw-elem/culls.d.ts +4 -4
- package/node/debug/functions/draw-elem/culls.js +21 -21
- package/node/debug/functions/draw-elem/culls.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
- package/node/debug/functions/draw-elem/draw-elem.js +45 -45
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/dull-corner.js +10 -10
- package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
- package/node/debug/functions/draw-elem/leaves.js +12 -12
- package/node/debug/functions/draw-elem/leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/loop.d.ts +4 -4
- package/node/debug/functions/draw-elem/loop.js +11 -11
- package/node/debug/functions/draw-elem/loops.d.ts +4 -4
- package/node/debug/functions/draw-elem/loops.js +6 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
- package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/mat.d.ts +4 -4
- package/node/debug/functions/draw-elem/mat.js +30 -30
- package/node/debug/functions/draw-elem/mat.js.map +1 -1
- package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/max-vertex.js +8 -8
- package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
- package/node/debug/functions/draw-elem/min-y.js +13 -13
- package/node/debug/functions/draw-elem/min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong.js +16 -16
- package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
- package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/three-prong.js +16 -16
- package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
- package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/two-prong.js +36 -36
- package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/vertex.js +27 -27
- package/node/debug/functions/draw-elem/vertex.js.map +1 -1
- package/node/debug/functions/general.d.ts +48 -48
- package/node/debug/functions/general.js +52 -52
- package/node/debug/functions/general.js.map +1 -1
- package/node/debug/functions/three-prong.d.ts +11 -11
- package/node/debug/functions/three-prong.js +184 -184
- package/node/debug/functions/three-prong.js.map +1 -1
- package/node/debug/functions/two-prong.d.ts +13 -13
- package/node/debug/functions/two-prong.js +117 -117
- package/node/debug/functions/two-prong.js.map +1 -1
- package/node/debug/three-prong-for-debugging.d.ts +31 -31
- package/node/debug/three-prong-for-debugging.js +20 -20
- package/node/debug/two-prong-for-debugging.d.ts +26 -26
- package/node/debug/two-prong-for-debugging.js +1 -1
- package/node/find-mats.d.ts +26 -26
- package/node/find-mats.js +122 -125
- package/node/find-mats.js.map +1 -1
- package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
- package/node/get-boundary-bezier-parts-to-next.js +42 -42
- package/node/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/get-boundary-beziers-to-next.d.ts +8 -8
- package/node/get-boundary-beziers-to-next.js +44 -44
- package/node/get-boundary-beziers-to-next.js.map +1 -1
- package/node/get-bounding-box-.d.ts +2 -2
- package/node/get-bounding-box-.js +4 -4
- package/node/get-branches.d.ts +12 -12
- package/node/get-branches.js +68 -68
- package/node/get-branches.js.map +1 -1
- package/node/get-curve/get-curve-between.d.ts +9 -9
- package/node/get-curve/get-curve-between.js +56 -56
- package/node/get-curve/get-curve-between.js.map +1 -1
- package/node/get-curve/get-edge-direction.d.ts +9 -9
- package/node/get-curve/get-edge-direction.js +53 -53
- package/node/get-curve/get-edge-direction.js.map +1 -1
- package/node/get-curve-to-next.d.ts +9 -9
- package/node/get-curve-to-next.js +11 -11
- package/node/get-interface-ccw.d.ts +24 -24
- package/node/get-interface-ccw.js +97 -97
- package/node/get-interface-ccw.js.map +1 -1
- package/node/index.d.ts +36 -36
- package/node/index.js +32 -32
- package/node/loop/get-max-coordinate.d.ts +10 -10
- package/node/loop/get-max-coordinate.js +43 -43
- package/node/loop/get-max-coordinate.js.map +1 -1
- package/node/loop.d.ts +16 -16
- package/node/loop.js +34 -34
- package/node/loop.js.map +1 -1
- package/node/mat/add-to-cp-graph.d.ts +16 -16
- package/node/mat/add-to-cp-graph.js +30 -30
- package/node/mat/add-to-cp-graph.js.map +1 -1
- package/node/mat/bezier-piece.d.ts +12 -12
- package/node/mat/bezier-piece.js +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -73
- package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
- package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
- package/node/mat/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
- package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +1 -1
- package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
- package/node/mat/corner.d.ts +37 -37
- package/node/mat/corner.js +1 -1
- package/node/mat/create-new-cp-tree.d.ts +9 -9
- package/node/mat/create-new-cp-tree.js +23 -23
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/elem-type-two-prong.d.ts +3 -3
- package/node/mat/elem-type-two-prong.js +1 -1
- package/node/mat/find-mat/add-1-prong.d.ts +12 -12
- package/node/mat/find-mat/add-1-prong.js +42 -42
- package/node/mat/find-mat/add-1-prong.js.map +1 -1
- package/node/mat/find-mat/add-2-prong.d.ts +21 -21
- package/node/mat/find-mat/add-2-prong.js +192 -192
- package/node/mat/find-mat/add-2-prong.js.map +1 -1
- package/node/mat/find-mat/add-3-prong.d.ts +19 -19
- package/node/mat/find-mat/add-3-prong.js +54 -54
- package/node/mat/find-mat/add-3-prong.js.map +1 -1
- package/node/mat/find-mat/add-debug-info.d.ts +9 -9
- package/node/mat/find-mat/add-debug-info.js +67 -69
- package/node/mat/find-mat/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +1 -1
- package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
- package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
- package/node/mat/find-mat/create-initial-cp-graph.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
- package/node/mat/find-mat/find-2-prong/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
- package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
- package/node/mat/find-mat/find-3-prong/calc-better-x.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
- package/node/mat/find-mat/find-3-prong/find-3-prong.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
- package/node/mat/find-mat/find-3-prong/get-closest-points.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs.js +73 -74
- package/node/mat/find-mat/find-and-add-2-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
- package/node/mat/find-mat/find-and-add-3-prongs.js +146 -147
- package/node/mat/find-mat/find-and-add-3-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
- package/node/mat/find-mat/get-potential-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
- package/node/mat/find-mat/get-sharp-corners.js +17 -17
- package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
- package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
- package/node/mat/get-boundary-piece-beziers.js +58 -58
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
- package/node/mat/get-contact-circles-at-interface.js +20 -20
- package/node/mat/get-contact-circles-at-interface.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +4 -4
- package/node/mat/get-largest-vertex.js +9 -9
- package/node/mat/get-leaves.d.ts +4 -4
- package/node/mat/get-leaves.js +12 -12
- package/node/mat/get-leaves.js.map +1 -1
- package/node/mat/get-neighboring-cps.d.ts +14 -14
- package/node/mat/get-neighboring-cps.js +30 -30
- package/node/mat/get-neighboring-cps.js.map +1 -1
- package/node/mat/get-two-prong-type.d.ts +5 -5
- package/node/mat/get-two-prong-type.js +8 -8
- package/node/mat/is-another-cp-closeby.d.ts +20 -20
- package/node/mat/is-another-cp-closeby.js +55 -55
- package/node/mat/is-another-cp-closeby.js.map +1 -1
- package/node/mat/simplify-mat-map-only.d.ts +23 -23
- package/node/mat/simplify-mat-map-only.js +80 -80
- package/node/mat/simplify-mat-map-only.js.map +1 -1
- package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
- package/node/mat/to-scale-axis/add-debug-info.js +13 -13
- package/node/mat/to-scale-axis/add-debug-info.js.map +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
- package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
- package/node/mat/to-scale-axis/cull-non-cycles.js.map +1 -1
- package/node/mat/to-scale-axis/cull.d.ts +12 -12
- package/node/mat/to-scale-axis/cull.js +132 -132
- package/node/mat/to-scale-axis/cull.js.map +1 -1
- package/node/mat/trim-mat.d.ts +8 -8
- package/node/mat/trim-mat.js +16 -16
- package/node/mat/trim-mat.js.map +1 -1
- package/node/mat.d.ts +22 -22
- package/node/mat.js +1 -1
- package/node/point-on-shape.d.ts +73 -73
- package/node/point-on-shape.js +167 -167
- package/node/point-on-shape.js.map +1 -1
- package/node/simplify-mat.d.ts +16 -16
- package/node/simplify-mat.js +71 -71
- package/node/simplify-mat.js.map +1 -1
- package/node/svg/get-loop-bounds.d.ts +12 -12
- package/node/svg/get-loop-bounds.js +80 -80
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.d.ts +8 -8
- package/node/svg/get-min-y-pos.js +9 -9
- package/node/svg/get-shape-bounds.d.ts +9 -9
- package/node/svg/get-shape-bounds.js +35 -35
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.d.ts +18 -18
- package/node/sweep-line/sweep-line.js +72 -72
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/to-scale-axis.d.ts +16 -16
- package/node/to-scale-axis.js +74 -73
- package/node/to-scale-axis.js.map +1 -1
- package/node/traverse-edges.d.ts +10 -10
- package/node/traverse-edges.js +21 -21
- package/node/traverse-edges.js.map +1 -1
- package/node/traverse-vertices.d.ts +12 -12
- package/node/traverse-vertices.js +27 -27
- package/node/traverse-vertices.js.map +1 -1
- package/package.json +29 -24
- package/src/circle.ts +3 -3
- package/src/compare-curvatures-at-interface.ts +36 -36
- package/src/cp-node/clone.ts +6 -6
- package/src/cp-node/remove.ts +4 -4
- package/src/cp-node.ts +20 -20
- package/src/curve.ts +19 -19
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/branch.ts +4 -4
- package/src/debug/functions/draw-elem/culls.ts +4 -4
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +2 -2
- package/src/debug/functions/draw-elem/draw-elem.ts +1 -1
- package/src/debug/functions/draw-elem/dull-corner.ts +3 -3
- package/src/debug/functions/draw-elem/leaves.ts +4 -4
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +2 -2
- package/src/debug/functions/draw-elem/mat.ts +4 -4
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +3 -3
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +4 -4
- package/src/debug/functions/draw-elem/one-prong.ts +4 -4
- package/src/debug/functions/draw-elem/sharp-corner.ts +2 -2
- package/src/debug/functions/draw-elem/three-prong.ts +7 -7
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +1 -1
- package/src/debug/functions/draw-elem/two-prong.ts +1 -1
- package/src/debug/functions/draw-elem/vertex.ts +20 -14
- package/src/debug/functions/general.ts +3 -3
- package/src/debug/functions/three-prong.ts +37 -37
- package/src/debug/functions/two-prong.ts +15 -15
- package/src/find-mats.ts +19 -19
- package/src/get-boundary-bezier-parts-to-next.ts +8 -8
- package/src/get-boundary-beziers-to-next.ts +8 -8
- package/src/get-branches.ts +7 -7
- package/src/get-curve/get-curve-between.ts +21 -21
- package/src/get-curve/get-edge-direction.ts +13 -14
- package/src/get-interface-ccw.ts +12 -12
- package/src/loop/get-max-coordinate.ts +7 -7
- package/src/loop.ts +4 -4
- package/src/mat/add-to-cp-graph.ts +8 -8
- package/src/mat/closest-boundary-point/closest-points-on-curve.ts +5 -6
- package/src/mat/closest-boundary-point/cull-bezier-pieces.ts +1 -1
- package/src/mat/closest-boundary-point/cull-by-loose-bounding-box.ts +5 -5
- package/src/mat/closest-boundary-point/cull-by-tight-boundary-box.ts +5 -5
- package/src/mat/closest-boundary-point/get-best-distance-squared.ts +5 -5
- package/src/mat/closest-boundary-point/get-close-boundary-points.ts +15 -15
- package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +4 -4
- package/src/mat/cmp-cp-on-delta.ts +5 -5
- package/src/mat/create-new-cp-tree.ts +3 -3
- package/src/mat/find-mat/add-1-prong.ts +5 -5
- package/src/mat/find-mat/add-2-prong.ts +42 -42
- package/src/mat/find-mat/add-3-prong.ts +1 -1
- package/src/mat/find-mat/add-debug-info.ts +18 -20
- package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +4 -4
- package/src/mat/find-mat/create-initial-cp-graph.ts +11 -11
- package/src/mat/find-mat/find-2-prong/add-debug-info.ts +4 -4
- package/src/mat/find-mat/find-2-prong/cull-bezier-pieces.ts +5 -5
- package/src/mat/find-mat/find-2-prong/find-2-prong.ts +27 -27
- package/src/mat/find-mat/find-2-prong/find-equidistant-point-on-line.ts +7 -7
- package/src/mat/find-mat/find-2-prong/get-initial-bezier-pieces.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-better-x.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-initial-3-prong-center.ts +3 -3
- package/src/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.ts +37 -37
- package/src/mat/find-mat/find-3-prong/find-3-prong.ts +16 -16
- package/src/mat/find-mat/find-3-prong/get-closest-points.ts +1 -1
- package/src/mat/find-mat/find-and-add-2-prongs-on-all-paths.ts +2 -2
- package/src/mat/find-mat/find-and-add-2-prongs.ts +14 -16
- package/src/mat/find-mat/find-and-add-3-prongs.ts +19 -19
- package/src/mat/find-mat/find-and-add-hole-closing-2-prongs.ts +6 -6
- package/src/mat/find-mat/get-potential-2-prongs.ts +4 -4
- package/src/mat/find-mat/get-sharp-corners.ts +4 -4
- package/src/mat/find-mat/get-total-abs-curvature.ts +1 -1
- package/src/mat/geometry/get-closest-squared-distance-to-rotated-rect.ts +3 -3
- package/src/mat/get-boundary-piece-beziers.ts +5 -5
- package/src/mat/get-contact-circles-at-interface.ts +1 -1
- package/src/mat/get-edges-as-array.ts +2 -2
- package/src/mat/get-leaves.ts +2 -2
- package/src/mat/get-neighboring-cps.ts +1 -1
- package/src/mat/is-another-cp-closeby.ts +9 -9
- package/src/mat/simplify-mat-map-only.ts +15 -15
- package/src/mat/to-scale-axis/add-debug-info.ts +6 -3
- package/src/mat/to-scale-axis/add-to-tree.ts +10 -10
- package/src/mat/to-scale-axis/calc-groups.ts +19 -19
- package/src/mat/to-scale-axis/create-spacial-tree.ts +4 -4
- package/src/mat/to-scale-axis/cull-non-cycles.ts +5 -5
- package/src/mat/to-scale-axis/cull.ts +5 -5
- package/src/mat/to-scale-axis/get-engulfed-vertices.ts +18 -18
- package/src/mat/trim-mat.ts +1 -1
- package/src/point-on-shape.ts +16 -16
- package/src/simplify-mat.ts +10 -10
- package/src/svg/get-curvature-at-interface.ts +6 -8
- package/src/svg/get-extreme.ts +1 -1
- package/src/svg/get-loop-bounds.ts +13 -13
- package/src/svg/get-shape-bounds.ts +4 -4
- package/src/sweep-line/are-boxes-intersecting.ts +4 -4
- package/src/sweep-line/sweep-line.ts +8 -8
- package/src/to-scale-axis.ts +18 -17
- package/src/traverse-edges.ts +2 -2
- package/src/traverse-vertices.ts +2 -2
- package/tsconfig.json +0 -1
- package/webpack.config.cjs +12 -63
- package/browser/index.min.js.LICENSE.txt +0 -2819
- package/browser/index.module.js +0 -7149
- package/browser/index.module.min.js +0 -2
- package/browser/index.module.min.js.LICENSE.txt +0 -2819
|
@@ -5,7 +5,7 @@ import { getTwoProngType } from '../../../mat/get-two-prong-type.js';
|
|
|
5
5
|
|
|
6
6
|
/** @hidden */
|
|
7
7
|
function twoProng(g: SVGGElement, twoProng: TwoProngForDebugging) {
|
|
8
|
-
|
|
8
|
+
const scaleFactor = 0.3;
|
|
9
9
|
|
|
10
10
|
let $failedDot : SVGElement[] = [];
|
|
11
11
|
let $center : SVGElement[] = [];
|
|
@@ -3,36 +3,42 @@ import { CpNode } from '../../../cp-node.js';
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/** @hidden */
|
|
6
|
-
function vertex(
|
|
7
|
-
|
|
6
|
+
function vertex(
|
|
7
|
+
g: SVGGElement,
|
|
8
|
+
cpNode: CpNode,
|
|
9
|
+
classes?: string,
|
|
10
|
+
delay?: number,
|
|
11
|
+
visible = true) {
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
const visibleClass = visible ? '' : ' invisible';
|
|
14
|
+
|
|
15
|
+
const circle = cpNode.cp.circle;
|
|
10
16
|
|
|
11
17
|
const THIN = 'thin20';
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
const cps = cpNode.getCpNodesOnCircle();
|
|
14
20
|
console.log(cps)
|
|
15
21
|
|
|
16
22
|
let $svgs: SVGElement[] = [];
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const $circle = drawFs.circle(g, circle, 'red ' + THIN + ' nofill ' + visibleClass, delay);
|
|
25
|
+
const $crossHair = drawFs.crossHair(g, circle.center, 'red ' + THIN + ' nofill ' + visibleClass, 3, delay);
|
|
20
26
|
|
|
21
27
|
$svgs = [...$circle, ...$crossHair];
|
|
22
28
|
|
|
23
29
|
for (let i=0; i<cps.length; i++) {
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
const cp = cps[i];
|
|
31
|
+
const edgeCircle = cp.next.cp.circle;
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
const $circle = drawFs.circle(g, edgeCircle, 'pink ' + THIN + ' nofill ' + visibleClass, delay);
|
|
34
|
+
const $crossHair = drawFs.crossHair(g, edgeCircle.center, 'pink ' + THIN + ' nofill ' + visibleClass, 3, delay);
|
|
29
35
|
|
|
30
36
|
$svgs.push(...$circle, ...$crossHair)
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
const p1 = circle.center;
|
|
39
|
+
const p2 = edgeCircle.center;
|
|
40
|
+
const thin = i === 0 ? 'thin10' : (i === 1 ? 'thin20' : 'thin35');
|
|
41
|
+
const $line = drawFs.line(g, [p1, p2], 'yellow ' + thin + ' nofill ' + visibleClass, delay);
|
|
36
42
|
|
|
37
43
|
$svgs.push(...$line);
|
|
38
44
|
}
|
|
@@ -18,7 +18,7 @@ let i = 0;
|
|
|
18
18
|
* @hidden
|
|
19
19
|
* Name the given object - for debugging purposes only
|
|
20
20
|
*/
|
|
21
|
-
function nameObj(o: any, pre
|
|
21
|
+
function nameObj(o: any, pre = '') {
|
|
22
22
|
o.name = '' + pre + i++;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -61,13 +61,13 @@ function pointsToStr(ps: number[][], decimalPlaces = 3) {
|
|
|
61
61
|
* @param p The point
|
|
62
62
|
* @param decimalPlaces number of decimal places
|
|
63
63
|
*/
|
|
64
|
-
function pointToStr(p: number[], decimalPlaces
|
|
64
|
+
function pointToStr(p: number[], decimalPlaces = 3) {
|
|
65
65
|
return p[0].toFixed(decimalPlaces) + ', ' + p[1].toFixed(decimalPlaces);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
/** @hidden */
|
|
70
|
-
|
|
70
|
+
const generalDebugFunctions/*: IGeneralDebugFunctions*/ = {
|
|
71
71
|
δToString,
|
|
72
72
|
δsToString,
|
|
73
73
|
pointToStr,
|
|
@@ -27,10 +27,10 @@ export interface IThreeProngDebugFunctions {
|
|
|
27
27
|
* @param n - The 3-prong's zero-based index.
|
|
28
28
|
*/
|
|
29
29
|
function drawSpokes(g: SVGGElement, n: number): void {
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const threeProng = _debug_.generated.elems.threeProng[n];
|
|
31
|
+
//const g = threeProng.generated.g;
|
|
32
|
+
const cc = threeProng.circle.center;
|
|
33
|
+
const poss = threeProng.poss;
|
|
34
34
|
|
|
35
35
|
//_debug_.fs.draw.line(g, [poss[0].p, cc], 'thin5 red');
|
|
36
36
|
//_debug_.fs.draw.line(g, [poss[1].p, cc], 'thin5 red');
|
|
@@ -62,12 +62,12 @@ function traceConvergence(g: SVGGElement, n_: number, idx: number): void {
|
|
|
62
62
|
|
|
63
63
|
for (let n=sIndx; n<eIndx; n++) {
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
//
|
|
65
|
+
const forDebugging = _debug_.generated.elems.threeProng[n];
|
|
66
|
+
//const g = forDebugging.generated.g;
|
|
67
67
|
|
|
68
68
|
console.log(forDebugging);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
const candidateThreeProngs = forDebugging.candidateThreeProngs;
|
|
71
71
|
|
|
72
72
|
//-----------------------------
|
|
73
73
|
//---- Get start and end index
|
|
@@ -91,7 +91,7 @@ function traceConvergence(g: SVGGElement, n_: number, idx: number): void {
|
|
|
91
91
|
//---- Draw candidate three-prongs
|
|
92
92
|
//---------------------------------
|
|
93
93
|
for (let i=startIndx; i<endIndx; i++) {
|
|
94
|
-
|
|
94
|
+
const circle = candidateThreeProngs[i].circle;
|
|
95
95
|
if (forDebugging.bestIndx === i) {
|
|
96
96
|
drawFs.dot(g, circle.center, 0.2, 'green');
|
|
97
97
|
drawFs.circle(g, circle, 'black thin10 nofill');
|
|
@@ -112,16 +112,16 @@ function traceConvergence(g: SVGGElement, n_: number, idx: number): void {
|
|
|
112
112
|
* show all.
|
|
113
113
|
*/
|
|
114
114
|
function showBoundary(g: SVGGElement, n: number, idx: number): void {
|
|
115
|
-
|
|
116
|
-
//
|
|
115
|
+
const debugInfo = _debug_.generated.elems.threeProng[n];
|
|
116
|
+
//const g = debugInfo.generated.g;
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
const candidateThreeProngs = debugInfo.candidateThreeProngs;
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const startIndx = idx === undefined ? 0 : idx;
|
|
121
|
+
const endIndx = idx === undefined ? candidateThreeProngs.length : idx;
|
|
122
122
|
|
|
123
123
|
// Draw relevant δs
|
|
124
|
-
|
|
124
|
+
const cpss = debugInfo.cpss;
|
|
125
125
|
let j = 0;
|
|
126
126
|
// For each iteration of δ3s (indexed by j)
|
|
127
127
|
for (let idx=1; idx<cpss.length-1; idx++) {
|
|
@@ -131,7 +131,7 @@ function showBoundary(g: SVGGElement, n: number, idx: number): void {
|
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
const δ3s = [
|
|
135
135
|
cpss[0],
|
|
136
136
|
cpss[idx],
|
|
137
137
|
cpss[cpss.length-1]
|
|
@@ -140,17 +140,17 @@ function showBoundary(g: SVGGElement, n: number, idx: number): void {
|
|
|
140
140
|
|
|
141
141
|
// For each of the 3 δs
|
|
142
142
|
for (let i=0; i<3; i++) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const δ = δ3s[i];
|
|
144
|
+
const δS = δ[0]; // Delta Start
|
|
145
|
+
const δE = δ[1]; // Delta End
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
const posS = δS.cp.pointOnShape;
|
|
148
|
+
const posE = δE.cp.pointOnShape;
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
const pS = posS.p;
|
|
151
|
+
const pE = posE.p;
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
const r = 1 + (i*0.5);
|
|
154
154
|
|
|
155
155
|
if (equal(pS, pE)) {
|
|
156
156
|
drawFs.crossHair(g, pS, 'red thin10 nofill', r);
|
|
@@ -170,7 +170,7 @@ function showBoundary(g: SVGGElement, n: number, idx: number): void {
|
|
|
170
170
|
* @param n The 3-prong's zero-based index.
|
|
171
171
|
*/
|
|
172
172
|
function logδs(n: number): void {
|
|
173
|
-
|
|
173
|
+
const threeProng = _debug_.generated.elems.threeProng[n];
|
|
174
174
|
|
|
175
175
|
console.log(threeProng.cpss);
|
|
176
176
|
}
|
|
@@ -186,26 +186,26 @@ function logNearest(
|
|
|
186
186
|
showBoundaries = true) {
|
|
187
187
|
|
|
188
188
|
return function(g: SVGGElement, p: number[], showDelay = 1000) {
|
|
189
|
-
|
|
189
|
+
const generated = _debug_.generated;
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
const threeProng = getObjClosestTo<ThreeProngForDebugging>(
|
|
192
192
|
p,
|
|
193
193
|
generated.elems.threeProng,
|
|
194
194
|
threeProng => threeProng.circle ? threeProng.circle.center : [0,0]
|
|
195
195
|
);
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
//
|
|
198
|
+
const circle = threeProng.circle;
|
|
199
|
+
//const g = threeProng.generated.g;
|
|
200
200
|
|
|
201
201
|
console.log(threeProng);
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
const circle2 = {
|
|
204
204
|
center: circle.center,
|
|
205
205
|
radius: circle.radius || 1
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
//
|
|
208
|
+
//const draw = _debug_.fs.draw;
|
|
209
209
|
|
|
210
210
|
drawFs.circle(g, circle2, 'blue thin10 nofill', showDelay);
|
|
211
211
|
drawFs.crossHair(g, circle.center, 'red thin2 nofill', 2, showDelay);
|
|
@@ -218,21 +218,21 @@ function logNearest(
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
if (showBoundaries) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
const boundaries = threeProng.boundaries;
|
|
222
|
+
const boundaryS = boundaries[0];
|
|
223
|
+
const boundaryE = boundaries[boundaries.length-1];
|
|
224
224
|
|
|
225
225
|
drawFs.beziers(g, boundaryS, 'red thin20 nofill', showDelay);
|
|
226
226
|
for (let i=1; i<boundaries.length-1; i++) {
|
|
227
|
-
|
|
227
|
+
const boundary = boundaries[i];
|
|
228
228
|
drawFs.beziers(g, boundary, 'green thin20 nofill', showDelay);
|
|
229
229
|
}
|
|
230
230
|
drawFs.beziers(g, boundaryE, 'blue thin20 nofill', showDelay);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
if (showTrace) {
|
|
234
|
-
|
|
235
|
-
for (
|
|
234
|
+
const traces = threeProng.traces;
|
|
235
|
+
for (const trace of traces) {
|
|
236
236
|
drawFs.polyline(g, trace, 'red thin5 nofill', showDelay)
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -241,7 +241,7 @@ function logNearest(
|
|
|
241
241
|
|
|
242
242
|
|
|
243
243
|
/** @hidden */
|
|
244
|
-
|
|
244
|
+
const threeProngDebugFunctions: IThreeProngDebugFunctions = {
|
|
245
245
|
drawSpokes,
|
|
246
246
|
traceConvergence,
|
|
247
247
|
showBoundary,
|
|
@@ -25,7 +25,7 @@ interface ITwoProngDebugFunctions {
|
|
|
25
25
|
* @hidden
|
|
26
26
|
*/
|
|
27
27
|
function logδ(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
28
|
-
|
|
28
|
+
const δ =_debug_.generated.elems[type][n].δ;
|
|
29
29
|
|
|
30
30
|
console.log(δ);
|
|
31
31
|
}
|
|
@@ -35,7 +35,7 @@ function logδ(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
|
35
35
|
* @hidden
|
|
36
36
|
*/
|
|
37
37
|
function log(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
38
|
-
|
|
38
|
+
const twoProng = _debug_.generated.elems[type][n];
|
|
39
39
|
console.log(twoProng);
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -49,7 +49,7 @@ function drawNormal(
|
|
|
49
49
|
showDelay = 1000,
|
|
50
50
|
type: ElemType_TwoProng = 'twoProng_regular') {
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const twoProngs = _debug_.generated.elems[type];
|
|
53
53
|
|
|
54
54
|
// If not specified which, draw all
|
|
55
55
|
if (n === undefined) {
|
|
@@ -58,7 +58,7 @@ function drawNormal(
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const twoProng = twoProngs[n];
|
|
62
62
|
|
|
63
63
|
//let g = twoProng.generated.g;
|
|
64
64
|
|
|
@@ -77,10 +77,10 @@ function logδBasic(
|
|
|
77
77
|
n: number,
|
|
78
78
|
type: ElemType_TwoProng = 'twoProng_regular') {
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const delta = _debug_.generated.elems[type][n].δ;
|
|
81
81
|
|
|
82
82
|
function f(x: CpNode) {
|
|
83
|
-
|
|
83
|
+
const pos = x.cp.pointOnShape;
|
|
84
84
|
return {
|
|
85
85
|
bez: pos.curve.ps,
|
|
86
86
|
t: pos.t
|
|
@@ -96,10 +96,10 @@ function logδBasic(
|
|
|
96
96
|
* @hidden
|
|
97
97
|
*/
|
|
98
98
|
function logNearest(g: SVGGElement, p: number[], showDelay = 1000, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
99
|
-
|
|
99
|
+
const closestPerLoops: TwoProngForDebugging[] = [];
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const generated = _debug_.generated;
|
|
102
|
+
const twoProng = getObjClosestTo<TwoProngForDebugging>(
|
|
103
103
|
p,
|
|
104
104
|
generated.elems[type],
|
|
105
105
|
twoProng => twoProng.circle.center
|
|
@@ -110,7 +110,7 @@ function logNearest(g: SVGGElement, p: number[], showDelay = 1000, type: ElemTyp
|
|
|
110
110
|
|
|
111
111
|
let n;
|
|
112
112
|
for (let i=0; i<_debug_.generated.elems[type].length; i++) {
|
|
113
|
-
|
|
113
|
+
const twoProng_ = _debug_.generated.elems[type][i];
|
|
114
114
|
if (twoProng_ === twoProng) {
|
|
115
115
|
n = i;
|
|
116
116
|
break;
|
|
@@ -136,8 +136,8 @@ function traceConvergence(
|
|
|
136
136
|
|
|
137
137
|
if (n === undefined) { return; }
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const twoProngInfo = _debug_.generated.elems[type][n];
|
|
140
|
+
const xs = twoProngInfo.xs;
|
|
141
141
|
//let g = twoProngInfo.generated.g;
|
|
142
142
|
|
|
143
143
|
console.log(twoProngInfo);
|
|
@@ -160,9 +160,9 @@ function traceConvergence(
|
|
|
160
160
|
continue;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
const x = twoProngInfo.xs[i];
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
const circle = { center: x.x, radius: distanceBetween(x.x, x.y.p) };
|
|
166
166
|
drawFs.crossHair(g, x.x, 'red thin10 nofill', undefined, showDelay);
|
|
167
167
|
drawFs.circle(g, circle, 'blue thin10 nofill', showDelay);
|
|
168
168
|
if (x.z !== undefined) {
|
|
@@ -177,7 +177,7 @@ function traceConvergence(
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
/** @hidden */
|
|
180
|
-
|
|
180
|
+
const twoProngDebugFunctions: ITwoProngDebugFunctions = {
|
|
181
181
|
logδ,
|
|
182
182
|
log,
|
|
183
183
|
drawNormal,
|
package/src/find-mats.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
declare
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const _debug_: Debug;
|
|
3
3
|
|
|
4
4
|
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
5
5
|
import { simplifyPaths } from 'flo-boolean';
|
|
@@ -8,7 +8,7 @@ import { CpNode } from './cp-node.js';
|
|
|
8
8
|
import { Loop } from './loop.js';
|
|
9
9
|
import { Mat } from './mat.js';
|
|
10
10
|
import { findAndAddAll3Prongs } from './mat/find-mat/find-and-add-3-prongs.js';
|
|
11
|
-
import { createInitialCpGraph } from './mat/find-mat/create-initial-cp-graph.js'
|
|
11
|
+
import { createInitialCpGraph } from './mat/find-mat/create-initial-cp-graph.js';
|
|
12
12
|
import { addDebugInfo1, addDebugInfo2, addDebugInfo3, addDebugInfo4 } from './mat/find-mat/add-debug-info.js';
|
|
13
13
|
import { getPotential2Prongs } from './mat/find-mat/get-potential-2-prongs.js';
|
|
14
14
|
import { getSharpCorners } from './mat/find-mat/get-sharp-corners.js';
|
|
@@ -46,18 +46,18 @@ function findMats(
|
|
|
46
46
|
maxCurviness = 0.4,
|
|
47
47
|
maxLength = 4): Mat[] {
|
|
48
48
|
|
|
49
|
-
if (typeof _debug_ !== 'undefined') { var timingStart = performance.now(); }
|
|
49
|
+
// if (typeof _debug_ !== 'undefined') { var timingStart = performance.now(); }
|
|
50
50
|
|
|
51
51
|
let maxCoordinate: number;
|
|
52
52
|
let minBezLength: number;
|
|
53
53
|
({ maxCurviness, maxLength, maxCoordinate, minBezLength } =
|
|
54
54
|
getSizeParams(bezierLoops, maxCurviness, maxLength));
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
const loopss = simplifyPaths(bezierLoops, maxCoordinate);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
for (
|
|
60
|
-
|
|
58
|
+
const mats: Mat[] = [];
|
|
59
|
+
for (const loops of loopss) {
|
|
60
|
+
const mat = findMat(
|
|
61
61
|
loops,
|
|
62
62
|
minBezLength,
|
|
63
63
|
maxCurviness,
|
|
@@ -77,14 +77,14 @@ function getSizeParams(
|
|
|
77
77
|
maxLength: number) {
|
|
78
78
|
|
|
79
79
|
// Gather some shape metrics
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const { maxCoordinate, maxRadius } = getLoopsMetrics(bezierLoops);
|
|
81
|
+
const expMax = Math.ceil(Math.log2(maxCoordinate));
|
|
82
|
+
const minBezLengthSigBits = 14;
|
|
83
83
|
/**
|
|
84
84
|
* If a curve is shorter than this value then no points on it will be
|
|
85
85
|
* selected for the purpose of finding the MAT.
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
const minBezLength = 2**expMax * 2**(-minBezLengthSigBits);
|
|
88
88
|
|
|
89
89
|
// Limit the tolerance to a reasonable level
|
|
90
90
|
if (maxCurviness < 0.05) { maxCurviness = 0.05; }
|
|
@@ -93,8 +93,8 @@ function getSizeParams(
|
|
|
93
93
|
if (maxLength < 0.1) { maxLength = 0.1; }
|
|
94
94
|
if (maxLength > 100) { maxLength = 100; }
|
|
95
95
|
// Adjust length tolerance according to a reference max coordinate
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const expMaxRadius = Math.ceil(Math.log2(maxRadius));
|
|
97
|
+
const maxLengthSigBits = 10; // 1024 x 1024
|
|
98
98
|
maxLength = maxLength * (2**expMaxRadius * 2**(-maxLengthSigBits));
|
|
99
99
|
|
|
100
100
|
return { maxCurviness, maxLength, maxCoordinate, minBezLength };
|
|
@@ -118,14 +118,14 @@ function findMat(
|
|
|
118
118
|
|
|
119
119
|
// Gets interesting points on the shape, i.e. those that makes sense to use
|
|
120
120
|
// for the 2-prong procedure.
|
|
121
|
-
|
|
121
|
+
const pointsPerLoop = loops.map(
|
|
122
122
|
getInterestingPointsOnLoop(minBezLength, maxCurviness, maxLength)
|
|
123
123
|
);
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const for2ProngsPerLoop = getPotential2Prongs(pointsPerLoop);
|
|
126
|
+
const sharpCornersPerLoop = getSharpCorners(pointsPerLoop);
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
const cpTrees: Map<Loop, LlRbTree<CpNode>> = new Map();
|
|
129
129
|
let cpNode = createInitialCpGraph(loops, cpTrees, sharpCornersPerLoop);
|
|
130
130
|
|
|
131
131
|
findAndAddHoleClosing2Prongs(loops, cpTrees, maxCoordinate);
|
|
@@ -160,7 +160,7 @@ function findMat(
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
const mat = { cpNode, cpTrees };
|
|
164
164
|
|
|
165
165
|
addDebugInfo4(mat);
|
|
166
166
|
|
|
@@ -9,14 +9,14 @@ import { Curve } from './curve.js';
|
|
|
9
9
|
* @param cpNode
|
|
10
10
|
*/
|
|
11
11
|
function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const cpThis = cpNode;
|
|
13
|
+
const cpNext = cpNode.next;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const posThis = cpThis.cp.pointOnShape;
|
|
16
|
+
const posNext = cpNext.cp.pointOnShape;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const curveThis = posThis.curve;
|
|
19
|
+
const curveNext = posNext.curve;
|
|
20
20
|
|
|
21
21
|
if (curveThis.loop !== curveNext.loop) {
|
|
22
22
|
// It is a hole-closer going over to the other loop - a kind of terminal
|
|
@@ -24,7 +24,7 @@ function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
|
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const bezierParts: BezierPiece[] = [];
|
|
28
28
|
|
|
29
29
|
if (curveNext === curveThis) {
|
|
30
30
|
bezierParts.push(
|
|
@@ -60,7 +60,7 @@ function addSkippedBeziers(
|
|
|
60
60
|
let curveThis = curveStart;
|
|
61
61
|
do {
|
|
62
62
|
curveThis = curveThis.next;
|
|
63
|
-
|
|
63
|
+
const bezierPart = curveThis === curveEnd
|
|
64
64
|
? { ps: curveThis.ps, ts: [0, t1] }
|
|
65
65
|
: { ps: curveThis.ps, ts: [0, 1] }
|
|
66
66
|
|
|
@@ -10,14 +10,14 @@ import { Curve } from './curve.js';
|
|
|
10
10
|
* @param cpNode
|
|
11
11
|
*/
|
|
12
12
|
function getBoundaryBeziersToNext(cpNode: CpNode) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const cpThis = cpNode;
|
|
14
|
+
const cpNext = cpNode.next;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const posThis = cpThis.cp.pointOnShape;
|
|
17
|
+
const posNext = cpNext.cp.pointOnShape;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const curveThis = posThis.curve;
|
|
20
|
+
const curveNext = posNext.curve;
|
|
21
21
|
|
|
22
22
|
if (curveThis.loop !== curveNext.loop) {
|
|
23
23
|
// It is a hole-closer going over to the other loop - a kind of terminal
|
|
@@ -25,7 +25,7 @@ function getBoundaryBeziersToNext(cpNode: CpNode) {
|
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const beziers = [];
|
|
29
29
|
|
|
30
30
|
if (curveNext === curveThis) {
|
|
31
31
|
beziers.push(
|
|
@@ -61,7 +61,7 @@ function addSkippedBeziers(
|
|
|
61
61
|
let curveThis = curveStart;
|
|
62
62
|
do {
|
|
63
63
|
curveThis = curveThis.next;
|
|
64
|
-
|
|
64
|
+
const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
65
65
|
beziers.push(
|
|
66
66
|
// qqq from0ToT(curveThis.ps, tEnd)
|
|
67
67
|
fromTo(curveThis.ps, 0, tEnd)
|
package/src/get-branches.ts
CHANGED
|
@@ -26,15 +26,15 @@ function getBranches(
|
|
|
26
26
|
cpNode = cpNode.next;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const branches: CpNode[][] = [];
|
|
30
30
|
|
|
31
31
|
// Since the tree is unrooted we must iterate in all directions from the
|
|
32
32
|
// given vertex.
|
|
33
|
-
|
|
33
|
+
const cps = [cpNode.prevOnCircle];
|
|
34
34
|
|
|
35
35
|
let branchCpNodes: CpNode[] = [];
|
|
36
36
|
while (cps.length) {
|
|
37
|
-
|
|
37
|
+
const cp = cps.pop();
|
|
38
38
|
branchCpNodes.push(cp);
|
|
39
39
|
|
|
40
40
|
let children = cp.getChildren();
|
|
@@ -68,17 +68,17 @@ function getBranches(
|
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const backPointingTan = toUnitVector(tangent(
|
|
72
72
|
getCurveToNext(cp.next.prevOnCircle),
|
|
73
73
|
0
|
|
74
74
|
));
|
|
75
|
-
|
|
75
|
+
const forwardPointingTan = toUnitVector(tangent(
|
|
76
76
|
getCurveToNext(children[0]),
|
|
77
77
|
0
|
|
78
78
|
));
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const cross_ = cross(backPointingTan, forwardPointingTan);
|
|
81
|
+
const angle = Math.abs(Math.asin( cross_ ) * (180/Math.PI));
|
|
82
82
|
|
|
83
83
|
if (angle > tolerance) {
|
|
84
84
|
branches.push(branchCpNodes);
|
|
@@ -22,22 +22,22 @@ function getCurveBetween(
|
|
|
22
22
|
cpNodeFrom: CpNode,
|
|
23
23
|
cpNodeTo: CpNode) {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const fromCc = cpNodeFrom.cp.circle.center;
|
|
26
|
+
const fromL = getEdgeDirection(cpNodeFrom);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const toCc = cpNodeTo.cp.circle.center;
|
|
29
|
+
const toL = getEdgeDirection(cpNodeTo.prevOnCircle);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
const mid = lineLineIntersection(fromL, toL);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const c = fromTo(fromCc,toCc);
|
|
34
34
|
|
|
35
35
|
let twisted: boolean;
|
|
36
36
|
if (!mid) {
|
|
37
37
|
twisted = true;
|
|
38
38
|
} else {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const a = fromTo(fromCc, mid);
|
|
40
|
+
const b = fromTo(toCc, mid);
|
|
41
41
|
|
|
42
42
|
twisted = dot(a,c) < 0 || dot(b,c) > 0;
|
|
43
43
|
}
|
|
@@ -46,12 +46,12 @@ function getCurveBetween(
|
|
|
46
46
|
return [fromCc, mid, toCc];
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const r = rotate90Degrees(c);
|
|
50
|
+
const w1 = fromTo(fromL[0], fromL[1]); // This is a unit vector
|
|
51
|
+
const w2 = fromTo(toL[0], toL[1]); // This is a unit vector
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const d1 = Math.abs(cross(c, w1)) / (3*3);
|
|
54
|
+
const d2 = Math.abs(cross(c, w2)) / (3*3);
|
|
55
55
|
|
|
56
56
|
if (d1 > TOLERANCE_ADD_2PRONG || d2 > TOLERANCE_ADD_2PRONG) {
|
|
57
57
|
// TODO - not within tolerance - must add additional 2-prong
|
|
@@ -60,14 +60,14 @@ function getCurveBetween(
|
|
|
60
60
|
|
|
61
61
|
if (d1 > TOLERANCE_USE_LINE || d2 > TOLERANCE_USE_LINE) {
|
|
62
62
|
// approximate with cubic bezier
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
const m1 = interpolate(fromCc,toCc,1/3);
|
|
64
|
+
const m2 = interpolate(fromCc,toCc,2/3);
|
|
65
|
+
const v1 = translate(r, m1);
|
|
66
|
+
const v2 = translate(r, m2);
|
|
67
|
+
const l1 = [m1,v1];
|
|
68
|
+
const l2 = [m2,v2];
|
|
69
|
+
const mid1 = lineLineIntersection(fromL, l1);
|
|
70
|
+
const mid2 = lineLineIntersection(toL, l2);
|
|
71
71
|
|
|
72
72
|
return [fromCc, mid1, mid2, toCc];
|
|
73
73
|
}
|