flo-mat 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.cjs +17 -0
- package/README.md +12 -1
- package/browser/index.js +7348 -0
- package/browser/index.min.js +2 -1
- package/browser/index.min.js.LICENSE.txt +2907 -0
- package/browser/index.module.js +7369 -0
- package/browser/index.module.min.js +2 -0
- package/browser/index.module.min.js.LICENSE.txt +2907 -0
- package/node/circle.js +3 -7
- package/node/circle.js.map +1 -1
- package/node/compare-curvatures-at-interface.d.ts +19 -0
- package/node/compare-curvatures-at-interface.js +125 -0
- package/node/compare-curvatures-at-interface.js.map +1 -0
- package/node/contact-point.d.ts +2 -2
- package/node/contact-point.js +3 -6
- package/node/contact-point.js.map +1 -1
- package/node/cp-node/clone.d.ts +1 -1
- package/node/cp-node/clone.js +4 -7
- package/node/cp-node/clone.js.map +1 -1
- package/node/cp-node/remove.d.ts +2 -2
- package/node/cp-node/remove.js +1 -4
- package/node/cp-node/remove.js.map +1 -1
- package/node/cp-node.d.ts +4 -5
- package/node/cp-node.js +8 -12
- package/node/cp-node.js.map +1 -1
- package/node/curve.d.ts +2 -2
- package/node/curve.js +10 -14
- package/node/curve.js.map +1 -1
- package/node/debug/cp-node-for-debugging.d.ts +2 -2
- package/node/debug/cp-node-for-debugging.js +1 -2
- package/node/debug/debug-elem-types.d.ts +8 -8
- package/node/debug/debug-elem-types.js +1 -2
- package/node/debug/debug.d.ts +5 -7
- package/node/debug/debug.js +67 -10
- package/node/debug/debug.js.map +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js +3 -6
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/branch.d.ts +1 -1
- package/node/debug/functions/draw-elem/branch.js +5 -8
- package/node/debug/functions/draw-elem/branch.js.map +1 -1
- package/node/debug/functions/draw-elem/culls.d.ts +1 -1
- package/node/debug/functions/draw-elem/culls.js +1 -4
- package/node/debug/functions/draw-elem/culls.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.js +1 -4
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js +34 -37
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/dull-corner.d.ts +1 -1
- package/node/debug/functions/draw-elem/dull-corner.js +5 -7
- package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/leaves.d.ts +1 -1
- package/node/debug/functions/draw-elem/leaves.js +3 -6
- package/node/debug/functions/draw-elem/leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/loop.d.ts +1 -1
- package/node/debug/functions/draw-elem/loop.js +1 -4
- package/node/debug/functions/draw-elem/loop.js.map +1 -1
- package/node/debug/functions/draw-elem/loops.d.ts +1 -1
- package/node/debug/functions/draw-elem/loops.js +1 -4
- package/node/debug/functions/draw-elem/loops.js.map +1 -1
- package/node/debug/functions/draw-elem/loose-bounding-box.js +3 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/mat.d.ts +1 -1
- package/node/debug/functions/draw-elem/mat.js +7 -10
- package/node/debug/functions/draw-elem/mat.js.map +1 -1
- package/node/debug/functions/draw-elem/max-vertex.d.ts +1 -1
- package/node/debug/functions/draw-elem/max-vertex.js +3 -6
- package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/min-y.d.ts +1 -1
- package/node/debug/functions/draw-elem/min-y.js +9 -12
- 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 +1 -1
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +7 -10
- 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 +1 -1
- package/node/debug/functions/draw-elem/one-prong.js +9 -12
- package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.js +3 -6
- package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/three-prong.d.ts +1 -1
- package/node/debug/functions/draw-elem/three-prong.js +9 -12
- package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.js +3 -6
- package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/two-prong.d.ts +1 -1
- package/node/debug/functions/draw-elem/two-prong.js +9 -12
- package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/vertex.d.ts +1 -1
- package/node/debug/functions/draw-elem/vertex.js +7 -10
- package/node/debug/functions/draw-elem/vertex.js.map +1 -1
- package/node/debug/functions/general.d.ts +1 -1
- package/node/debug/functions/general.js +3 -6
- package/node/debug/functions/general.js.map +1 -1
- package/node/debug/functions/three-prong.js +24 -27
- package/node/debug/functions/three-prong.js.map +1 -1
- package/node/debug/functions/two-prong.d.ts +1 -1
- package/node/debug/functions/two-prong.js +10 -13
- package/node/debug/functions/two-prong.js.map +1 -1
- package/node/debug/three-prong-for-debugging.d.ts +4 -4
- package/node/debug/three-prong-for-debugging.js +4 -7
- package/node/debug/three-prong-for-debugging.js.map +1 -1
- package/node/debug/two-prong-for-debugging.d.ts +5 -5
- package/node/debug/two-prong-for-debugging.js +1 -2
- package/node/find-mats.d.ts +12 -9
- package/node/find-mats.js +47 -53
- package/node/find-mats.js.map +1 -1
- package/node/get-boundary-bezier-parts-to-next.d.ts +3 -3
- package/node/get-boundary-bezier-parts-to-next.js +1 -4
- package/node/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/get-boundary-beziers-to-next.d.ts +1 -1
- package/node/get-boundary-beziers-to-next.js +8 -8
- package/node/get-boundary-beziers-to-next.js.map +1 -1
- package/node/get-bounding-box-.d.ts +2 -0
- package/node/get-bounding-box-.js +5 -0
- package/node/get-bounding-box-.js.map +1 -0
- package/node/get-branches.d.ts +1 -1
- package/node/get-branches.js +7 -10
- package/node/get-branches.js.map +1 -1
- package/node/get-curve/get-curve-between.d.ts +1 -1
- package/node/get-curve/get-curve-between.js +21 -24
- package/node/get-curve/get-curve-between.js.map +1 -1
- package/node/get-curve/get-edge-direction.d.ts +1 -1
- package/node/get-curve/get-edge-direction.js +12 -15
- package/node/get-curve/get-edge-direction.js.map +1 -1
- package/node/get-curve-to-next.d.ts +1 -1
- package/node/get-curve-to-next.js +3 -6
- package/node/get-curve-to-next.js.map +1 -1
- package/node/get-interface-ccw.d.ts +24 -0
- package/node/get-interface-ccw.js +98 -0
- package/node/get-interface-ccw.js.map +1 -0
- package/node/index.d.ts +35 -36
- package/node/index.js +32 -56
- package/node/index.js.map +1 -1
- package/node/loop/get-max-coordinate.js +1 -4
- package/node/loop/get-max-coordinate.js.map +1 -1
- package/node/loop.d.ts +1 -1
- package/node/loop.js +1 -4
- package/node/loop.js.map +1 -1
- package/node/mat/add-to-cp-graph.d.ts +5 -5
- package/node/mat/add-to-cp-graph.js +5 -8
- package/node/mat/add-to-cp-graph.js.map +1 -1
- package/node/mat/bezier-piece.d.ts +1 -1
- package/node/mat/bezier-piece.js +1 -2
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +15 -14
- 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 +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +7 -10
- 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 +1 -1
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +5 -8
- 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 +1 -1
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +7 -8
- 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 +1 -1
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +6 -9
- 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 +2 -2
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +9 -12
- 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 +3 -3
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +10 -13
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
- package/node/mat/corner.js +1 -2
- package/node/mat/create-new-cp-tree.d.ts +3 -3
- package/node/mat/create-new-cp-tree.js +5 -7
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/elem-type-two-prong.js +1 -2
- package/node/mat/find-mat/add-1-prong.d.ts +4 -4
- package/node/mat/find-mat/add-1-prong.js +9 -12
- package/node/mat/find-mat/add-1-prong.js.map +1 -1
- package/node/mat/find-mat/add-2-prong.d.ts +5 -5
- package/node/mat/find-mat/add-2-prong.js +19 -22
- package/node/mat/find-mat/add-2-prong.js.map +1 -1
- package/node/mat/find-mat/add-3-prong.d.ts +5 -5
- package/node/mat/find-mat/add-3-prong.js +7 -10
- package/node/mat/find-mat/add-3-prong.js.map +1 -1
- package/node/mat/find-mat/add-debug-info.d.ts +2 -2
- package/node/mat/find-mat/add-debug-info.js +8 -13
- 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 +3 -3
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +29 -16
- 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 +4 -4
- package/node/mat/find-mat/create-initial-cp-graph.js +7 -9
- 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 +5 -5
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +3 -6
- 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 +1 -1
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +5 -8
- 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 +5 -5
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +37 -39
- 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.js +1 -4
- 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 +5 -5
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +7 -10
- 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 +1 -1
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -2
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +2 -2
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +10 -13
- 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 +2 -2
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +6 -8
- 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 +3 -3
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +29 -32
- 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 +3 -3
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +14 -12
- 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 +2 -2
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +3 -6
- 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 +4 -4
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +3 -6
- 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 +4 -4
- package/node/mat/find-mat/find-and-add-2-prongs.js +9 -12
- 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 +3 -3
- package/node/mat/find-mat/find-and-add-3-prongs.js +8 -11
- 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 +3 -3
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +11 -14
- 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 +1 -1
- package/node/mat/find-mat/get-potential-2-prongs.js +3 -6
- package/node/mat/find-mat/get-potential-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-sharp-corners.d.ts +1 -1
- package/node/mat/find-mat/get-sharp-corners.js +3 -6
- package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +21 -15
- package/node/mat/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +5 -8
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
- package/node/mat/get-boundary-piece-beziers.js +6 -9
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-contact-circles-at-interface.d.ts +2 -2
- package/node/mat/get-contact-circles-at-interface.js +7 -10
- package/node/mat/get-contact-circles-at-interface.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +1 -1
- package/node/mat/get-largest-vertex.js +1 -4
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/get-leaves.d.ts +1 -1
- package/node/mat/get-leaves.js +1 -4
- package/node/mat/get-leaves.js.map +1 -1
- package/node/mat/get-neighboring-cps.d.ts +3 -3
- package/node/mat/get-neighboring-cps.js +5 -8
- package/node/mat/get-neighboring-cps.js.map +1 -1
- package/node/mat/get-two-prong-type.d.ts +2 -2
- package/node/mat/get-two-prong-type.js +1 -4
- package/node/mat/get-two-prong-type.js.map +1 -1
- package/node/mat/is-another-cp-closeby.d.ts +5 -5
- package/node/mat/is-another-cp-closeby.js +8 -11
- package/node/mat/is-another-cp-closeby.js.map +1 -1
- package/node/mat/simplify-mat-map-only.d.ts +1 -1
- package/node/mat/simplify-mat-map-only.js +10 -14
- package/node/mat/simplify-mat-map-only.js.map +1 -1
- package/node/mat/to-scale-axis/add-debug-info.d.ts +1 -1
- package/node/mat/to-scale-axis/add-debug-info.js +1 -4
- package/node/mat/to-scale-axis/add-debug-info.js.map +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.js +5 -8
- package/node/mat/to-scale-axis/cull-non-cycles.js.map +1 -1
- package/node/mat/to-scale-axis/cull.d.ts +2 -2
- package/node/mat/to-scale-axis/cull.js +75 -8
- package/node/mat/to-scale-axis/cull.js.map +1 -1
- package/node/mat/trim-mat.d.ts +1 -1
- package/node/mat/trim-mat.js +6 -9
- package/node/mat/trim-mat.js.map +1 -1
- package/node/mat.d.ts +3 -3
- package/node/mat.js +1 -2
- package/node/point-on-shape.d.ts +2 -2
- package/node/point-on-shape.js +23 -34
- package/node/point-on-shape.js.map +1 -1
- package/node/simplify-mat.d.ts +4 -3
- package/node/simplify-mat.js +14 -16
- package/node/simplify-mat.js.map +1 -1
- package/node/svg/get-loop-bounds.d.ts +2 -2
- package/node/svg/get-loop-bounds.js +11 -13
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.d.ts +3 -2
- package/node/svg/get-min-y-pos.js +3 -6
- package/node/svg/get-min-y-pos.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +5 -5
- package/node/svg/get-shape-bounds.js +5 -8
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js +1 -4
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/to-scale-axis.d.ts +2 -1
- package/node/to-scale-axis.js +18 -21
- package/node/to-scale-axis.js.map +1 -1
- package/node/traverse-edges.d.ts +1 -1
- package/node/traverse-edges.js +1 -4
- package/node/traverse-edges.js.map +1 -1
- package/node/traverse-vertices.d.ts +1 -1
- package/node/traverse-vertices.js +1 -4
- package/node/traverse-vertices.js.map +1 -1
- package/package.json +34 -31
- package/src/circle.ts +0 -6
- package/src/compare-curvatures-at-interface.ts +197 -0
- package/src/contact-point.ts +2 -3
- package/src/cp-node/clone.ts +1 -2
- package/src/cp-node/remove.ts +2 -3
- package/src/cp-node.ts +6 -8
- package/src/curve.ts +3 -4
- package/src/debug/cp-node-for-debugging.ts +2 -3
- package/src/debug/debug-elem-types.ts +8 -10
- package/src/debug/debug.ts +22 -17
- package/src/debug/functions/draw-elem/bounding-hull.ts +0 -1
- package/src/debug/functions/draw-elem/branch.ts +2 -3
- package/src/debug/functions/draw-elem/culls.ts +1 -2
- package/src/debug/functions/draw-elem/draw-elem.ts +18 -19
- package/src/debug/functions/draw-elem/dull-corner.ts +3 -3
- package/src/debug/functions/draw-elem/leaves.ts +2 -4
- package/src/debug/functions/draw-elem/loop.ts +1 -2
- package/src/debug/functions/draw-elem/loops.ts +1 -2
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +0 -1
- package/src/debug/functions/draw-elem/mat.ts +3 -5
- package/src/debug/functions/draw-elem/max-vertex.ts +1 -2
- package/src/debug/functions/draw-elem/min-y.ts +5 -7
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -2
- package/src/debug/functions/draw-elem/one-prong.ts +2 -3
- package/src/debug/functions/draw-elem/sharp-corner.ts +1 -2
- package/src/debug/functions/draw-elem/three-prong.ts +2 -4
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +0 -1
- package/src/debug/functions/draw-elem/two-prong.ts +2 -3
- package/src/debug/functions/draw-elem/vertex.ts +1 -2
- package/src/debug/functions/general.ts +2 -3
- package/src/debug/functions/three-prong.ts +3 -4
- package/src/debug/functions/two-prong.ts +6 -14
- package/src/debug/three-prong-for-debugging.ts +4 -5
- package/src/debug/two-prong-for-debugging.ts +5 -6
- package/src/find-mats.ts +34 -39
- package/src/get-boundary-bezier-parts-to-next.ts +5 -6
- package/src/get-boundary-beziers-to-next.ts +8 -7
- package/src/get-bounding-box-.ts +7 -0
- package/src/get-branches.ts +2 -3
- package/src/get-curve/get-curve-between.ts +2 -3
- package/src/get-curve/get-edge-direction.ts +2 -5
- package/src/get-curve-to-next.ts +2 -3
- package/src/get-interface-ccw.ts +112 -0
- package/src/index.ts +34 -48
- package/src/loop/get-max-coordinate.ts +0 -1
- package/src/loop.ts +1 -2
- package/src/mat/add-to-cp-graph.ts +7 -8
- package/src/mat/bezier-piece.ts +1 -2
- package/src/mat/closest-boundary-point/closest-points-on-curve.ts +19 -17
- package/src/mat/closest-boundary-point/cull-bezier-pieces.ts +4 -5
- package/src/mat/closest-boundary-point/cull-by-loose-bounding-box.ts +4 -5
- package/src/mat/closest-boundary-point/cull-by-tight-boundary-box.ts +7 -5
- package/src/mat/closest-boundary-point/get-best-distance-squared.ts +1 -2
- package/src/mat/closest-boundary-point/get-close-boundary-points.ts +4 -11
- package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +5 -6
- package/src/mat/cmp-cp-on-delta.ts +2 -3
- package/src/mat/create-new-cp-tree.ts +5 -5
- package/src/mat/find-mat/add-1-prong.ts +7 -8
- package/src/mat/find-mat/add-2-prong.ts +11 -12
- package/src/mat/find-mat/add-3-prong.ts +7 -8
- package/src/mat/find-mat/add-debug-info.ts +8 -7
- package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +22 -8
- package/src/mat/find-mat/create-initial-cp-graph.ts +7 -8
- package/src/mat/find-mat/find-2-prong/add-debug-info.ts +9 -10
- package/src/mat/find-mat/find-2-prong/cull-bezier-pieces.ts +4 -7
- package/src/mat/find-mat/find-2-prong/find-2-prong.ts +19 -17
- package/src/mat/find-mat/find-2-prong/get-initial-bezier-pieces.ts +7 -8
- package/src/mat/find-mat/find-2-prong/x-for-debugging.ts +1 -2
- package/src/mat/find-mat/find-3-prong/calc-better-x.ts +3 -6
- package/src/mat/find-mat/find-3-prong/calc-initial-3-prong-center.ts +3 -8
- package/src/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.ts +10 -14
- package/src/mat/find-mat/find-3-prong/find-3-prong.ts +13 -8
- package/src/mat/find-mat/find-3-prong/get-closest-points.ts +2 -5
- package/src/mat/find-mat/find-and-add-2-prongs-on-all-paths.ts +5 -6
- package/src/mat/find-mat/find-and-add-2-prongs.ts +9 -10
- package/src/mat/find-mat/find-and-add-3-prongs.ts +8 -9
- package/src/mat/find-mat/find-and-add-hole-closing-2-prongs.ts +7 -8
- package/src/mat/find-mat/get-potential-2-prongs.ts +1 -2
- package/src/mat/find-mat/get-sharp-corners.ts +1 -2
- package/src/mat/find-mat/get-total-abs-curvature.ts +2 -3
- package/src/mat/find-mat/get-total-by.ts +2 -3
- package/src/mat/geometry/get-closest-square-distance-to-rect.ts +15 -4
- package/src/mat/geometry/get-closest-squared-distance-to-rotated-rect.ts +0 -1
- package/src/mat/get-boundary-piece-beziers.ts +5 -6
- package/src/mat/get-contact-circles-at-interface.ts +3 -4
- package/src/mat/get-edges-as-array.ts +2 -3
- package/src/mat/get-largest-three-prong.ts +1 -2
- package/src/mat/get-largest-vertex.ts +1 -2
- package/src/mat/get-leaves.ts +1 -2
- package/src/mat/get-neighboring-cps.ts +5 -6
- package/src/mat/get-two-prong-type.ts +2 -3
- package/src/mat/is-another-cp-closeby.ts +6 -7
- package/src/mat/simplify-mat-map-only.ts +5 -7
- package/src/mat/to-scale-axis/add-debug-info.ts +2 -3
- package/src/mat/to-scale-axis/add-to-tree.ts +3 -4
- package/src/mat/to-scale-axis/calc-groups.ts +1 -2
- package/src/mat/to-scale-axis/create-spacial-tree.ts +3 -4
- package/src/mat/to-scale-axis/cull-non-cycles.ts +2 -3
- package/src/mat/to-scale-axis/cull.ts +3 -4
- package/src/mat/to-scale-axis/get-engulfed-vertices.ts +3 -4
- package/src/mat/to-scale-axis/t-tree.ts +1 -2
- package/src/mat/to-scale-axis/traverse-spacial-tree.ts +2 -4
- package/src/mat/trim-mat.ts +4 -5
- package/src/mat.ts +3 -5
- package/src/point-on-shape.ts +10 -12
- package/src/simplify-mat.ts +11 -13
- package/src/svg/get-curvature-at-interface.ts +1 -3
- package/src/svg/get-extreme.ts +2 -3
- package/src/svg/get-loop-bounds.ts +4 -4
- package/src/svg/get-min-y-pos.ts +2 -6
- package/src/svg/get-shape-bounds.ts +2 -3
- package/src/sweep-line/are-boxes-intersecting.ts +1 -1
- package/src/to-scale-axis.ts +15 -16
- package/src/traverse-edges.ts +1 -2
- package/src/traverse-vertices.ts +1 -2
- package/test/lib-load.spec.ts +0 -1
- package/tsconfig.json +6 -31
- package/webpack.config.cjs +132 -0
- package/.nycrc +0 -4
- package/node/mat/cmp-cp-on-delta.d.ts +0 -14
- package/node/mat/cmp-cp-on-delta.js +0 -45
- package/node/mat/cmp-cp-on-delta.js.map +0 -1
- package/node/mat/find-mat/get-total-abs-curvature.d.ts +0 -5
- package/node/mat/find-mat/get-total-abs-curvature.js +0 -13
- package/node/mat/find-mat/get-total-abs-curvature.js.map +0 -1
- package/node/mat/find-mat/get-total-by.d.ts +0 -10
- package/node/mat/find-mat/get-total-by.js +0 -22
- package/node/mat/find-mat/get-total-by.js.map +0 -1
- package/node/mat/get-edges-as-array.d.ts +0 -4
- package/node/mat/get-edges-as-array.js +0 -12
- package/node/mat/get-edges-as-array.js.map +0 -1
- package/node/mat/get-largest-three-prong.d.ts +0 -4
- package/node/mat/get-largest-three-prong.js +0 -13
- package/node/mat/get-largest-three-prong.js.map +0 -1
- package/node/mat/to-scale-axis/add-to-tree.d.ts +0 -13
- package/node/mat/to-scale-axis/add-to-tree.js +0 -39
- package/node/mat/to-scale-axis/add-to-tree.js.map +0 -1
- package/node/mat/to-scale-axis/calc-groups.d.ts +0 -28
- package/node/mat/to-scale-axis/calc-groups.js +0 -66
- package/node/mat/to-scale-axis/calc-groups.js.map +0 -1
- package/node/mat/to-scale-axis/create-spacial-tree.d.ts +0 -9
- package/node/mat/to-scale-axis/create-spacial-tree.js +0 -24
- package/node/mat/to-scale-axis/create-spacial-tree.js.map +0 -1
- package/node/mat/to-scale-axis/get-engulfed-vertices.d.ts +0 -12
- package/node/mat/to-scale-axis/get-engulfed-vertices.js +0 -95
- package/node/mat/to-scale-axis/get-engulfed-vertices.js.map +0 -1
- package/node/mat/to-scale-axis/t-tree.d.ts +0 -6
- package/node/mat/to-scale-axis/t-tree.js +0 -3
- package/node/mat/to-scale-axis/t-tree.js.map +0 -1
- package/node/mat/to-scale-axis/traverse-spacial-tree.d.ts +0 -11
- package/node/mat/to-scale-axis/traverse-spacial-tree.js +0 -25
- package/node/mat/to-scale-axis/traverse-spacial-tree.js.map +0 -1
- package/node/svg/get-curvature-at-interface.d.ts +0 -9
- package/node/svg/get-curvature-at-interface.js +0 -49
- package/node/svg/get-curvature-at-interface.js.map +0 -1
- package/node/svg/get-extreme.d.ts +0 -9
- package/node/svg/get-extreme.js +0 -16
- package/node/svg/get-extreme.js.map +0 -1
- package/node/sweep-line/are-boxes-intersecting.d.ts +0 -11
- package/node/sweep-line/are-boxes-intersecting.js +0 -42
- package/node/sweep-line/are-boxes-intersecting.js.map +0 -1
- package/test/mocha.opts +0 -4
- package/webpack.config.js +0 -25
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
declare let _debug_: Debug;
|
|
3
2
|
|
|
4
3
|
import { drawFs } from 'flo-draw';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { CpNode } from '../../cp-node';
|
|
8
|
-
import { Circle } from '../../circle';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
getObjClosestTo,
|
|
12
|
-
distanceBetween,
|
|
13
|
-
squaredDistanceBetween
|
|
14
|
-
} from 'flo-vector2d';
|
|
15
|
-
|
|
16
|
-
import { TwoProngForDebugging } from '../two-prong-for-debugging';
|
|
17
|
-
import { ElemType_TwoProng } from '../../mat/elem-type-two-prong';
|
|
4
|
+
import { getObjClosestTo, distanceBetween, squaredDistanceBetween } from 'flo-vector2d';
|
|
5
|
+
import { Debug, Generated } from '../debug.js';
|
|
6
|
+
import { CpNode } from '../../cp-node.js';
|
|
7
|
+
import { Circle } from '../../circle.js';
|
|
8
|
+
import { TwoProngForDebugging } from '../two-prong-for-debugging.js';
|
|
9
|
+
import { ElemType_TwoProng } from '../../mat/elem-type-two-prong.js';
|
|
18
10
|
|
|
19
11
|
|
|
20
12
|
/** @hidden */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Generated } from './debug';
|
|
1
|
+
import { CpNode } from '../cp-node.js';
|
|
2
|
+
import { posToHumanString, IPointOnShape } from '../point-on-shape.js';
|
|
3
|
+
import { Circle } from '../circle.js';
|
|
4
|
+
import { Generated } from './debug.js';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Generated } from './debug';
|
|
1
|
+
import { CpNode } from '../cp-node.js';
|
|
2
|
+
import { IPointOnShape } from '../point-on-shape.js';
|
|
3
|
+
import { Circle } from '../circle.js';
|
|
4
|
+
import { BezierPiece } from '../mat/bezier-piece.js';
|
|
5
|
+
import { Generated } from './debug.js';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
/** @hidden */
|
package/src/find-mats.ts
CHANGED
|
@@ -1,69 +1,66 @@
|
|
|
1
|
-
|
|
2
1
|
/** @hidden */
|
|
3
2
|
declare var _debug_: Debug;
|
|
4
3
|
|
|
5
|
-
import {
|
|
6
|
-
import LlRbTree from 'flo-ll-rb-tree';
|
|
4
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
7
5
|
import { simplifyPaths } from 'flo-boolean';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
6
|
+
import { Debug } from './debug/debug.js';
|
|
7
|
+
import { CpNode } from './cp-node.js';
|
|
8
|
+
import { Loop } from './loop.js';
|
|
9
|
+
import { Mat } from './mat.js';
|
|
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';;
|
|
12
|
+
import { addDebugInfo1, addDebugInfo2, addDebugInfo3, addDebugInfo4 } from './mat/find-mat/add-debug-info.js';
|
|
13
|
+
import { getPotential2Prongs } from './mat/find-mat/get-potential-2-prongs.js';
|
|
14
|
+
import { getSharpCorners } from './mat/find-mat/get-sharp-corners.js';
|
|
15
|
+
import { findAndAdd2ProngsOnAllPaths } from './mat/find-mat/find-and-add-2-prongs-on-all-paths.js';
|
|
16
|
+
import { getInterestingPointsOnLoop } from './mat/find-mat/create-get-interesting-points-on-loop.js';
|
|
17
|
+
import { findAndAddHoleClosing2Prongs } from './mat/find-mat/find-and-add-hole-closing-2-prongs.js';
|
|
18
|
+
import { getLoopsMetrics } from './loop/get-max-coordinate.js';
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Finds and returns the Medial Axis Transforms (MATs) from the given array of
|
|
24
23
|
* bezier loops representing shape boundaries.
|
|
24
|
+
*
|
|
25
25
|
* @param bezierLoops An array of (possibly intersecting) loops with each loop
|
|
26
26
|
* representing one or more piecewise smooth closed curves (i.e. shapes). Each
|
|
27
27
|
* loop consists of an array of beziers represented by an array of control
|
|
28
28
|
* points with 2,3 or 4 elements corresponding to linear, quadratic and cubic
|
|
29
29
|
* beziers respectively. Each point is a two-element array (ordered pair), the
|
|
30
30
|
* first of which is the x-coordinate and the second the y-coordinate.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* @param maxCurviness The maximum value the 'curviness' of a curve can have
|
|
33
|
+
* before an additional MAT point is inserted in between. Defaults to 0.4.
|
|
34
|
+
* (Curviness is measured as the total angle in radians between the consecutive
|
|
35
|
+
* vectors formed by the ordered control points of th bezier curve). The value
|
|
36
|
+
* is clipped in the range `[0.05,3]`.
|
|
35
37
|
* @param maxLength The maximum length a curve can have before an additional MAT
|
|
36
|
-
* point is
|
|
37
|
-
* grid (e.g. if the shape fits in a 512 x 512 axis-aligned box the will be
|
|
38
|
-
* halved, e.g. from 10 to 5). Together with
|
|
38
|
+
* point is inserted. This value is scaled to a reference 1024 x 1024
|
|
39
|
+
* grid (e.g. if the shape fits in a 512 x 512 axis-aligned box the value will be
|
|
40
|
+
* halved, e.g. from 10 to 5). Together with maxCurviness it represents a
|
|
39
41
|
* tolerance for the accuracy of the MAT. Defaults to 4. The value is clipped
|
|
40
42
|
* in [1,100].
|
|
41
43
|
*/
|
|
42
44
|
function findMats(
|
|
43
45
|
bezierLoops: number[][][][],
|
|
44
|
-
|
|
46
|
+
maxCurviness = 0.4,
|
|
45
47
|
maxLength = 4): Mat[] {
|
|
46
48
|
|
|
47
49
|
if (typeof _debug_ !== 'undefined') { var timingStart = performance.now(); }
|
|
48
50
|
|
|
49
51
|
let maxCoordinate: number;
|
|
50
52
|
let minBezLength: number;
|
|
51
|
-
({
|
|
52
|
-
getSizeParams(bezierLoops,
|
|
53
|
+
({ maxCurviness, maxLength, maxCoordinate, minBezLength } =
|
|
54
|
+
getSizeParams(bezierLoops, maxCurviness, maxLength));
|
|
53
55
|
|
|
54
56
|
let loopss = simplifyPaths(bezierLoops, maxCoordinate);
|
|
55
57
|
|
|
56
|
-
if (typeof _debug_ !== 'undefined') {
|
|
57
|
-
let timing = _debug_.generated.timing;
|
|
58
|
-
timing.simplifyPaths = performance.now() - timingStart;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
58
|
let mats: Mat[] = [];
|
|
62
59
|
for (let loops of loopss) {
|
|
63
60
|
let mat = findMat(
|
|
64
61
|
loops,
|
|
65
62
|
minBezLength,
|
|
66
|
-
|
|
63
|
+
maxCurviness,
|
|
67
64
|
maxLength,
|
|
68
65
|
maxCoordinate
|
|
69
66
|
);
|
|
@@ -76,7 +73,7 @@ function findMats(
|
|
|
76
73
|
|
|
77
74
|
function getSizeParams(
|
|
78
75
|
bezierLoops: number[][][][],
|
|
79
|
-
|
|
76
|
+
maxCurviness: number,
|
|
80
77
|
maxLength: number) {
|
|
81
78
|
|
|
82
79
|
// Gather some shape metrics
|
|
@@ -90,8 +87,8 @@ function getSizeParams(
|
|
|
90
87
|
let minBezLength = 2**expMax * 2**(-minBezLengthSigBits);
|
|
91
88
|
|
|
92
89
|
// Limit the tolerance to a reasonable level
|
|
93
|
-
if (
|
|
94
|
-
if (
|
|
90
|
+
if (maxCurviness < 0.05) { maxCurviness = 0.05; }
|
|
91
|
+
if (maxCurviness > 3 ) { maxCurviness = 3; }
|
|
95
92
|
// Limit the tolerance to a reasonable level
|
|
96
93
|
if (maxLength < 0.1) { maxLength = 0.1; }
|
|
97
94
|
if (maxLength > 100) { maxLength = 100; }
|
|
@@ -100,7 +97,7 @@ function getSizeParams(
|
|
|
100
97
|
let maxLengthSigBits = 10; // 1024 x 1024
|
|
101
98
|
maxLength = maxLength * (2**expMaxRadius * 2**(-maxLengthSigBits));
|
|
102
99
|
|
|
103
|
-
return {
|
|
100
|
+
return { maxCurviness, maxLength, maxCoordinate, minBezLength };
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
|
|
@@ -109,13 +106,11 @@ function getSizeParams(
|
|
|
109
106
|
* Find the MAT of the given loops.
|
|
110
107
|
* @param loops The loops (that as a precondition must be ordered from highest
|
|
111
108
|
* (i.e. smallest y-value) topmost point loops to lowest)
|
|
112
|
-
* @param xMap Intersection point map.
|
|
113
|
-
* @param additionalPointCount
|
|
114
109
|
*/
|
|
115
110
|
function findMat(
|
|
116
111
|
loops: Loop[],
|
|
117
112
|
minBezLength: number,
|
|
118
|
-
|
|
113
|
+
maxCurviness: number,
|
|
119
114
|
maxLength: number,
|
|
120
115
|
maxCoordinate: number): Mat {
|
|
121
116
|
|
|
@@ -124,7 +119,7 @@ function findMat(
|
|
|
124
119
|
// Gets interesting points on the shape, i.e. those that makes sense to use
|
|
125
120
|
// for the 2-prong procedure.
|
|
126
121
|
let pointsPerLoop = loops.map(
|
|
127
|
-
getInterestingPointsOnLoop(minBezLength,
|
|
122
|
+
getInterestingPointsOnLoop(minBezLength, maxCurviness, maxLength)
|
|
128
123
|
);
|
|
129
124
|
|
|
130
125
|
let for2ProngsPerLoop = getPotential2Prongs(pointsPerLoop);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Curve } from './curve';
|
|
1
|
+
import { BezierPiece } from 'flo-bezier3';
|
|
2
|
+
import { CpNode } from './cp-node.js';
|
|
3
|
+
import { Curve } from './curve.js';
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -9,7 +8,7 @@ import { Curve } from './curve';
|
|
|
9
8
|
* on the boundary.
|
|
10
9
|
* @param cpNode
|
|
11
10
|
*/
|
|
12
|
-
function getBoundaryBezierPartsToNext(cpNode: CpNode):
|
|
11
|
+
function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
|
|
13
12
|
let cpThis = cpNode;
|
|
14
13
|
let cpNext = cpNode.next;
|
|
15
14
|
|
|
@@ -25,7 +24,7 @@ function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPart[] {
|
|
|
25
24
|
return undefined;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
let bezierParts:
|
|
27
|
+
let bezierParts: BezierPiece[] = [];
|
|
29
28
|
|
|
30
29
|
if (curveNext === curveThis) {
|
|
31
30
|
bezierParts.push(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
// qqq import { fromTo, fromTTo1, from0ToT } from 'flo-bezier3';
|
|
2
|
+
import { fromTo } from 'flo-bezier3';
|
|
3
|
+
import { CpNode } from './cp-node.js';
|
|
4
|
+
import { Curve } from './curve.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -29,11 +29,11 @@ function getBoundaryBeziersToNext(cpNode: CpNode) {
|
|
|
29
29
|
|
|
30
30
|
if (curveNext === curveThis) {
|
|
31
31
|
beziers.push(
|
|
32
|
-
fromTo(posThis.curve.ps
|
|
32
|
+
fromTo(posThis.curve.ps, posThis.t, posNext.t)
|
|
33
33
|
);
|
|
34
34
|
} else {
|
|
35
35
|
beziers.push(
|
|
36
|
-
|
|
36
|
+
fromTo(posThis.curve.ps, posThis.t, 1)
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
addSkippedBeziers(
|
|
@@ -63,7 +63,8 @@ function addSkippedBeziers(
|
|
|
63
63
|
curveThis = curveThis.next;
|
|
64
64
|
let tEnd = curveThis === curveEnd ? t1 : 1;
|
|
65
65
|
beziers.push(
|
|
66
|
-
from0ToT(curveThis.ps, tEnd)
|
|
66
|
+
// qqq from0ToT(curveThis.ps, tEnd)
|
|
67
|
+
fromTo(curveThis.ps, 0, tEnd)
|
|
67
68
|
);
|
|
68
69
|
} while (curveThis !== curveEnd);
|
|
69
70
|
}
|
package/src/get-branches.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { CpNode } from './cp-node';
|
|
3
1
|
import { tangent } from 'flo-bezier3';
|
|
4
2
|
import { cross, toUnitVector } from 'flo-vector2d';
|
|
5
|
-
import {
|
|
3
|
+
import { CpNode } from './cp-node.js';
|
|
4
|
+
import { getCurveToNext } from './get-curve-to-next.js';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
/** @hidden */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
2
|
fromTo, dot, cross, rotate90Degrees, interpolate, translate,
|
|
4
3
|
lineLineIntersection
|
|
5
4
|
} from 'flo-vector2d';
|
|
6
|
-
import { CpNode } from '../cp-node';
|
|
7
|
-
import { getEdgeDirection } from './get-edge-direction';
|
|
5
|
+
import { CpNode } from '../cp-node.js';
|
|
6
|
+
import { getEdgeDirection } from './get-edge-direction.js';
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
/** @hidden */
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
2
|
toUnitVector, fromTo, rotate, translate, rotate90Degrees, reverse, dot
|
|
4
3
|
} from 'flo-vector2d';
|
|
5
|
-
|
|
6
4
|
import { tangent } from 'flo-bezier3';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { isPosSharpCorner } from '../point-on-shape';
|
|
5
|
+
import { CpNode } from '../cp-node.js';
|
|
6
|
+
import { isPosSharpCorner } from '../point-on-shape.js';
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
/**
|
package/src/get-curve-to-next.ts
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { orient2d } from 'big-float-ts';
|
|
2
|
+
import { dot } from "flo-vector2d";
|
|
3
|
+
import { compareCurvaturesAtInterface } from "./compare-curvatures-at-interface.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a positive value if the second bezier (of order 1, 2 or 3) curves
|
|
8
|
+
* anti-clockwise with respect to the first at the point where the first bezier
|
|
9
|
+
* ends and the second one starts. Returns a negative number if the turn is
|
|
10
|
+
* clockwise. Returns 0 otherwise.
|
|
11
|
+
*
|
|
12
|
+
* The algorithm is a generalization of `ccw`, a.k.a `orient2d`.
|
|
13
|
+
*
|
|
14
|
+
* The above obviously necessitates that their endpoints coincide as described.
|
|
15
|
+
*
|
|
16
|
+
* Preconditions (for robustness):
|
|
17
|
+
* * The beziers has control points with max bit-length of 25 and bit-aligned.
|
|
18
|
+
* * The bezier does not have infinite curvature at either endpoint
|
|
19
|
+
*
|
|
20
|
+
* This is so the vectors between control points can be
|
|
21
|
+
* calculated exactly without resorting to adaptive infinite precision floating
|
|
22
|
+
* point operations. Note: aligned to 'grid' here means if you bitwise-and all
|
|
23
|
+
* values together the resulting bitlength === the max bithlength of any value.
|
|
24
|
+
*
|
|
25
|
+
* @param psI The incoming bezier that ends at the interface
|
|
26
|
+
* @param psO The outgoing bezier that starts at the interface
|
|
27
|
+
*/
|
|
28
|
+
// TODO - improve and make at least 46-bitlength precondition
|
|
29
|
+
function getInterfaceCcw(psI: number[][], psO: number[][]) {
|
|
30
|
+
let lenI = psI.length;
|
|
31
|
+
|
|
32
|
+
// second last control point of incoming curve
|
|
33
|
+
let p0 = psI[lenI-2];
|
|
34
|
+
// last control point of incoming curve / first control point of outgoing
|
|
35
|
+
let p1 = psO[0];
|
|
36
|
+
// second control point of outgoing curve
|
|
37
|
+
let p2 = psO[1];
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
if (typeof _bez_debug_ !== 'undefined') {
|
|
41
|
+
let maxBitLength = 25;
|
|
42
|
+
let p1_ = psI[lenI-1];
|
|
43
|
+
// ---- precondition: does endpoints coincide
|
|
44
|
+
if (p1_[0] !== p1[0] || p1_[1] !== p1[1]) {
|
|
45
|
+
throw new Error('Curve endpoints must coincide.');
|
|
46
|
+
}
|
|
47
|
+
// ---- precondition: are coordinates grid-aligned
|
|
48
|
+
// Get all coordinate values into an array
|
|
49
|
+
let xs: number[] = [];
|
|
50
|
+
[psI, psO].forEach(ps => ps.forEach(p => p.forEach(x => {
|
|
51
|
+
xs.push(x);
|
|
52
|
+
})));
|
|
53
|
+
|
|
54
|
+
let msb = xs.reduce((prevX, x) => Math.max(prevX, msbExponent(x)), Number.NEGATIVE_INFINITY);
|
|
55
|
+
let lsb = xs.reduce((prevX, x) => Math.min(prevX, lsbExponent(x)), Number.POSITIVE_INFINITY);
|
|
56
|
+
let bitlengthAll = msb - lsb + 1;
|
|
57
|
+
if (bitlengthAll > maxBitLength) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Curve control point coordinates must be bit-aligned and <= ${maxBitLength}. bitlength === ${bitlengthAll}, coordinates: ${xs}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
// Max one bit can be added in the calculations below due to bit-alignment
|
|
66
|
+
let xE = p1[0] - p0[0]; // tangent x-coordinate
|
|
67
|
+
let yE = p1[1] - p0[1]; // tangent y-coordinate
|
|
68
|
+
let xS = p2[0] - p1[0]; // tangent x-coordinate
|
|
69
|
+
let yS = p2[1] - p1[1]; // tangent y-coordinate
|
|
70
|
+
|
|
71
|
+
// If the tangent is to be found at t === 0 or t === 1 then using a basic
|
|
72
|
+
// property of bezier curves we can find the tangents easily as below
|
|
73
|
+
|
|
74
|
+
// (non-normalized) tangent of incoming curve at t === 1
|
|
75
|
+
let tangentAtEnd = [xE,yE];
|
|
76
|
+
// (non-normalized) tangent of outgoing curve at t === 0
|
|
77
|
+
let tangentAtStart = [xS,yS];
|
|
78
|
+
|
|
79
|
+
// The cross calculated below will have a max bitlength of
|
|
80
|
+
// (2*(maxBitLength+1))+1 === e.g. (2*(25+1)) + 1 === 53
|
|
81
|
+
// If the preconditions are met it is exact
|
|
82
|
+
//let crossTangents = cross(tangentAtEnd, tangentAtStart);
|
|
83
|
+
|
|
84
|
+
// The cross below is exact by adaptive infinite precision
|
|
85
|
+
let crossTangents = orient2d(p0, p1, p2);
|
|
86
|
+
|
|
87
|
+
if (crossTangents !== 0) {
|
|
88
|
+
return crossTangents;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The dot calculated below will have a max bitlength of
|
|
92
|
+
// (2*(maxBitLength+1))+1 === e.g. (2*(25+1)) + 1 === 53
|
|
93
|
+
// If the preconditions are met it is exact
|
|
94
|
+
let dotTangents = dot(tangentAtEnd, tangentAtStart);
|
|
95
|
+
if (dotTangents > 0) {
|
|
96
|
+
// Curves go in same direction at interface - neither clock or
|
|
97
|
+
// anti-clockwise.
|
|
98
|
+
// Note: The above comment is not strictly true but as this case is not
|
|
99
|
+
// important for the algorithm we return 0
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Curves go in opposite directions at interface starting off with the exact
|
|
104
|
+
// same tangent - look now at curvature to see which has the largest
|
|
105
|
+
// curvature so we can base the clock or anti-clockwise result on that
|
|
106
|
+
|
|
107
|
+
// Look at curvature
|
|
108
|
+
return compareCurvaturesAtInterface(psI.slice().reverse(), psO);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
export { getInterfaceCcw }
|
package/src/index.ts
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
import { Mat } from './mat';
|
|
3
|
-
import { Loop } from './loop';
|
|
4
|
-
import { Curve } from './curve';
|
|
5
|
-
import { CpNode } from './cp-node';
|
|
6
|
-
import { PointOnShape, IPointOnShape } from './point-on-shape';
|
|
7
|
-
import { Circle } from './circle';
|
|
8
|
-
import { ContactPoint } from './contact-point';
|
|
9
|
-
import { BezierPiece } from './mat/bezier-piece';
|
|
10
|
-
|
|
11
|
-
import { findMats } from './find-mats';
|
|
12
|
-
import { trimMat } from './mat/trim-mat';
|
|
13
|
-
import { toScaleAxis } from './to-scale-axis';
|
|
14
|
-
|
|
15
|
-
import { traverseEdges } from './traverse-edges';
|
|
16
|
-
import { getBranches } from './get-branches';
|
|
17
|
-
import { traverseVertices } from './traverse-vertices';
|
|
18
|
-
|
|
19
|
-
import { Debug, enableDebugForMat } from './debug/debug';
|
|
20
|
-
import { drawBranch } from './debug/functions/draw-elem/branch';
|
|
21
|
-
import { drawMat } from './debug/functions/draw-elem/mat';
|
|
22
|
-
|
|
23
|
-
import { IDebugElems } from './debug/debug-elem-types';
|
|
24
|
-
import { TDrawElemFunctions } from './debug/functions/draw-elem/draw-elem';
|
|
25
|
-
|
|
26
|
-
import { ICpNodeForDebugging } from './debug/cp-node-for-debugging';
|
|
27
|
-
|
|
28
|
-
import { ITiming } from './debug/debug';
|
|
29
|
-
|
|
30
|
-
import { getClosestBoundaryPoint } from
|
|
31
|
-
'./mat/closest-boundary-point/get-closest-boundary-point';
|
|
32
|
-
|
|
33
1
|
import { beziersToSvgPathStr, getPathsFromStr } from 'flo-boolean';
|
|
34
|
-
import { getShapeBounds } from './svg/get-shape-bounds';
|
|
35
|
-
|
|
36
|
-
import { getBoundaryBeziersToNext } from './get-boundary-beziers-to-next';
|
|
37
|
-
import { getBoundaryBezierPartsToNext } from './get-boundary-bezier-parts-to-next';
|
|
38
|
-
import { getBoundaryPieceBeziers } from './mat/get-boundary-piece-beziers';
|
|
39
|
-
import { simplifyMat } from './simplify-mat';
|
|
40
|
-
import { simplifyMatMapOnly } from './mat/simplify-mat-map-only';
|
|
41
|
-
|
|
42
|
-
import { drawElemFunctions } from './debug/functions/draw-elem/draw-elem'
|
|
43
2
|
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
3
|
+
import { Mat } from './mat.js';
|
|
4
|
+
import { Loop } from './loop.js';
|
|
5
|
+
import { Curve } from './curve.js';
|
|
6
|
+
import { CpNode } from './cp-node.js';
|
|
7
|
+
import { PointOnShape, IPointOnShape } from './point-on-shape.js';
|
|
8
|
+
import { Circle } from './circle.js';
|
|
9
|
+
import { ContactPoint } from './contact-point.js';
|
|
10
|
+
import { BezierPiece } from './mat/bezier-piece.js';
|
|
11
|
+
import { findMats } from './find-mats.js';
|
|
12
|
+
import { trimMat } from './mat/trim-mat.js';
|
|
13
|
+
import { toScaleAxis } from './to-scale-axis.js';
|
|
14
|
+
import { traverseEdges } from './traverse-edges.js';
|
|
15
|
+
import { getBranches } from './get-branches.js';
|
|
16
|
+
import { traverseVertices } from './traverse-vertices.js';
|
|
17
|
+
import { Debug, enableDebugForMat } from './debug/debug.js';
|
|
18
|
+
import { drawBranch } from './debug/functions/draw-elem/branch.js';
|
|
19
|
+
import { drawMat } from './debug/functions/draw-elem/mat.js';
|
|
20
|
+
import { IDebugElems } from './debug/debug-elem-types.js';
|
|
21
|
+
import { TDrawElemFunctions } from './debug/functions/draw-elem/draw-elem.js';
|
|
22
|
+
import { ICpNodeForDebugging } from './debug/cp-node-for-debugging.js';
|
|
23
|
+
import { ITiming } from './debug/debug.js';
|
|
24
|
+
import { getClosestBoundaryPoint } from './mat/closest-boundary-point/get-closest-boundary-point.js';
|
|
25
|
+
import { getShapeBounds } from './svg/get-shape-bounds.js';
|
|
26
|
+
import { getBoundaryBeziersToNext } from './get-boundary-beziers-to-next.js';
|
|
27
|
+
import { getBoundaryBezierPartsToNext } from './get-boundary-bezier-parts-to-next.js';
|
|
28
|
+
import { getBoundaryPieceBeziers } from './mat/get-boundary-piece-beziers.js';
|
|
29
|
+
import { simplifyMat } from './simplify-mat.js';
|
|
30
|
+
import { simplifyMatMapOnly } from './mat/simplify-mat-map-only.js';
|
|
31
|
+
import { drawElemFunctions } from './debug/functions/draw-elem/draw-elem.js';
|
|
32
|
+
import { getCurveToNext } from './get-curve-to-next.js';
|
|
33
|
+
import { getCurveBetween } from './get-curve/get-curve-between.js';
|
|
34
|
+
import { sweepLine } from './sweep-line/sweep-line.js';
|
|
35
|
+
import { getClosestSquareDistanceToRect } from './mat/geometry/get-closest-square-distance-to-rect.js';
|
|
36
|
+
import { loopFromBeziers } from './loop.js';
|
|
50
37
|
|
|
51
38
|
|
|
52
39
|
export {
|
|
@@ -96,7 +83,6 @@ export {
|
|
|
96
83
|
drawElemFunctions,
|
|
97
84
|
|
|
98
85
|
sweepLine,
|
|
99
|
-
areBoxesIntersecting,
|
|
100
86
|
|
|
101
87
|
getClosestSquareDistanceToRect,
|
|
102
88
|
|
package/src/loop.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { getNeighbouringPoints } from './get-neighboring-cps';
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { Loop } from '../loop.js';
|
|
3
|
+
import { Circle } from '../circle.js';
|
|
4
|
+
import { ContactPoint } from '../contact-point.js';
|
|
5
|
+
import { IPointOnShape } from '../point-on-shape.js';
|
|
6
|
+
import { CpNode } from '../cp-node.js';
|
|
7
|
+
import { getNeighbouringPoints } from './get-neighboring-cps.js';
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
/**
|
package/src/mat/bezier-piece.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
// qqq import { deflateQuad, allRootsMultiWithErrBounds, RootInterval } from 'flo-poly';
|
|
2
|
+
// qqq import { getTangentPolyFromPointExact, evalDeCasteljau, evaluate, getFootpointPolyExact } from 'flo-bezier3';
|
|
3
|
+
import { ddDeflate, allRootsCertified, RootInterval } from 'flo-poly';
|
|
4
|
+
import { evalDeCasteljau, evaluate, getFootpointPolyDd, getFootpointPolyExact } from 'flo-bezier3';
|
|
5
|
+
import { Curve } from "../../curve.js";
|
|
6
|
+
import { eToDd } from 'big-float-ts';
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -17,22 +19,22 @@ function closestPointsOnCurve(
|
|
|
17
19
|
p: number[],
|
|
18
20
|
[tS,tE]: number[] = [0,1],
|
|
19
21
|
touchedCurve: Curve,
|
|
20
|
-
t: number) {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
t: number): {
|
|
23
|
+
p: number[];
|
|
24
|
+
t: number;
|
|
25
|
+
}[] {
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
+
// qqq let poly = getTangentPolyFromPointExact(curve.ps, p);
|
|
28
|
+
const _poly = getFootpointPolyDd(curve.ps, p);
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
tS,
|
|
33
|
-
tE
|
|
34
|
-
);
|
|
30
|
+
// qqq poly = deflateQuad(poly, t);
|
|
31
|
+
const poly = curve === touchedCurve
|
|
32
|
+
? ddDeflate(_poly, t)
|
|
33
|
+
: _poly;
|
|
35
34
|
|
|
35
|
+
// let roots: Omit<RootInterval,'multiplicity'>[] = allRootsMultiWithErrBounds(
|
|
36
|
+
let roots: Omit<RootInterval,'multiplicity'>[];
|
|
37
|
+
roots = allRootsCertified(poly, tS, tE);
|
|
36
38
|
|
|
37
39
|
// Also test the endpoints
|
|
38
40
|
let push0 = true;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { cullByTightBoundingBox } from "./cull-by-tight-boundary-box";
|
|
1
|
+
import { BezierPiece } from '../bezier-piece.js';
|
|
2
|
+
import { getBestDistanceSquared } from './get-best-distance-squared.js';
|
|
3
|
+
import { cullByLooseBoundingBox } from './cull-by-loose-bounding-box.js';
|
|
4
|
+
import { cullByTightBoundingBox } from './cull-by-tight-boundary-box.js';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
/**
|