flo-mat 4.1.4 → 5.0.1
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/__tests__/closest-boundary-point/get-endpoint-info.spec.ts +140 -0
- package/__tests__/closest-boundary-point/root-interval-to-distance-squared-interval.spec.ts +87 -0
- package/__tests__/cp-node/circle-identity.spec.ts +56 -0
- package/__tests__/cp-node/fs/get-all-on-loop-by-loop.spec.ts +55 -0
- package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +39 -3
- package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +87 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +41 -3
- package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +20 -3
- package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +42 -3
- package/__tests__/cp-node/fs/get-branch.spec.ts +60 -3
- package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +19 -3
- package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +37 -4
- package/__tests__/cp-node/fs/get-edge-direction.spec.ts +50 -3
- package/__tests__/cp-node/fs/get-first-exit.spec.ts +78 -3
- package/__tests__/cp-node/fs/get-hole-closers.spec.ts +32 -3
- package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +48 -3
- package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +77 -3
- package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +17 -4
- package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +38 -3
- package/__tests__/cp-node/fs/get-salience.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +40 -3
- package/__tests__/cp-node/fs/insert-cp-node.spec.ts +87 -3
- package/__tests__/cp-node/fs/is-special.spec.ts +1 -1
- package/__tests__/cp-node/fs/remove-cp-node.spec.ts +42 -3
- package/__tests__/find-2-prong/calc-seperation-tolerance.spec.ts +46 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +7 -5
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +4 -2
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +1 -1
- package/__tests__/floyd-warshall/get-graph.spec.ts +100 -0
- package/__tests__/get-mats-with-hole.ts +28 -0
- package/__tests__/get-mats1.spec.ts +61 -0
- package/__tests__/get-mats1.ts +75 -67
- package/__tests__/helpers/cp-node-by-id.ts +27 -0
- package/__tests__/helpers/expect-point-close.ts +42 -0
- package/__tests__/mat/hausdorff-distance-one-sided-exceeds.spec.ts +129 -0
- package/__tests__/mat/simplify-mat.spec.ts +85 -0
- package/__tests__/reconstruct-from-mat/reconstruct-from-mat.spec.ts +39 -0
- package/__tests__/specific-cases/test-svgs/achispado.svg +14 -0
- package/__tests__/utils/get-beziers-from-tangents.spec.ts +142 -0
- package/browser/index.js +17882 -13800
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js +3 -2
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/cull-curve-pieces.d.ts +21 -0
- package/node/closest-boundary-point/cull-curve-pieces.js +40 -0
- package/node/closest-boundary-point/cull-curve-pieces.js.map +1 -0
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +5 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/closest-boundary-point/get-endpoint-info.d.ts +39 -0
- package/node/closest-boundary-point/get-endpoint-info.js +78 -0
- package/node/closest-boundary-point/get-endpoint-info.js.map +1 -0
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +5 -19
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +17 -5
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +37 -50
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
- package/node/corner/get-corner.d.ts +18 -1
- package/node/corner/get-corner.js +8 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node.d.ts +4 -3
- package/node/cp-node/fs/enhance-cp-node.d.ts +9 -9
- package/node/cp-node/fs/get-all-on-loop-by-loop.js +0 -4
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.d.ts +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.js +7 -4
- package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-between.d.ts +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.d.ts +2 -1
- package/node/cp-node/fs/get-branch-beziers.js +3 -2
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js +1 -2
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-distance-to-next.js +4 -2
- package/node/cp-node/fs/get-distance-to-next.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.js +3 -2
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.d.ts +7 -3
- package/node/cp-node/fs/get-first-exit.js +13 -11
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +10 -2
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js +11 -54
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.d.ts +5 -3
- package/node/cp-node/fs/get-mat-curve-between.js +6 -49
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.d.ts +1 -1
- package/node/cp-node/fs/get-mat-curves-between.d.ts +8 -0
- package/node/cp-node/fs/get-mat-curves-between.js +9 -2
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.d.ts +2 -1
- package/node/cp-node/fs/get-real-prong-count.js +11 -5
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-salience.d.ts +10 -0
- package/node/cp-node/fs/get-salience.js +17 -1
- package/node/cp-node/fs/get-salience.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +4 -2
- package/node/cp-node/fs/is-fully-terminating.js +6 -17
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-on-same-circle.d.ts +3 -0
- package/node/cp-node/fs/is-on-same-circle.js +4 -4
- package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
- package/node/cp-node/fs/is-on-same-loop.d.ts +1 -1
- package/node/cp-node/fs/is-special.d.ts +7 -0
- package/node/cp-node/fs/is-special.js +9 -2
- package/node/cp-node/fs/is-special.js.map +1 -1
- package/node/cp-node/fs/is-vertex.d.ts +1 -1
- package/node/cp-node/fs/traverse-edges.d.ts +7 -3
- package/node/cp-node/fs/traverse-edges.js +7 -3
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/stringification/from-stringifyable.d.ts +2 -2
- package/node/cp-node/stringification/from-stringifyable.js +17 -1
- package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
- package/node/cp-node/stringification/to-stringifyable.d.ts +3 -3
- package/node/cp-node/stringification/to-stringifyable.js +3 -3
- package/node/debug/debug.d.ts +26 -3
- package/node/debug/debug.js +16 -5
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/add-2-prong.js +7 -9
- package/node/find-2-prong/add-2-prong.js.map +1 -1
- package/node/find-2-prong/calc-seperation-tolerance.d.ts +28 -5
- package/node/find-2-prong/calc-seperation-tolerance.js +32 -89
- package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +8 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-and-add-2-prongs.js +2 -2
- package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -2
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -3
- package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
- package/node/find-2-prong/get-medial/get-closest-points.d.ts +1 -8
- package/node/find-2-prong/get-medial/get-closest-points.js +4 -40
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +1 -1
- package/node/find-2-prong/reduce-radius.js +6 -3
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -1
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +3 -2
- package/node/find-3-prong/find-3-prong-for-delta3s.js +36 -42
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js +3 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs.js +16 -0
- package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
- package/node/find-mat/create-initial-cp-tree.js +2 -2
- package/node/find-mat/create-initial-cp-tree.js.map +1 -1
- package/node/find-mat/find-mat.js +3 -4
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.d.ts +6 -12
- package/node/find-mat/find-mats.js +10 -27
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +2 -2
- package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
- package/node/find-mat/get-for-1-prongs-on-loop.js +36 -8
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +14 -4
- package/node/find-mat/get-meta.js +30 -24
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +2 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/find-mat/mat-options.d.ts +2 -2
- package/node/floyd-warshall/get-graph.d.ts +12 -1
- package/node/floyd-warshall/get-graph.js +41 -38
- package/node/floyd-warshall/get-graph.js.map +1 -1
- package/node/geometry/get-bounding-box-.d.ts +16 -2
- package/node/geometry/get-bounding-box-.js +5 -2
- package/node/geometry/get-bounding-box-.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.d.ts +3 -0
- package/node/geometry/get-closest-square-distance-to-rect.js +7 -5
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +4 -0
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +12 -5
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +1 -2
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -1
- package/node/index.d.ts +3 -2
- package/node/index.js +2 -1
- package/node/index.js.map +1 -1
- package/node/mat/clone-mat.d.ts +9 -0
- package/node/mat/clone-mat.js +17 -0
- package/node/mat/clone-mat.js.map +1 -0
- package/node/mat/clone-meta.d.ts +12 -0
- package/node/mat/clone-meta.js +24 -0
- package/node/mat/clone-meta.js.map +1 -0
- package/node/mat/get-boundary-piece-beziers.d.ts +5 -0
- package/node/mat/get-boundary-piece-beziers.js +7 -93
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-closeby-cp-if-exist.js +2 -1
- package/node/mat/get-closeby-cp-if-exist.js.map +1 -1
- package/node/mat/get-largest-3-prong.d.ts +6 -0
- package/node/mat/get-largest-3-prong.js +8 -5
- package/node/mat/get-largest-3-prong.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +15 -1
- package/node/mat/get-largest-vertex.js +20 -7
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/hausdorff-distance-one-sided-exceeds.d.ts +79 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js +251 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js.map +1 -0
- package/node/mat/mat-meta.d.ts +0 -6
- package/node/mat/simplify-mat.d.ts +25 -8
- package/node/mat/simplify-mat.js +182 -53
- package/node/mat/simplify-mat.js.map +1 -1
- package/node/mat/trim-mat.d.ts +4 -2
- package/node/mat/trim-mat.js +3 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/point-on-shape/get-boundary-tangent-line.d.ts +19 -0
- package/node/point-on-shape/get-boundary-tangent-line.js +33 -0
- package/node/point-on-shape/get-boundary-tangent-line.js.map +1 -0
- package/node/point-on-shape/get-osculating-circle.d.ts +6 -4
- package/node/point-on-shape/get-osculating-circle.js +6 -4
- package/node/point-on-shape/get-osculating-circle.js.map +1 -1
- package/node/point-on-shape/get-pos-corner.js +2 -2
- package/node/point-on-shape/get-pos-corner.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +5 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +20 -80
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
- package/node/sat/cull.d.ts +7 -6
- package/node/sat/cull.js +13 -16
- package/node/sat/cull.js.map +1 -1
- package/node/sat/get-sat-culls.d.ts +12 -2
- package/node/sat/get-sat-culls.js +21 -16
- package/node/sat/get-sat-culls.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +1 -12
- package/node/svg/get-shape-bounds.js +2 -3
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/utils/get-beziers-from-tangents.d.ts +28 -0
- package/node/utils/get-beziers-from-tangents.js +92 -0
- package/node/utils/get-beziers-from-tangents.js.map +1 -0
- package/node/vertex/remove-vertex.d.ts +5 -3
- package/node/vertex/remove-vertex.js +5 -3
- package/node/vertex/remove-vertex.js.map +1 -1
- package/package.json +16 -16
- package/qv-infinite-loop.md +120 -0
- package/src/add-n-prong.ts/join-spokes.ts +4 -2
- package/src/closest-boundary-point/cull-curve-pieces.ts +49 -0
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -2
- package/src/closest-boundary-point/get-endpoint-info.ts +96 -0
- package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +5 -23
- package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +42 -60
- package/src/corner/get-corner.ts +10 -1
- package/src/corner/get-interface-ccw.ts +2 -2
- package/src/cp-node/cp-node.ts +4 -3
- package/src/cp-node/fs/get-all-on-loop-by-loop.ts +0 -4
- package/src/cp-node/fs/get-angle-between-mat-curves.ts +9 -5
- package/src/cp-node/fs/get-boundary-beziers-between.ts +10 -8
- package/src/cp-node/fs/get-branch-beziers.ts +3 -2
- package/src/cp-node/fs/get-branch.ts +1 -2
- package/src/cp-node/fs/get-distance-to-next.ts +4 -2
- package/src/cp-node/fs/get-edge-direction.ts +4 -2
- package/src/cp-node/fs/get-first-exit.ts +15 -14
- package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +18 -70
- package/src/cp-node/fs/get-mat-curve-between.ts +10 -67
- package/src/cp-node/fs/get-mat-curves-between.ts +9 -2
- package/src/cp-node/fs/get-real-prong-count.ts +11 -7
- package/src/cp-node/fs/get-salience.ts +15 -2
- package/src/cp-node/fs/is-fully-terminating.ts +6 -22
- package/src/cp-node/fs/is-on-same-circle.ts +6 -7
- package/src/cp-node/fs/is-on-same-loop.ts +2 -2
- package/src/cp-node/fs/is-special.ts +11 -6
- package/src/cp-node/fs/is-vertex.ts +1 -1
- package/src/cp-node/fs/traverse-edges.ts +8 -4
- package/src/cp-node/stringification/from-stringifyable.ts +75 -58
- package/src/cp-node/stringification/to-stringifyable.ts +3 -3
- package/src/debug/debug.ts +44 -8
- package/src/find-2-prong/add-2-prong.ts +9 -11
- package/src/find-2-prong/calc-seperation-tolerance.ts +34 -115
- package/src/find-2-prong/find-2-prong.ts +9 -11
- package/src/find-2-prong/find-and-add-2-prongs.ts +2 -2
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +1 -3
- package/src/find-2-prong/get-medial/get-closest-points.ts +6 -51
- package/src/find-2-prong/reduce-radius.ts +6 -4
- package/src/find-3-prong/calc-better-x.ts +2 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +197 -214
- package/src/find-3-prong/find-3-prong.ts +54 -51
- package/src/find-3-prong/find-and-add-3-prongs.ts +20 -1
- package/src/find-mat/create-initial-cp-tree.ts +2 -2
- package/src/find-mat/find-mat.ts +4 -6
- package/src/find-mat/find-mats.ts +83 -105
- package/src/find-mat/get-dull-corners-on-loop.ts +2 -2
- package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -8
- package/src/find-mat/get-meta.ts +34 -39
- package/src/find-mat/get-sharp-corners.ts +2 -2
- package/src/find-mat/mat-options.ts +2 -2
- package/src/floyd-warshall/get-graph.ts +46 -47
- package/src/geometry/get-bounding-box-.ts +5 -2
- package/src/geometry/get-closest-square-distance-to-rect.ts +7 -7
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +15 -13
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +1 -2
- package/src/index.ts +3 -2
- package/src/mat/clone-mat.ts +9 -3
- package/src/mat/clone-meta.ts +8 -0
- package/src/mat/get-boundary-piece-beziers.ts +16 -117
- package/src/mat/get-closeby-cp-if-exist.ts +3 -1
- package/src/mat/get-largest-3-prong.ts +9 -6
- package/src/mat/get-largest-vertex.ts +25 -9
- package/src/mat/hausdorff-distance-one-sided-exceeds.ts +314 -0
- package/src/mat/mat-meta.ts +0 -9
- package/src/mat/simplify-mat.ts +254 -116
- package/src/mat/trim-mat.ts +6 -4
- package/src/point-on-shape/get-boundary-tangent-line.ts +36 -0
- package/src/point-on-shape/get-osculating-circle.ts +7 -5
- package/src/point-on-shape/get-pos-corner.ts +2 -2
- package/src/point-on-shape/point-on-shape.ts +5 -0
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +22 -111
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +4 -0
- package/src/sat/cull.ts +16 -20
- package/src/sat/get-sat-culls.ts +28 -23
- package/src/svg/get-shape-bounds.ts +2 -3
- package/src/sweep-line/sweep-line.ts +1 -1
- package/src/utils/deg-to-rad.ts +4 -2
- package/src/utils/get-beziers-from-tangents.ts +110 -0
- package/src/utils/map-map.ts +1 -1
- package/src/utils/rad-to-deg.ts +4 -1
- package/src/vertex/remove-vertex.ts +5 -3
- package/webpack.config.cjs +7 -2
- package/__tests__/cp-node/fs/get-distance-between.spec.ts +0 -7
- package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +0 -24
- package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +0 -17
- package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +0 -17
- package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +0 -14
- package/node/closest-boundary-point/cull-bezier-pieces-1.d.ts +0 -9
- package/node/closest-boundary-point/cull-bezier-pieces-1.js +0 -17
- package/node/closest-boundary-point/cull-bezier-pieces-1.js.map +0 -1
- package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +0 -13
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js +0 -27
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
- package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +0 -11
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js +0 -27
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
- package/node/cp-node/fs/find-first.d.ts +0 -10
- package/node/cp-node/fs/find-first.js +0 -19
- package/node/cp-node/fs/find-first.js.map +0 -1
- package/node/debug/functions/check-ordering.d.ts +0 -4
- package/node/debug/functions/check-ordering.js +0 -43
- package/node/debug/functions/check-ordering.js.map +0 -1
- package/node/find-2-prong/cull-bezier-pieces.d.ts +0 -13
- package/node/find-2-prong/cull-bezier-pieces.js +0 -43
- package/node/find-2-prong/cull-bezier-pieces.js.map +0 -1
- package/node/floyd-warshall/get-hole-closer-pairs.d.ts +0 -8
- package/node/floyd-warshall/get-hole-closer-pairs.js +0 -27
- package/node/floyd-warshall/get-hole-closer-pairs.js.map +0 -1
- package/node/utils/dual-set.d.ts +0 -27
- package/node/utils/dual-set.js +0 -55
- package/node/utils/dual-set.js.map +0 -1
- package/node/utils/tri-map.d.ts +0 -27
- package/node/utils/tri-map.js +0 -49
- package/node/utils/tri-map.js.map +0 -1
- package/src/closest-boundary-point/cull-bezier-pieces-1.ts +0 -36
- package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +0 -42
- package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +0 -43
- package/src/closest-boundary-point/get-p-from-box.ts +0 -14
- package/src/cp-node/fs/add-distance-from.ts +0 -49
- package/src/cp-node/fs/get-distance-between.ts +0 -16
- package/src/cp-node/fs/get-terminating-on-circle.ts +0 -24
- package/src/cp-node/fs/is-single-3-prong.ts +0 -15
- package/src/cp-node/fs/iterate-all-on-loop.ts +0 -15
- package/src/cp-node/fs/traverse-all-forward.ts +0 -24
- package/src/debug/functions/draw/draw-beziers-as-single-path.ts +0 -40
- package/src/debug/functions/draw/draw-disk.ts +0 -34
- package/src/debug/functions/draw/xmlns.ts +0 -5
- package/src/find-2-prong/cull-bezier-pieces.ts +0 -61
- package/src/find-2-prong/find-and-add-2-prong.ts +0 -30
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +0 -213
- package/src/find-2-prong/x-for-debugging.ts +0 -13
- package/src/floyd-warshall/get-hole-closer-pairs.ts +0 -35
- package/src/mat/get-two-prong-type.ts +0 -13
- package/src/point-on-shape/is-pos-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-sharp-corner.ts +0 -18
- package/src/point-on-shape/pos-to-human-string.ts +0 -18
- package/src/sweep-line/are-boxes-intersecting.ts +0 -37
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { closestPointOnBezier, controlPointLinesLength, evalDeCasteljau, fromTo } from 'flo-bezier3';
|
|
2
|
+
|
|
3
|
+
const { max, sqrt } = Math;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A point `q` on a piecewise bezier curve at parameter `t` of piece `k`
|
|
8
|
+
* together with its distance `d` to some other point.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
interface Foot {
|
|
13
|
+
d: number;
|
|
14
|
+
q: number[];
|
|
15
|
+
k: number;
|
|
16
|
+
t: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the closest point on the piecewise bezier curve given by `curves`
|
|
22
|
+
* to the point `p` (as a `Foot`), i.e. the piece-wise minimum of the
|
|
23
|
+
* (certified) `closestPointOnBezier` of `flo-bezier3`.
|
|
24
|
+
*
|
|
25
|
+
* @param p the point
|
|
26
|
+
* @param curves the pieces of the piecewise bezier curve
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
function closestPointOnCurves(
|
|
31
|
+
p: number[],
|
|
32
|
+
curves: number[][][]): Foot {
|
|
33
|
+
|
|
34
|
+
let best: Foot = { d: Infinity, q: p, k: 0, t: 0 };
|
|
35
|
+
for (let k=0; k<curves.length; k++) {
|
|
36
|
+
const c = closestPointOnBezier(curves[k], p);
|
|
37
|
+
if (c.d < best.d) {
|
|
38
|
+
best = { d: c.d, q: c.p, k, t: c.t };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return best;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Returns the distance from the point `p` to the piecewise bezier curve given
|
|
48
|
+
* by `curves` (i.e. the minimum over the pieces of the distance to the piece).
|
|
49
|
+
*
|
|
50
|
+
* @param p the point
|
|
51
|
+
* @param curves the pieces of the piecewise bezier curve
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
function distanceToCurves(
|
|
56
|
+
p: number[],
|
|
57
|
+
curves: number[][][]): number {
|
|
58
|
+
|
|
59
|
+
return closestPointOnCurves(p, curves).d;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Evaluates the bezier curve `ps` (of order 1, 2 or 3) and its first two
|
|
65
|
+
* derivatives at `t`, returned as `[B, B', B'']`.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
function evalWithDerivatives(
|
|
70
|
+
ps: number[][],
|
|
71
|
+
t: number): [number[], number[], number[]] {
|
|
72
|
+
|
|
73
|
+
const [p0, p1] = ps;
|
|
74
|
+
|
|
75
|
+
if (ps.length === 2) {
|
|
76
|
+
return [
|
|
77
|
+
[p0[0] + t*(p1[0] - p0[0]), p0[1] + t*(p1[1] - p0[1])],
|
|
78
|
+
[p1[0] - p0[0], p1[1] - p0[1]],
|
|
79
|
+
[0, 0]
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const s = 1 - t;
|
|
84
|
+
|
|
85
|
+
if (ps.length === 3) {
|
|
86
|
+
const p2 = ps[2];
|
|
87
|
+
return [
|
|
88
|
+
[s*s*p0[0] + 2*s*t*p1[0] + t*t*p2[0],
|
|
89
|
+
s*s*p0[1] + 2*s*t*p1[1] + t*t*p2[1]],
|
|
90
|
+
[2*(s*(p1[0] - p0[0]) + t*(p2[0] - p1[0])),
|
|
91
|
+
2*(s*(p1[1] - p0[1]) + t*(p2[1] - p1[1]))],
|
|
92
|
+
[2*(p2[0] - 2*p1[0] + p0[0]),
|
|
93
|
+
2*(p2[1] - 2*p1[1] + p0[1])]
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const p2 = ps[2];
|
|
98
|
+
const p3 = ps[3];
|
|
99
|
+
return [
|
|
100
|
+
[s*s*s*p0[0] + 3*s*s*t*p1[0] + 3*s*t*t*p2[0] + t*t*t*p3[0],
|
|
101
|
+
s*s*s*p0[1] + 3*s*s*t*p1[1] + 3*s*t*t*p2[1] + t*t*t*p3[1]],
|
|
102
|
+
[3*(s*s*(p1[0] - p0[0]) + 2*s*t*(p2[0] - p1[0]) + t*t*(p3[0] - p2[0])),
|
|
103
|
+
3*(s*s*(p1[1] - p0[1]) + 2*s*t*(p2[1] - p1[1]) + t*t*(p3[1] - p2[1]))],
|
|
104
|
+
[6*(s*(p2[0] - 2*p1[0] + p0[0]) + t*(p3[0] - 2*p2[0] + p1[0])),
|
|
105
|
+
6*(s*(p2[1] - 2*p1[1] + p0[1]) + t*(p3[1] - 2*p2[1] + p1[1]))]
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns a point on piece `k` of `curves` close to `p` found by a few Newton
|
|
112
|
+
* iterations on the squared distance starting from parameter `t0`, as a
|
|
113
|
+
* `Foot`.
|
|
114
|
+
*
|
|
115
|
+
* * the returned distance is thus an *upper bound* on the distance from `p`
|
|
116
|
+
* to the piecewise curve (any point on the curve gives one) - it is not
|
|
117
|
+
* certified to be the minimum
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
function newtonFoot(
|
|
122
|
+
p: number[],
|
|
123
|
+
curves: number[][][],
|
|
124
|
+
k: number,
|
|
125
|
+
t0: number): Foot {
|
|
126
|
+
|
|
127
|
+
const ps = curves[k];
|
|
128
|
+
if (ps.length === 1) {
|
|
129
|
+
const q = ps[0];
|
|
130
|
+
return { d: sqrt((q[0] - p[0])**2 + (q[1] - p[1])**2), q, k, t: 0 };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let t = t0;
|
|
134
|
+
let [q, dq, ddq] = evalWithDerivatives(ps, t);
|
|
135
|
+
let rx = q[0] - p[0];
|
|
136
|
+
let ry = q[1] - p[1];
|
|
137
|
+
let best: Foot = { d: sqrt(rx*rx + ry*ry), q, k, t };
|
|
138
|
+
|
|
139
|
+
for (let i=0; i<4; i++) {
|
|
140
|
+
// minimize g(t) = |B(t) - p|²/2: g' = r·B', g'' = B'·B' + r·B''
|
|
141
|
+
const g1 = rx*dq[0] + ry*dq[1];
|
|
142
|
+
const g2 = dq[0]*dq[0] + dq[1]*dq[1] + rx*ddq[0] + ry*ddq[1];
|
|
143
|
+
if (g2 <= 0) { break; }
|
|
144
|
+
|
|
145
|
+
let t_ = t - g1/g2;
|
|
146
|
+
if (t_ < 0) { t_ = 0; } else if (t_ > 1) { t_ = 1; }
|
|
147
|
+
if (t_ === t) { break; }
|
|
148
|
+
t = t_;
|
|
149
|
+
|
|
150
|
+
[q, dq, ddq] = evalWithDerivatives(ps, t);
|
|
151
|
+
rx = q[0] - p[0];
|
|
152
|
+
ry = q[1] - p[1];
|
|
153
|
+
const d = sqrt(rx*rx + ry*ry);
|
|
154
|
+
if (d < best.d) { best = { d, q, k, t }; }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return best;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Returns the maximum distance from the point `q` to the control points of
|
|
163
|
+
* `ps` - an upper bound on the distance from `q` to any point on the bezier
|
|
164
|
+
* curve `ps` (which lies within the convex hull of its control points).
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
function maxDistanceToControlPoints(
|
|
169
|
+
ps: number[][],
|
|
170
|
+
q: number[]): number {
|
|
171
|
+
|
|
172
|
+
let m = 0;
|
|
173
|
+
for (let i=0; i<ps.length; i++) {
|
|
174
|
+
const c = ps[i];
|
|
175
|
+
const dd = (c[0] - q[0])**2 + (c[1] - q[1])**2;
|
|
176
|
+
if (dd > m) { m = dd; }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return sqrt(m);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* An interval `[tS,tE]` of the parameter of the 'from' curve together with
|
|
185
|
+
* the feet (on the 'to' curve) of its endpoints.
|
|
186
|
+
*
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
interface Interval {
|
|
190
|
+
tS: number;
|
|
191
|
+
tE: number;
|
|
192
|
+
fS: Foot;
|
|
193
|
+
fE: Foot;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Returns `true` if the one-sided Hausdorff distance from the bezier curve `A`
|
|
199
|
+
* to the piecewise bezier curve `B` exceeds `tolerance` and `false` otherwise.
|
|
200
|
+
*
|
|
201
|
+
* * this is a *decision procedure* and is thus much cheaper than computing the
|
|
202
|
+
* distance (e.g. via `hausdorffDistanceOneSided` from `flo-bezier3`) and then
|
|
203
|
+
* comparing it: it stops as soon as either a point on `A` further than
|
|
204
|
+
* `tolerance` from `B` is found (a certified *lower* bound exceeding the
|
|
205
|
+
* tolerance) or every piece of `A` is certified to be within `tolerance`
|
|
206
|
+
* (a certified *upper* bound)
|
|
207
|
+
* * `A` is bisected into parameter intervals; the upper bound on an interval
|
|
208
|
+
* `[tS,tE]` is the smaller of
|
|
209
|
+
* * `(hS + hE + L)/2` where `hS`, `hE` are (upper bounds on) the
|
|
210
|
+
* distances from its endpoints to `B` and `L` is the control polygon
|
|
211
|
+
* length of `A` restricted to the interval (an upper bound on its arc
|
|
212
|
+
* length): any point on the interval is within `L` of both endpoints so
|
|
213
|
+
* its distance to `B` is at most `min(hS + l, hE + (L - l))` with `l`
|
|
214
|
+
* the arc length from the start, maximized at `(hS + hE + L)/2`
|
|
215
|
+
* * the maximum distance from the foot (on `B`) of either endpoint to the
|
|
216
|
+
* control points of `A` restricted to the interval (the sub-curve lies
|
|
217
|
+
* within the convex hull of its control points, within which the
|
|
218
|
+
* distance to a fixed point is maximized at a vertex)
|
|
219
|
+
* * the distances from sample points on `A` to `B` are found cheaply by
|
|
220
|
+
* Newton iteration from the feet of the neighboring samples - these are upper
|
|
221
|
+
* bounds (any point on `B` gives one) which suffice for certifying the
|
|
222
|
+
* acceptance of an interval; only when such a bound exceeds the tolerance is
|
|
223
|
+
* the certified (and expensive) closest point computed to decide whether the
|
|
224
|
+
* tolerance is really exceeded
|
|
225
|
+
* * `B` need not be smooth, nor need its pieces be connected
|
|
226
|
+
* * the result is approximate only to the extent that the floating point
|
|
227
|
+
* evaluations are, i.e. a decision is only taken once it is certain up to
|
|
228
|
+
* roundoff
|
|
229
|
+
*
|
|
230
|
+
* @param A the 'from' bezier curve given by its control points
|
|
231
|
+
* @param B the 'to' piecewise bezier curve given as an array of bezier curves
|
|
232
|
+
* @param tolerance the distance to compare against
|
|
233
|
+
* @param maxIterations the maximum number of interval bisections (each
|
|
234
|
+
* costing one cheap closest point calculation) before giving up, in which
|
|
235
|
+
* case `true` is returned (the conservative answer for simplification
|
|
236
|
+
* purposes); defaults to `1000` (curves only just within tolerance may
|
|
237
|
+
* need many bisections, especially where they run nearly parallel to `B`)
|
|
238
|
+
*
|
|
239
|
+
* @internal
|
|
240
|
+
*/
|
|
241
|
+
function hausdorffDistanceOneSidedExceeds(
|
|
242
|
+
A: number[][],
|
|
243
|
+
B: number[][][],
|
|
244
|
+
tolerance: number,
|
|
245
|
+
maxIterations = 1000): boolean {
|
|
246
|
+
|
|
247
|
+
const fS = closestPointOnCurves(A[0], B);
|
|
248
|
+
if (fS.d > tolerance) { return true; }
|
|
249
|
+
const fE = closestPointOnCurves(A[A.length - 1], B);
|
|
250
|
+
if (fE.d > tolerance) { return true; }
|
|
251
|
+
|
|
252
|
+
if (A.length <= 2) {
|
|
253
|
+
// A point or a line: if `B` is a single line (a convex set) the
|
|
254
|
+
// distance is convex along `A` and thus maximal at an endpoint.
|
|
255
|
+
if (A.length === 1 || (B.length === 1 && B[0].length <= 2)) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Depth first; the stack never holds more than about `2*log2(iterations)`
|
|
261
|
+
// intervals.
|
|
262
|
+
const stack: Interval[] = [{ tS: 0, tE: 1, fS, fE }];
|
|
263
|
+
let iterations = 0;
|
|
264
|
+
while (stack.length > 0) {
|
|
265
|
+
const { tS, tE, fS, fE } = stack.pop()!;
|
|
266
|
+
|
|
267
|
+
const ps = tS === 0 && tE === 1 ? A : fromTo(A, tS, tE);
|
|
268
|
+
|
|
269
|
+
// the entire interval is certified within tolerance if either upper
|
|
270
|
+
// bound says so
|
|
271
|
+
if ((fS.d + fE.d + controlPointLinesLength(ps))/2 <= tolerance) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (maxDistanceToControlPoints(ps, fS.q) <= tolerance ||
|
|
275
|
+
maxDistanceToControlPoints(ps, fE.q) <= tolerance) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (iterations++ >= maxIterations) {
|
|
280
|
+
return true; // undecided - be conservative
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const tM = (tS + tE)/2;
|
|
284
|
+
const pM = evalDeCasteljau(A, tM);
|
|
285
|
+
|
|
286
|
+
// a cheap upper bound on the distance from `pM` to `B` - by Newton
|
|
287
|
+
// iteration from the feet of the endpoints
|
|
288
|
+
let fM = newtonFoot(pM, B, fS.k, fS.k === fE.k ? (fS.t + fE.t)/2 : fS.t);
|
|
289
|
+
if (fS.k !== fE.k) {
|
|
290
|
+
const fM_ = newtonFoot(pM, B, fE.k, fE.t);
|
|
291
|
+
if (fM_.d < fM.d) { fM = fM_; }
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (fM.d > tolerance) {
|
|
295
|
+
// possibly exceeds - now get the certified closest point
|
|
296
|
+
fM = closestPointOnCurves(pM, B);
|
|
297
|
+
if (fM.d > tolerance) { return true; }
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// push the half with the larger lower bound last so it is tried first
|
|
301
|
+
if (max(fS.d, fM.d) >= max(fM.d, fE.d)) {
|
|
302
|
+
stack.push({ tS: tM, tE, fS: fM, fE });
|
|
303
|
+
stack.push({ tS, tE: tM, fS, fE: fM });
|
|
304
|
+
} else {
|
|
305
|
+
stack.push({ tS, tE: tM, fS, fE: fM });
|
|
306
|
+
stack.push({ tS: tM, tE, fS: fM, fE });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
export { hausdorffDistanceOneSidedExceeds, distanceToCurves, closestPointOnCurves }
|
package/src/mat/mat-meta.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Loop } from 'flo-boolean';
|
|
2
2
|
import type { CpNode } from '../cp-node/cp-node.js';
|
|
3
|
-
import type { Curve } from 'flo-boolean';
|
|
4
|
-
import type { TriMap } from '../utils/tri-map.js';
|
|
5
3
|
import { RbTree } from 'flo-ll-rb-tree';
|
|
6
4
|
|
|
7
5
|
|
|
@@ -9,13 +7,6 @@ interface MatMeta {
|
|
|
9
7
|
/** The minimum power of 2 such that `2**maxCoordPowerOf2 >= "the max coordinate"` */
|
|
10
8
|
readonly maxCoordPowerOf2: number;
|
|
11
9
|
readonly squaredDiagonalLength: number;
|
|
12
|
-
readonly looseBoundingBoxes: number[][][];
|
|
13
|
-
readonly tightBoundingBoxes: number[][][];
|
|
14
|
-
readonly boundingHulls: number[][][];
|
|
15
|
-
|
|
16
|
-
readonly sharpCorners: Curve[];
|
|
17
|
-
readonly dullCorners: Curve[];
|
|
18
|
-
|
|
19
10
|
readonly loops: Loop[];
|
|
20
11
|
|
|
21
12
|
/**
|