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
|
@@ -3,6 +3,9 @@ import { CpNode } from "../cp-node.js";
|
|
|
3
3
|
* Returns true if the 2 given `CpNode`s are on the same maximal disk
|
|
4
4
|
* circle.
|
|
5
5
|
*
|
|
6
|
+
* * O(1): all `CpNode`s on the same on-circle ring share the same `Circle`
|
|
7
|
+
* object, and no other ring does (see `PointOnShape.circle`)
|
|
8
|
+
*
|
|
6
9
|
* @param cpNode1 A `CpNode`.
|
|
7
10
|
* @param cpNode2 Another `CpNode`
|
|
8
11
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { getAllOnCircle } from "./get-all-on-circle.js";
|
|
2
1
|
/**
|
|
3
2
|
* Returns true if the 2 given `CpNode`s are on the same maximal disk
|
|
4
3
|
* circle.
|
|
5
4
|
*
|
|
5
|
+
* * O(1): all `CpNode`s on the same on-circle ring share the same `Circle`
|
|
6
|
+
* object, and no other ring does (see `PointOnShape.circle`)
|
|
7
|
+
*
|
|
6
8
|
* @param cpNode1 A `CpNode`.
|
|
7
9
|
* @param cpNode2 Another `CpNode`
|
|
8
10
|
*/
|
|
9
11
|
function isOnSameCircle(cpNode1, cpNode2) {
|
|
10
|
-
|
|
11
|
-
const cpNodes = getAllOnCircle(cpNode1);
|
|
12
|
-
return cpNodes.indexOf(cpNode2) >= 0;
|
|
12
|
+
return cpNode1.pointOnShape.circle === cpNode2.pointOnShape.circle;
|
|
13
13
|
}
|
|
14
14
|
export { isOnSameCircle };
|
|
15
15
|
//# sourceMappingURL=is-on-same-circle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-on-same-circle.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-on-same-circle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-on-same-circle.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-on-same-circle.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,SAAS,cAAc,CACf,OAAe,EACf,OAAe;IAEnB,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;AACvE,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { CpNode } from "../cp-node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns `true` if the given `CpNode` is on a 'special' MAT vertex, i.e. one
|
|
4
|
+
* that is not a plain 2-prong: a leaf, a 3-prong (or higher) or a hole-closer.
|
|
5
|
+
*
|
|
6
|
+
* * these are the vertices that must be kept when simplifying the MAT and
|
|
7
|
+
* the vertices of the MAT seen as a graph
|
|
8
|
+
*/
|
|
2
9
|
declare function isSpecial(cpNode: CpNode): boolean;
|
|
3
10
|
export { isSpecial };
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { getRealProngCount } from "./get-real-prong-count.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns `true` if the given `CpNode` is on a 'special' MAT vertex, i.e. one
|
|
4
|
+
* that is not a plain 2-prong: a leaf, a 3-prong (or higher) or a hole-closer.
|
|
5
|
+
*
|
|
6
|
+
* * these are the vertices that must be kept when simplifying the MAT and
|
|
7
|
+
* the vertices of the MAT seen as a graph
|
|
8
|
+
*/
|
|
2
9
|
function isSpecial(cpNode) {
|
|
3
|
-
return (
|
|
4
|
-
|
|
10
|
+
return (getRealProngCount(cpNode) !== 2 ||
|
|
11
|
+
cpNode.isHoleClosing);
|
|
5
12
|
}
|
|
6
13
|
export { isSpecial };
|
|
7
14
|
//# sourceMappingURL=is-special.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-special.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-special.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"is-special.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-special.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAc;IAC7B,OAAO,CACH,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,MAAM,CAAC,aAAa,CACvB,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { CpNode } from '../cp-node.js';
|
|
2
2
|
/**
|
|
3
|
-
* Traverses all edges
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Traverses all edges of the given MAT tree exactly once each, calling the
|
|
4
|
+
* callback for one of the two `CpNode`s representing each edge.
|
|
5
|
+
*
|
|
6
|
+
* * the edges are visited in boundary order starting from the given `CpNode`
|
|
7
|
+
* (not depth first)
|
|
8
|
+
*
|
|
9
|
+
* @param cpNode Any `CpNode` on the MAT.
|
|
6
10
|
* @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
|
|
7
11
|
* start of an edge.
|
|
8
12
|
*/
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { isTerminating } from './is-terminating.js';
|
|
2
2
|
import { getAllOnLoop } from './get-all-on-loop.js';
|
|
3
3
|
/**
|
|
4
|
-
* Traverses all edges
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Traverses all edges of the given MAT tree exactly once each, calling the
|
|
5
|
+
* callback for one of the two `CpNode`s representing each edge.
|
|
6
|
+
*
|
|
7
|
+
* * the edges are visited in boundary order starting from the given `CpNode`
|
|
8
|
+
* (not depth first)
|
|
9
|
+
*
|
|
10
|
+
* @param cpNode Any `CpNode` on the MAT.
|
|
7
11
|
* @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
|
|
8
12
|
* start of an edge.
|
|
9
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-edges.js","sourceRoot":"","sources":["../../../src/cp-node/fs/traverse-edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD
|
|
1
|
+
{"version":3,"file":"traverse-edges.js","sourceRoot":"","sources":["../../../src/cp-node/fs/traverse-edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CACd,MAAc,EACd,qBAA+C;IAEnD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,IAAI,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAChE,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;AACL,CAAC;AAGD,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CpNode } from "../cp-node";
|
|
2
|
-
import type { CpNodeStringifyable } from "./cp-node-stringifyable";
|
|
1
|
+
import type { CpNode } from "../cp-node.js";
|
|
2
|
+
import type { CpNodeStringifyable } from "./cp-node-stringifyable.js";
|
|
3
3
|
declare function fromStringifyable(cpNodesStringifyable: CpNodeStringifyable): CpNode;
|
|
4
4
|
export { fromStringifyable };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EDGES } from "./cp-node-stringifyable";
|
|
1
|
+
import { EDGES } from "./cp-node-stringifyable.js";
|
|
2
|
+
import { getAllOnCircle } from "../fs/get-all-on-circle.js";
|
|
2
3
|
import { loopFromStringifyable } from './loop-from-stringifyable.js';
|
|
3
4
|
function fromStringifyable(cpNodesStringifyable) {
|
|
4
5
|
const { cpNodes: _cpNodes, loops: _loops } = cpNodesStringifyable;
|
|
@@ -38,6 +39,21 @@ function fromStringifyable(cpNodesStringifyable) {
|
|
|
38
39
|
cpNode[edge] = nodeMap.get(id);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
//--------------------------------------------------------------------------
|
|
43
|
+
// Third pass: one shared `Circle` object per on-circle ring, as when the
|
|
44
|
+
// MAT was built (the JSON gave every contact point its own copy).
|
|
45
|
+
//--------------------------------------------------------------------------
|
|
46
|
+
const done = new Set();
|
|
47
|
+
for (const cpNode of cpNodes) {
|
|
48
|
+
if (done.has(cpNode)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const { circle } = cpNode.pointOnShape;
|
|
52
|
+
for (const cp of getAllOnCircle(cpNode)) {
|
|
53
|
+
done.add(cp);
|
|
54
|
+
cp.pointOnShape.circle = circle;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
41
57
|
return cpNodes[0];
|
|
42
58
|
}
|
|
43
59
|
export { fromStringifyable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-stringifyable.js","sourceRoot":"","sources":["../../../src/cp-node/stringification/from-stringifyable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"from-stringifyable.js","sourceRoot":"","sources":["../../../src/cp-node/stringification/from-stringifyable.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD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ns a
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Returns a plain, acyclic representation of the entire MAT the given `CpNode`
|
|
5
|
+
* is part of (the `CpNode` edges replaced by ids and the boundary loops
|
|
6
|
+
* included) suitable for `JSON.stringify`; `fromStringifyable` reverses it.
|
|
7
7
|
*/
|
|
8
8
|
declare function toStringifyable(cpNode: CpNode): CpNodeStringifyable;
|
|
9
9
|
export { toStringifyable };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { loopToStringifyable } from "./loop-to-stringifyable.js";
|
|
2
2
|
/**
|
|
3
|
-
* Returns a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Returns a plain, acyclic representation of the entire MAT the given `CpNode`
|
|
4
|
+
* is part of (the `CpNode` edges replaced by ids and the boundary loops
|
|
5
|
+
* included) suitable for `JSON.stringify`; `fromStringifyable` reverses it.
|
|
6
6
|
*/
|
|
7
7
|
function toStringifyable(cpNode) {
|
|
8
8
|
const cpNodes_ = [];
|
package/node/debug/debug.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Curve } from 'flo-boolean';
|
|
1
2
|
/** @internal */
|
|
2
3
|
interface Debug {
|
|
3
4
|
/** Generated by debug object for later inspection */
|
|
4
|
-
elems:
|
|
5
|
+
elems: Elems;
|
|
5
6
|
timing: Timing;
|
|
6
7
|
/**
|
|
7
8
|
* These functions are meant to be used in the console, e.g. in the
|
|
@@ -10,6 +11,26 @@ interface Debug {
|
|
|
10
11
|
fs: {};
|
|
11
12
|
directives: Directives;
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Elements generated during `findMats` for later inspection (only available
|
|
16
|
+
* if debug has been enabled via `enableDebugForMat(true)`).
|
|
17
|
+
*
|
|
18
|
+
* The arrays are reset at the start of each `findMats` call and accumulate
|
|
19
|
+
* over all MATs found in that call, one entry per boundary bezier curve in the
|
|
20
|
+
* order the curves are encountered.
|
|
21
|
+
*/
|
|
22
|
+
interface Elems {
|
|
23
|
+
/** The loose (axis-aligned) bounding box of each boundary bezier curve */
|
|
24
|
+
readonly looseBoundingBoxes: number[][][];
|
|
25
|
+
/** The tight (rotated) bounding box of each boundary bezier curve */
|
|
26
|
+
readonly tightBoundingBoxes: number[][][];
|
|
27
|
+
/** The bounding hull of each boundary bezier curve */
|
|
28
|
+
readonly boundingHulls: number[][][];
|
|
29
|
+
/** The curves whose end point forms a quite sharp corner with the next curve */
|
|
30
|
+
readonly sharpCorners: Curve[];
|
|
31
|
+
/** The curves whose end point forms a quite dull corner with the next curve */
|
|
32
|
+
readonly dullCorners: Curve[];
|
|
33
|
+
}
|
|
13
34
|
/** @internal */
|
|
14
35
|
interface Timing {
|
|
15
36
|
holeClosers: number;
|
|
@@ -27,6 +48,8 @@ interface Directives {
|
|
|
27
48
|
stopAfterThreeProngs: boolean;
|
|
28
49
|
stopAfterThreeProngsNum: number;
|
|
29
50
|
}
|
|
51
|
+
/** Returns a fresh (empty) set of debug `Elems`. */
|
|
52
|
+
declare function createEmptyElems(): Elems;
|
|
30
53
|
declare function enableDebugForMat(debugOn: boolean): void;
|
|
31
|
-
export type { Debug, Timing, Directives };
|
|
32
|
-
export { enableDebugForMat };
|
|
54
|
+
export type { Debug, Elems, Timing, Directives };
|
|
55
|
+
export { enableDebugForMat, createEmptyElems };
|
package/node/debug/debug.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
/** Returns a fresh (empty) set of debug `Elems`. */
|
|
2
|
+
function createEmptyElems() {
|
|
3
|
+
return {
|
|
4
|
+
looseBoundingBoxes: [],
|
|
5
|
+
tightBoundingBoxes: [],
|
|
6
|
+
boundingHulls: [],
|
|
7
|
+
sharpCorners: [],
|
|
8
|
+
dullCorners: []
|
|
9
|
+
};
|
|
10
|
+
}
|
|
1
11
|
function enableDebugForMat(debugOn) {
|
|
2
12
|
if (!debugOn) {
|
|
3
|
-
|
|
13
|
+
globalThis._debug_ = undefined;
|
|
4
14
|
return;
|
|
5
15
|
}
|
|
6
|
-
let debug =
|
|
16
|
+
let debug = globalThis._debug_;
|
|
7
17
|
debug = {
|
|
8
18
|
...debug,
|
|
9
19
|
elems: {
|
|
10
|
-
...debug?.elems
|
|
20
|
+
...debug?.elems,
|
|
21
|
+
...createEmptyElems()
|
|
11
22
|
},
|
|
12
23
|
timing: {
|
|
13
24
|
...debug?.timing,
|
|
@@ -31,7 +42,7 @@ function enableDebugForMat(debugOn) {
|
|
|
31
42
|
stopAfterThreeProngsNum: undefined,
|
|
32
43
|
}
|
|
33
44
|
};
|
|
34
|
-
|
|
45
|
+
globalThis._debug_ = debug;
|
|
35
46
|
}
|
|
36
|
-
export { enableDebugForMat };
|
|
47
|
+
export { enableDebugForMat, createEmptyElems };
|
|
37
48
|
//# sourceMappingURL=debug.js.map
|
package/node/debug/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/debug/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/debug/debug.ts"],"names":[],"mappings":"AA6DA,oDAAoD;AACpD,SAAS,gBAAgB;IACrB,OAAO;QACH,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,EAAE;KAClB,CAAC;AACN,CAAC;AAGD,SAAS,iBAAiB,CAAC,OAAgB;IACvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACV,UAAkB,CAAC,OAAO,GAAG,SAAS,CAAC;QACxC,OAAO;IACX,CAAC;IAED,IAAI,KAAK,GAAW,UAAkB,CAAC,OAAO,CAAC;IAE/C,KAAK,GAAG;QACJ,GAAG,KAAK;QACR,KAAK,EAAE;YACH,GAAG,KAAK,EAAE,KAAK;YACf,GAAG,gBAAgB,EAAE;SACxB;QACD,MAAM,EAAE;YACJ,GAAG,KAAK,EAAE,MAAM;YAChB,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;YAChB,WAAW,EAAE,CAAC;YACd,IAAI,EAAE,CAAC;YACP,WAAW,EAAE,CAAC;SACjB;QACD,EAAE,EAAE;YACA,GAAG,KAAK,EAAE,EAAE;SACf;QACD,UAAU,EAAE;YACR,uBAAuB;YACvB,GAAG,KAAK,EAAE,UAAU;YACpB,oBAAoB,EAAE,KAAK;YAC3B,uBAAuB,EAAE,SAAU;YACnC,kBAAkB,EAAE,KAAK;YACzB,qBAAqB,EAAE,SAAU;YACjC,oBAAoB,EAAE,KAAK;YAC3B,uBAAuB,EAAE,SAAU;SACtC;KACJ,CAAC;IAED,UAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;AACxC,CAAC;AAID,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -20,12 +20,6 @@ function add2Prong(meta, circle, pposSource, pposAntipode, isHoleClosing) {
|
|
|
20
20
|
: pposSource;
|
|
21
21
|
const orderSource = calcPosOrder(circle.center, pposSource);
|
|
22
22
|
const orderAntipode = calcPosOrder(circle.center, pposAntipode);
|
|
23
|
-
const posAntipode = {
|
|
24
|
-
...pposAntipode, circle, order: orderAntipode, order2: 0
|
|
25
|
-
};
|
|
26
|
-
const posSource = {
|
|
27
|
-
...pposSource, circle, order: orderSource, order2: 0
|
|
28
|
-
};
|
|
29
23
|
// Make sure there isn't already a ContactPoint close by - it can cause
|
|
30
24
|
// floating point stability issues.
|
|
31
25
|
if (!!getCloseByCpIfExist(meta, pposSource, circle, orderSource, 0, 2)) {
|
|
@@ -34,7 +28,7 @@ function add2Prong(meta, circle, pposSource, pposAntipode, isHoleClosing) {
|
|
|
34
28
|
if (!!getCloseByCpIfExist(meta, pposAntipode, circle, orderAntipode, 0, 2)) {
|
|
35
29
|
return undefined;
|
|
36
30
|
}
|
|
37
|
-
const { anyFailed, cpNodes } = addToCpTree(isHoleClosing, isHoleClosing, circle, [orderSource, orderAntipode], meta, [
|
|
31
|
+
const { anyFailed, cpNodes } = addToCpTree(isHoleClosing, isHoleClosing, circle, [orderSource, orderAntipode], meta, [pposSource, pposAntipode]);
|
|
38
32
|
if (anyFailed) {
|
|
39
33
|
cpNodes.forEach(cpNode => {
|
|
40
34
|
if (cpNode !== undefined) {
|
|
@@ -51,15 +45,19 @@ function add2Prong(meta, circle, pposSource, pposAntipode, isHoleClosing) {
|
|
|
51
45
|
function closeHole(meta, cpNodes) {
|
|
52
46
|
const { cpTrees } = meta;
|
|
53
47
|
const [cpNodeSource, cpNodeAntipode] = cpNodes;
|
|
48
|
+
// The twins form their own on-circle ring (a separate MAT vertex - that
|
|
49
|
+
// is what cuts the hole), so they get their own (equal) `Circle` object:
|
|
50
|
+
// one `Circle` object per ring.
|
|
51
|
+
const twinCircle = { ...cpNodeSource.pointOnShape.circle };
|
|
54
52
|
// Antipode - create and insert twin
|
|
55
53
|
const posAntipode = cpNodeAntipode.pointOnShape;
|
|
56
|
-
const cpNodeAntipodeTwin = insertCpNode(true, true, false, cpTrees.get(posAntipode.curve.loop), { ...posAntipode, order2: +1 }, cpNodeAntipode, undefined, // unused
|
|
54
|
+
const cpNodeAntipodeTwin = insertCpNode(true, true, false, cpTrees.get(posAntipode.curve.loop), { ...posAntipode, circle: twinCircle, order2: +1 }, cpNodeAntipode, undefined, // unused
|
|
57
55
|
meta.lastInsertId);
|
|
58
56
|
cpNodeAntipodeTwin.holeCloserTwin = cpNodeAntipode;
|
|
59
57
|
cpNodeAntipode.holeCloserTwin = cpNodeAntipodeTwin;
|
|
60
58
|
// Source - create and insert twin
|
|
61
59
|
const posSource = cpNodeSource.pointOnShape;
|
|
62
|
-
const cpNodeSourceTwin = insertCpNode(true, true, false, cpTrees.get(posSource.curve.loop), { ...posSource, order2: -1 }, cpNodeSource.prev, undefined, // unused
|
|
60
|
+
const cpNodeSourceTwin = insertCpNode(true, true, false, cpTrees.get(posSource.curve.loop), { ...posSource, circle: twinCircle, order2: -1 }, cpNodeSource.prev, undefined, // unused
|
|
63
61
|
meta.lastInsertId);
|
|
64
62
|
cpNodeSourceTwin.holeCloserTwin = cpNodeSource;
|
|
65
63
|
cpNodeSource.holeCloserTwin = cpNodeSourceTwin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-2-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/add-2-prong.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D;;;;;;;;;;GAUG;AACH,SAAS,SAAS,CACV,IAAa,EACb,MAAc,EACd,UAA2B,EAC3B,YAA6B,EAC7B,aAAsB;IAE1B,UAAU,GAAG,UAAU,CAAC,CAAC,KAAK,CAAC;QAC3B,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;QACvD,CAAC,CAAC,UAAU,CAAC;IAEjB,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAEhE,
|
|
1
|
+
{"version":3,"file":"add-2-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/add-2-prong.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,E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,EACjD,YAAY,CAAC,IAAI,EACjB,SAAS,EAAG,SAAS;IACrB,IAAI,CAAC,YAAY,CACA,CAAC;IACtB,gBAAgB,CAAC,cAAc,GAAG,YAAY,CAAC;IAC/C,YAAY,CAAC,cAAc,GAAG,gBAAgB,CAAC;IAE/C,gBAAgB;IAChB,gBAAgB,CAAC,YAAY,GAAG,kBAAkB,CAAC;IACnD,gBAAgB,CAAC,YAAY,GAAG,kBAAkB,CAAC;IACnD,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;IACnD,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;IAEnD,cAAc,CAAC,IAAI,GAAG,YAAY,CAAC;IACnC,YAAY,CAAC,IAAI,GAAG,cAAc,CAAC;IAEnC,gBAAgB,CAAC,IAAI,GAAG,kBAAkB,CAAC;IAC3C,kBAAkB,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAC/C,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Returns the *squared* separation tolerance between the two contact points
|
|
3
|
+
* `y` (the source point) and `z` (the antipode) of a candidate 2-prong: if
|
|
4
|
+
* `|yz|²` is below it the antipode is indistinguishable (to within the error
|
|
5
|
+
* tolerance `δ`) from the circle merely grazing the boundary at `y` - the
|
|
6
|
+
* near-1-prong case - and the 2-prong should be rejected.
|
|
3
7
|
*
|
|
4
|
-
*
|
|
8
|
+
* Derivation: the MAT circle (radius `r`) is tangent to the boundary at `y`
|
|
9
|
+
* and so is the osculating circle there (radius `R`), both centers lying on
|
|
10
|
+
* the inward normal at `y`. Approximating the boundary near `y` by the
|
|
11
|
+
* osculating circle, the MAT circle enlarged by `δ` crosses it at the angle
|
|
12
|
+
* `θ` (at the MAT center, measured from `y`) given by the law of cosines:
|
|
13
|
+
*
|
|
14
|
+
* cos θ = (r(R-r) - rδ - δ²/2) / ((R-r)(r+δ))
|
|
15
|
+
*
|
|
16
|
+
* Points of the MAT circle within that angle of `y` are within `δ` of the
|
|
17
|
+
* boundary. The chord `|yz|` subtending `θ` is `2r·sin(θ/2)`, and since
|
|
18
|
+
* `2sin²(θ/2) = 1 - cos θ = (Rδ + δ²/2) / ((R-r)(r+δ))` the squared chord is
|
|
19
|
+
*
|
|
20
|
+
* |yz|² = r²(2Rδ + δ²) / ((R-r)(r+δ))
|
|
21
|
+
*
|
|
22
|
+
* which is what is returned - in closed form, without the cancellation that
|
|
23
|
+
* recovering a tiny `θ` from `cos θ` suffers from.
|
|
24
|
+
*
|
|
25
|
+
* @param R radius of the osculating circle of the boundary at `y`
|
|
5
26
|
* @param r radius of the MAT circle
|
|
6
|
-
* @param
|
|
27
|
+
* @param δ the error tolerance on distances
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
7
30
|
*/
|
|
8
|
-
declare function
|
|
9
|
-
export {
|
|
31
|
+
declare function calcSquaredSeperationTolerance(R: number, r: number, δ: number): number;
|
|
32
|
+
export { calcSquaredSeperationTolerance };
|
|
@@ -1,97 +1,40 @@
|
|
|
1
|
-
import { ddAddDd, twoProduct, ddDiffDd, ddDivDd, twoDiff, ddMultDouble1 } from 'double-double';
|
|
2
|
-
const tp = twoProduct;
|
|
3
|
-
const qaq = ddAddDd;
|
|
4
|
-
const qdq = ddDiffDd;
|
|
5
|
-
const qmd = ddMultDouble1;
|
|
6
|
-
const { acos } = Math;
|
|
7
1
|
/**
|
|
8
|
-
*
|
|
2
|
+
* Returns the *squared* separation tolerance between the two contact points
|
|
3
|
+
* `y` (the source point) and `z` (the antipode) of a candidate 2-prong: if
|
|
4
|
+
* `|yz|²` is below it the antipode is indistinguishable (to within the error
|
|
5
|
+
* tolerance `δ`) from the circle merely grazing the boundary at `y` - the
|
|
6
|
+
* near-1-prong case - and the 2-prong should be rejected.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
8
|
+
* Derivation: the MAT circle (radius `r`) is tangent to the boundary at `y`
|
|
9
|
+
* and so is the osculating circle there (radius `R`), both centers lying on
|
|
10
|
+
* the inward normal at `y`. Approximating the boundary near `y` by the
|
|
11
|
+
* osculating circle, the MAT circle enlarged by `δ` crosses it at the angle
|
|
12
|
+
* `θ` (at the MAT center, measured from `y`) given by the law of cosines:
|
|
13
|
+
*
|
|
14
|
+
* cos θ = (r(R-r) - rδ - δ²/2) / ((R-r)(r+δ))
|
|
15
|
+
*
|
|
16
|
+
* Points of the MAT circle within that angle of `y` are within `δ` of the
|
|
17
|
+
* boundary. The chord `|yz|` subtending `θ` is `2r·sin(θ/2)`, and since
|
|
18
|
+
* `2sin²(θ/2) = 1 - cos θ = (Rδ + δ²/2) / ((R-r)(r+δ))` the squared chord is
|
|
19
|
+
*
|
|
20
|
+
* |yz|² = r²(2Rδ + δ²) / ((R-r)(r+δ))
|
|
21
|
+
*
|
|
22
|
+
* which is what is returned - in closed form, without the cancellation that
|
|
23
|
+
* recovering a tiny `θ` from `cos θ` suffers from.
|
|
24
|
+
*
|
|
25
|
+
* @param R radius of the osculating circle of the boundary at `y`
|
|
11
26
|
* @param r radius of the MAT circle
|
|
12
|
-
* @param
|
|
27
|
+
* @param δ the error tolerance on distances
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
13
30
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
function calcSquaredSeperationTolerance(R, r, δ) {
|
|
32
|
+
if (r + δ >= R) {
|
|
33
|
+
// The enlarged MAT circle is at least as large as the osculating
|
|
34
|
+
// circle: every point on it is within tolerance of the boundary.
|
|
17
35
|
return Infinity;
|
|
18
36
|
}
|
|
19
|
-
|
|
20
|
-
const A_ = qmd(r, R_r_);
|
|
21
|
-
const N_ = qdq(qdq(A_, tp(r, δ)), tp(δ, δ / 2));
|
|
22
|
-
const D_ = qaq(A_, qmd(δ, R_r_));
|
|
23
|
-
const R_r = R - r;
|
|
24
|
-
const A = r * R_r;
|
|
25
|
-
const N = A - r * δ - (δ * δ) / 2;
|
|
26
|
-
const D = A + R_r * δ;
|
|
27
|
-
const cosC = N / D;
|
|
28
|
-
const Q = ddDivDd(N_, D_)[1];
|
|
29
|
-
// const Q = N_[1]/D_[1];
|
|
30
|
-
const C = acos(cosC);
|
|
31
|
-
const CC = acos(Q);
|
|
32
|
-
const θ = CC;
|
|
33
|
-
// return r*θ;
|
|
34
|
-
return r * θ;
|
|
37
|
+
return r * r * (2 * R * δ + δ * δ) / ((R - r) * (r + δ));
|
|
35
38
|
}
|
|
36
|
-
export {
|
|
37
|
-
// Quokka tests
|
|
38
|
-
// /**
|
|
39
|
-
// * Calculates and returns an appropriate seperation tolerance between `CpNode`s.
|
|
40
|
-
// *
|
|
41
|
-
// * @param R radius of the circle implied by the curvature at the boundary
|
|
42
|
-
// * @param r radius of the MAT circle
|
|
43
|
-
// * @param θ angle between point...
|
|
44
|
-
// */
|
|
45
|
-
// function calcSeperationTolerance2(
|
|
46
|
-
// R: number,
|
|
47
|
-
// r: number,
|
|
48
|
-
// δ: number) {
|
|
49
|
-
// const a = r + δ;
|
|
50
|
-
// if (a >= R) {
|
|
51
|
-
// return Infinity;
|
|
52
|
-
// }
|
|
53
|
-
// const b = R - r;
|
|
54
|
-
// const c = R;
|
|
55
|
-
// const N = c*c - a*a - b*b;
|
|
56
|
-
// const N_ = qdq(qdq(tp(c,c), tp(a,a)), tp(b,b));
|
|
57
|
-
// const D = 2*a*b;
|
|
58
|
-
// const D_ = tp(-2*a,b);
|
|
59
|
-
// const Q = ddDivDd(N_,D_)[1];
|
|
60
|
-
// const cosC = -N/D;
|
|
61
|
-
// const C = acos(cosC);
|
|
62
|
-
// const CC = acos(Q);
|
|
63
|
-
// const θ = π - CC;
|
|
64
|
-
// return θ;
|
|
65
|
-
// // return r*θ; // approximate arc with line
|
|
66
|
-
// }
|
|
67
|
-
// function degToRad(degrees: number) {
|
|
68
|
-
// return degrees/360*2*Math.PI;
|
|
69
|
-
// }
|
|
70
|
-
// function radToDeg(rad: number) {
|
|
71
|
-
// return rad*360/2/Math.PI;
|
|
72
|
-
// }
|
|
73
|
-
// const R = 699;
|
|
74
|
-
// const r = 698;
|
|
75
|
-
// const δ = 1000*2**-46;
|
|
76
|
-
// calcSeperationTolerance(R,r,δ);
|
|
77
|
-
// calcSeperationTolerance2(R,r,δ);
|
|
78
|
-
// calcSeperationTolerance3(R,r,δ);
|
|
79
|
-
// // * see https://en.wikipedia.org/wiki/Law_of_cosines, Version suited to small angles
|
|
80
|
-
// function calcSeperationTolerance3(
|
|
81
|
-
// R: number,
|
|
82
|
-
// r: number,
|
|
83
|
-
// δ: number) {
|
|
84
|
-
// const a = r + δ;
|
|
85
|
-
// const c = R - r;
|
|
86
|
-
// const b = R;
|
|
87
|
-
// // c² = (a - b)² + 4ab*sin²(θ/2) OR
|
|
88
|
-
// // (c² - (a - b)²)/4ab = sin²(θ/2)
|
|
89
|
-
// const cc = c*c;
|
|
90
|
-
// const abc = a*a + b*b - 2*a*b;
|
|
91
|
-
// const A = cc - abc;
|
|
92
|
-
// const B = sqrt(A/(4*a*b));
|
|
93
|
-
// const θ = 2*asin(B);
|
|
94
|
-
// return θ;
|
|
95
|
-
// // return r*θ; // approximate arc with line
|
|
96
|
-
// }
|
|
39
|
+
export { calcSquaredSeperationTolerance };
|
|
97
40
|
//# sourceMappingURL=calc-seperation-tolerance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calc-seperation-tolerance.js","sourceRoot":"","sources":["../../src/find-2-prong/calc-seperation-tolerance.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"calc-seperation-tolerance.js","sourceRoot":"","sources":["../../src/find-2-prong/calc-seperation-tolerance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAS,8BAA8B,CAC/B,CAAS,EACT,CAAS,EACT,CAAS;IAEb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACb,iEAAiE;QACjE,iEAAiE;QACjE,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,GAAC,CAAC,GAAC,CAAC,CAAC,GAAC,CAAC,GAAC,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAGD,OAAO,EAAE,8BAA8B,EAAE,CAAA"}
|
|
@@ -2,10 +2,10 @@ import { getInitialCurvePieces } from './get-initial-bezier-pieces.js';
|
|
|
2
2
|
import { getAntipodalPoints } from './get-medial/get-antipodal-points.js';
|
|
3
3
|
import { reduceRadius } from './reduce-radius.js';
|
|
4
4
|
import { squaredDistanceBetweenDd } from './squared-distance-between-dd.js';
|
|
5
|
-
import { cullCurvePieces } from '
|
|
5
|
+
import { cullCurvePieces } from '../closest-boundary-point/cull-curve-pieces.js';
|
|
6
6
|
import { add1Prong } from './add-1-prong.js';
|
|
7
7
|
import { toP } from '../point-on-shape/to-p.js';
|
|
8
|
-
import {
|
|
8
|
+
import { calcSquaredSeperationTolerance } from './calc-seperation-tolerance.js';
|
|
9
9
|
import { getInitialX } from './get-initial-x.js';
|
|
10
10
|
import { ddNormal } from 'flo-bezier3';
|
|
11
11
|
import { rotate } from 'flo-vector2d';
|
|
@@ -58,18 +58,16 @@ function find2Prong(meta) {
|
|
|
58
58
|
// the 2-prong circle. (Defined by start and end points).
|
|
59
59
|
const curvePieces = getInitialCurvePieces(angle, isHoleClosing, loop, loops, meta, yPos, xO);
|
|
60
60
|
// The lines below is an optimization.
|
|
61
|
-
const xy2 = reduceRadius(
|
|
61
|
+
const xy2 = reduceRadius(rO, curvePieces, y, nnorm);
|
|
62
62
|
const xy = sqrt(xy2);
|
|
63
63
|
const l = sqrt(nnorm[0] ** 2 + nnorm[1] ** 2);
|
|
64
64
|
xO = [y[0] + nnorm[0] / l * xy, y[1] + nnorm[1] / l * xy];
|
|
65
|
-
|
|
66
|
-
const
|
|
65
|
+
// (the extra multiplier accounts for floating point error)
|
|
66
|
+
const culledCurvePieces = cullCurvePieces(curvePieces, xO, (1 + 2 ** -20) * xy2);
|
|
67
|
+
const antipodalPoints = getAntipodalPoints(maxCoordPowerOf2, nnormDd, yPos, for1Prong, angle, culledCurvePieces);
|
|
67
68
|
// FUTURE - if antipodalPoints.length > 1 let's just add an n-prong;
|
|
68
69
|
if (antipodalPoints.length !== 1) {
|
|
69
70
|
if (antipodalPoints.length === 0) {
|
|
70
|
-
if (isHoleClosing) {
|
|
71
|
-
console.log(yPos);
|
|
72
|
-
}
|
|
73
71
|
return undefined;
|
|
74
72
|
}
|
|
75
73
|
if (!isHoleClosing && !areAllAntipodesSame(antipodalPoints, maxCoordPowerOf2)) {
|
|
@@ -99,7 +97,7 @@ function find2Prong(meta) {
|
|
|
99
97
|
}
|
|
100
98
|
// The lines below eliminate cases where the found 2-prong is too
|
|
101
99
|
// close to a one-prong
|
|
102
|
-
const squaredSeperationTolerance = max(
|
|
100
|
+
const squaredSeperationTolerance = max(calcSquaredSeperationTolerance(rO, sqrt(xz), (2 ** 2) * errorTolerance), minSquaredSeperationTolerance);
|
|
103
101
|
if (yz <= squaredSeperationTolerance) {
|
|
104
102
|
return undefined;
|
|
105
103
|
}
|
|
@@ -117,7 +115,7 @@ function areAllAntipodesSame(point, maxCoordPowerOf2) {
|
|
|
117
115
|
// return false;
|
|
118
116
|
// }
|
|
119
117
|
const { x: x_ } = point[i];
|
|
120
|
-
if (abs(x[0] - x_[0]) > tol || abs(x[
|
|
118
|
+
if (abs(x[0] - x_[0]) > tol || abs(x[1] - x_[1]) > tol) {
|
|
121
119
|
return false;
|
|
122
120
|
}
|
|
123
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-2-prong.js","sourceRoot":"","sources":["../../src/find-2-prong/find-2-prong.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACv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