flo-mat 4.0.3 → 4.1.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/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +106 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +73 -0
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +5 -2
- package/__tests__/helpers/close-to.ts +5 -5
- package/__tests__/specific-cases/load-svg/load-svg.ts +30 -0
- package/__tests__/specific-cases/specific-cases.spec.ts +168 -4
- package/__tests__/specific-cases/test-svgs/achispado.svg +5052 -0
- package/browser/index.js +1686 -2738
- package/browser/index.min.js +1 -1
- package/{jest.config.cjs → jest.config.ts} +8 -3
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +3 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/corner/get-corner.js +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.d.ts +6 -2
- package/node/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.js +5 -1
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.js +1 -59
- package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.d.ts +3 -1
- package/node/cp-node/fs/get-edge-direction.js +5 -3
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.js +6 -6
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.js +12 -0
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/debug/debug.d.ts +4 -13
- package/node/debug/debug.js +3 -30
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +24 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -2
- 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 +7 -1
- package/node/find-2-prong/get-medial/get-closest-points.js +60 -14
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +3 -1
- package/node/find-2-prong/reduce-radius.js +8 -6
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -3
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/calc-initial-3-prong-center.js +1 -2
- package/node/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.js +1 -4
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prong.js +0 -14
- package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
- package/node/find-mat/find-mat.js +2 -1
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +3 -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 +6 -3
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js +5 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +4 -1
- package/node/find-mat/get-meta.js +9 -1
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +4 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.d.ts +21 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js +46 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js +97 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js +109 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js +123 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.d.ts +30 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js +177 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +156 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js +40 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js.map +1 -0
- package/node/index.d.ts +4 -10
- package/node/index.js +3 -6
- package/node/index.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +2 -0
- package/node/point-on-shape/to-p.d.ts +1 -1
- package/node/point-on-shape/to-p.js +1 -1
- package/node/point-on-shape/to-p.js.map +1 -1
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +2 -2
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -1
- package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +8 -2
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +154 -22
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
- package/node/svg/get-loop-bounds.js +6 -2
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/utils/map-deep.d.ts +15 -0
- package/node/utils/map-deep.js +34 -0
- package/node/utils/map-deep.js.map +1 -0
- package/package.json +14 -8
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +3 -2
- package/src/corner/get-corner.ts +1 -1
- package/src/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.ts +7 -3
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-boundary-beziers-to-next.ts +1 -72
- package/src/cp-node/fs/get-edge-direction.ts +8 -4
- package/src/cp-node/fs/get-mat-curve-between.ts +6 -6
- package/src/cp-node/fs/is-fully-terminating.ts +16 -0
- package/src/debug/debug.ts +8 -50
- package/src/find-2-prong/find-2-prong.ts +37 -14
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +3 -2
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +213 -0
- package/src/find-2-prong/get-medial/get-closest-points.ts +74 -13
- package/src/find-2-prong/reduce-radius.ts +8 -5
- package/src/find-3-prong/calc-better-x.ts +1 -3
- package/src/find-3-prong/calc-initial-3-prong-center.ts +1 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +1 -4
- package/src/find-3-prong/find-3-prong.ts +0 -1
- package/src/find-3-prong/find-and-add-3-prong.ts +1 -15
- package/src/find-mat/find-mat.ts +3 -1
- package/src/find-mat/find-mats.ts +0 -1
- package/src/find-mat/get-dull-corners-on-loop.ts +4 -3
- package/src/find-mat/get-for-1-prongs-on-loop.ts +8 -3
- package/src/find-mat/get-for-2-prongs-on-loop.ts +6 -1
- package/src/find-mat/get-meta.ts +11 -0
- package/src/find-mat/get-sharp-corners.ts +5 -1
- package/src/get-medial-curve/__pycache__/get-cubic-self-medial-curve.cpython-313.pyc +0 -0
- package/src/get-medial-curve/get-cubic-self-medial-curve.py +419 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0-with-running-err.ts +76 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.ts +61 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.ts +116 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.ts +129 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.ts +142 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.ts +199 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +177 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs.ts +48 -0
- package/src/get-medial-points/double-double/error-bound-calc.txt +72 -0
- package/src/index.ts +4 -10
- package/src/point-on-shape/point-on-shape.ts +3 -0
- package/src/point-on-shape/to-p.ts +2 -2
- package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +2 -2
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +202 -21
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +1 -1
- package/src/svg/get-loop-bounds.ts +11 -3
- package/src/utils/map-deep.ts +75 -0
- package/src/utils/map-map.ts +33 -0
- package/wallaby.mjs +4 -4
- package/node/debug/debug-elem-types.d.ts +0 -26
- package/node/debug/debug-elem-types.js +0 -22
- package/node/debug/debug-elem-types.js.map +0 -1
- package/node/debug/functions/draw/draw-beziers-as-single-path.d.ts +0 -2
- package/node/debug/functions/draw/draw-beziers-as-single-path.js +0 -30
- package/node/debug/functions/draw/draw-beziers-as-single-path.js.map +0 -1
- package/node/debug/functions/draw/xmlns.d.ts +0 -2
- package/node/debug/functions/draw/xmlns.js +0 -3
- package/node/debug/functions/draw/xmlns.js.map +0 -1
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +0 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +0 -8
- package/node/debug/functions/draw-elem/bounding-hull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-branch.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-branch.js +0 -26
- package/node/debug/functions/draw-elem/draw-branch.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +0 -13
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cp-node.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-cp-node.js +0 -26
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cull.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-cull.js +0 -9
- package/node/debug/functions/draw-elem/draw-cull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-dull-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +0 -10
- package/node/debug/functions/draw-elem/draw-elem.js +0 -39
- package/node/debug/functions/draw-elem/draw-elem.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-leaves.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-leaves.js +0 -34
- package/node/debug/functions/draw-elem/draw-leaves.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loop.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loop.js +0 -11
- package/node/debug/functions/draw-elem/draw-loop.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loops.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loops.js +0 -6
- package/node/debug/functions/draw-elem/draw-loops.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js +0 -10
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-mat.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-mat.js +0 -34
- package/node/debug/functions/draw-elem/draw-mat.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-max-vertex.js +0 -9
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-min-y.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-min-y.js +0 -10
- package/node/debug/functions/draw-elem/draw-min-y.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js +0 -22
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong.js +0 -13
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-sharp-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-three-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-three-prong.js +0 -26
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js +0 -8
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-two-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-two-prong.js +0 -49
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-vertex.js +0 -13
- package/node/debug/functions/draw-elem/draw-vertex.js.map +0 -1
- package/node/find-3-prong/timed-cc.d.ts +0 -3
- package/node/find-3-prong/timed-cc.js +0 -5
- package/node/find-3-prong/timed-cc.js.map +0 -1
- package/node/reconstruct-from-mat/filter-zero-length.d.ts +0 -10
- package/node/reconstruct-from-mat/filter-zero-length.js +0 -14
- package/node/reconstruct-from-mat/filter-zero-length.js.map +0 -1
- package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js.map +0 -1
- package/node/reconstruct-from-mat/get-bezier-piece-length.d.ts +0 -3
- package/node/reconstruct-from-mat/get-bezier-piece-length.js +0 -6
- package/node/reconstruct-from-mat/get-bezier-piece-length.js.map +0 -1
- package/node/reconstruct-from-mat/get-boundary.d.ts +0 -7
- package/node/reconstruct-from-mat/get-boundary.js +0 -18
- package/node/reconstruct-from-mat/get-boundary.js.map +0 -1
- package/node/reconstruct-from-mat/get-matching-beziers.d.ts +0 -10
- package/node/reconstruct-from-mat/get-matching-beziers.js +0 -29
- package/node/reconstruct-from-mat/get-matching-beziers.js.map +0 -1
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.d.ts +0 -6
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js +0 -10
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js.map +0 -1
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.d.ts +0 -7
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js +0 -47
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js.map +0 -1
- package/node/reconstruct-from-mat/get-sats2.d.ts +0 -10
- package/node/reconstruct-from-mat/get-sats2.js +0 -16
- package/node/reconstruct-from-mat/get-sats2.js.map +0 -1
- package/node/reconstruct-from-mat/is-fully-terminating.d.ts +0 -3
- package/node/reconstruct-from-mat/is-fully-terminating.js +0 -19
- package/node/reconstruct-from-mat/is-fully-terminating.js.map +0 -1
- package/node/reconstruct-from-mat/matched-beziers.d.ts +0 -10
- package/node/reconstruct-from-mat/matched-beziers.js +0 -2
- package/node/reconstruct-from-mat/matched-beziers.js.map +0 -1
- package/node/reconstruct-from-mat/split-tri-path.d.ts +0 -5
- package/node/reconstruct-from-mat/split-tri-path.js +0 -209
- package/node/reconstruct-from-mat/split-tri-path.js.map +0 -1
- package/node/utils/clip.d.ts +0 -2
- package/node/utils/clip.js +0 -6
- package/node/utils/clip.js.map +0 -1
- package/node/utils/time-function-call.d.ts +0 -14
- package/node/utils/time-function-call.js +0 -32
- package/node/utils/time-function-call.js.map +0 -1
- package/src/debug/debug-elem-types.ts +0 -43
- package/src/debug/functions/draw-elem/bounding-hull.ts +0 -18
- package/src/debug/functions/draw-elem/culls.ts +0 -39
- package/src/debug/functions/draw-elem/draw-branch.ts +0 -37
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +0 -23
- package/src/debug/functions/draw-elem/draw-cp-node.ts +0 -46
- package/src/debug/functions/draw-elem/draw-cull.ts +0 -21
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-elem.ts +0 -64
- package/src/debug/functions/draw-elem/draw-leaves.ts +0 -51
- package/src/debug/functions/draw-elem/draw-loop.ts +0 -16
- package/src/debug/functions/draw-elem/draw-loops.ts +0 -10
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/draw-mat.ts +0 -43
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/draw-min-y.ts +0 -18
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +0 -40
- package/src/debug/functions/draw-elem/draw-one-prong.ts +0 -25
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-three-prong.ts +0 -44
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/draw-two-prong.ts +0 -68
- package/src/debug/functions/draw-elem/draw-vertex.ts +0 -27
- package/src/debug/functions/draw-elem/dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/leaves.ts +0 -20
- package/src/debug/functions/draw-elem/loop.ts +0 -16
- package/src/debug/functions/draw-elem/loops.ts +0 -10
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/mat.ts +0 -47
- package/src/debug/functions/draw-elem/max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/min-y.ts +0 -18
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +0 -26
- package/src/debug/functions/draw-elem/one-prong.ts +0 -23
- package/src/debug/functions/draw-elem/sharp-corner.ts +0 -20
- package/src/debug/functions/draw-elem/three-prong.ts +0 -30
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/two-prong.ts +0 -50
- package/src/debug/functions/draw-elem/vertex.ts +0 -51
- package/src/find-3-prong/timed-cc.ts +0 -9
- package/src/reconstruct-from-mat/filter-zero-length.ts +0 -23
- package/src/reconstruct-from-mat/get-bezier-piece-length.ts +0 -12
- package/src/reconstruct-from-mat/get-boundary.ts +0 -32
- package/src/reconstruct-from-mat/get-matching-beziers.ts +0 -46
- package/src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts +0 -19
- package/src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts +0 -69
- package/src/reconstruct-from-mat/get-sats2.ts +0 -25
- package/src/reconstruct-from-mat/is-fully-terminating.ts +0 -27
- package/src/reconstruct-from-mat/matched-beziers.ts +0 -14
- package/src/reconstruct-from-mat/split-tri-path.ts +0 -280
package/src/debug/debug.ts
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import type { DrawElemFunctions } from './functions/draw-elem/draw-elem.js';
|
|
2
|
-
import type { DebugElems } from './debug-elem-types.js';
|
|
3
|
-
import { drawElemFs } from './functions/draw-elem/draw-elem.js';
|
|
4
|
-
|
|
5
1
|
|
|
6
2
|
/** @internal */
|
|
7
3
|
interface Debug {
|
|
8
4
|
/** Generated by debug object for later inspection */
|
|
9
|
-
elems:
|
|
5
|
+
elems: {};
|
|
10
6
|
timing: Timing;
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* These functions are meant to be used in the console, e.g. in the
|
|
14
10
|
* console try typing d.fs.twoProng.traceConvergence(0);
|
|
15
11
|
*/
|
|
16
|
-
fs:
|
|
12
|
+
fs: {};
|
|
17
13
|
directives: Directives;
|
|
18
14
|
}
|
|
19
15
|
|
|
20
16
|
|
|
21
|
-
/** @internal */
|
|
22
|
-
type GeneratedElems = { [T in keyof DebugElems]: DebugElems[T][] };
|
|
23
|
-
|
|
24
|
-
|
|
25
17
|
/** @internal */
|
|
26
18
|
interface Timing {
|
|
27
19
|
holeClosers: number;
|
|
@@ -32,12 +24,6 @@ interface Timing {
|
|
|
32
24
|
}
|
|
33
25
|
|
|
34
26
|
|
|
35
|
-
/** @internal */
|
|
36
|
-
interface DebugFunctions {
|
|
37
|
-
drawElem: DrawElemFunctions,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
27
|
/** @internal */
|
|
42
28
|
interface Directives {
|
|
43
29
|
stopAfterHoleClosers: boolean,
|
|
@@ -60,30 +46,7 @@ function enableDebugForMat(debugOn: boolean) {
|
|
|
60
46
|
debug = {
|
|
61
47
|
...debug,
|
|
62
48
|
elems: {
|
|
63
|
-
...debug?.elems
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
|
|
66
|
-
oneProng : [],
|
|
67
|
-
// oneProngAtDullCorner : [],
|
|
68
|
-
twoProng : [],
|
|
69
|
-
// twoProng_regular : [],
|
|
70
|
-
// twoProng_failed : [],
|
|
71
|
-
// twoProng_notAdded : [],
|
|
72
|
-
// twoProng_deleted : [],
|
|
73
|
-
// twoProng_holeClosing : [],
|
|
74
|
-
looseBoundingBox : [],
|
|
75
|
-
tightBoundingBox : [],
|
|
76
|
-
// sharpCorner : [],
|
|
77
|
-
// dullCorner : [],
|
|
78
|
-
vertex : [],
|
|
79
|
-
threeProng : [],
|
|
80
|
-
boundingHull : [],
|
|
81
|
-
mat : [],
|
|
82
|
-
// sat : [],
|
|
83
|
-
cpNode : [],
|
|
84
|
-
maxVertex : [],
|
|
85
|
-
leaves : [],
|
|
86
|
-
// culls : [],
|
|
49
|
+
...debug?.elems
|
|
87
50
|
},
|
|
88
51
|
timing: {
|
|
89
52
|
...debug?.timing,
|
|
@@ -91,14 +54,10 @@ function enableDebugForMat(debugOn: boolean) {
|
|
|
91
54
|
oneAnd2Prongs: 0,
|
|
92
55
|
threeProngs: 0,
|
|
93
56
|
sats: 0,
|
|
94
|
-
simplifyMat: 0
|
|
57
|
+
simplifyMat: 0
|
|
95
58
|
},
|
|
96
59
|
fs: {
|
|
97
|
-
...debug?.fs
|
|
98
|
-
drawElem: {
|
|
99
|
-
...debug?.fs?.drawElem,
|
|
100
|
-
...drawElemFs
|
|
101
|
-
}
|
|
60
|
+
...debug?.fs
|
|
102
61
|
},
|
|
103
62
|
directives: {
|
|
104
63
|
//...debug?.directives,
|
|
@@ -116,7 +75,6 @@ function enableDebugForMat(debugOn: boolean) {
|
|
|
116
75
|
}
|
|
117
76
|
|
|
118
77
|
|
|
119
|
-
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
78
|
+
export type { Debug, Timing, Directives }
|
|
79
|
+
export { enableDebugForMat }
|
|
80
|
+
|
|
@@ -15,7 +15,7 @@ import { ddNormal } from 'flo-bezier3';
|
|
|
15
15
|
import { rotate } from 'flo-vector2d';
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
const { sin, cos, max, sqrt } = Math;
|
|
18
|
+
const { abs, sin, cos, max, sqrt } = Math;
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -60,6 +60,7 @@ function find2Prong(
|
|
|
60
60
|
angle: number,
|
|
61
61
|
yPos: PrePointOnShape): { circle: Circle, z: PrePointOnShape } | undefined {
|
|
62
62
|
|
|
63
|
+
|
|
63
64
|
const { curve: { loop, ps }, t, p: y } = yPos;
|
|
64
65
|
const normDd = ddNormal(ps, t);
|
|
65
66
|
const _nnorm = [-normDd[0][1], -normDd[1][1]]; // Left-handed system (sorry)
|
|
@@ -67,6 +68,10 @@ function find2Prong(
|
|
|
67
68
|
? [0, -maxOsculatingCircleRadius]
|
|
68
69
|
: (angle !== 0 ? rotate(sin(angle), cos(angle))(_nnorm) : _nnorm);
|
|
69
70
|
|
|
71
|
+
const nnormDd = isHoleClosing || angle !== 0
|
|
72
|
+
? [[0, nnorm[0]], [0, nnorm[1]]]
|
|
73
|
+
: [[-normDd[0][0], -normDd[0][1]], [-normDd[1][0], -normDd[1][1]]];
|
|
74
|
+
|
|
70
75
|
// Get initial kissing circle guess
|
|
71
76
|
let [xO,rO] = getInitialX(
|
|
72
77
|
angle, isHoleClosing, maxOsculatingCircleRadius, yPos, nnorm
|
|
@@ -80,7 +85,7 @@ function find2Prong(
|
|
|
80
85
|
);
|
|
81
86
|
|
|
82
87
|
// The lines below is an optimization.
|
|
83
|
-
const xy2 = reduceRadius(maxCoordPowerOf2, curvePieces, y, nnorm);
|
|
88
|
+
const xy2 = reduceRadius(maxCoordPowerOf2, rO, curvePieces, y, nnorm);
|
|
84
89
|
const xy = sqrt(xy2);
|
|
85
90
|
|
|
86
91
|
const l = sqrt(nnorm[0]**2 + nnorm[1]**2);
|
|
@@ -89,17 +94,24 @@ function find2Prong(
|
|
|
89
94
|
cullCurvePieces(curvePieces, xO, xy2);
|
|
90
95
|
|
|
91
96
|
const antipodalPoints = getAntipodalPoints(
|
|
92
|
-
maxCoordPowerOf2, nnorm, yPos,
|
|
97
|
+
maxCoordPowerOf2, nnorm, nnormDd, yPos,
|
|
93
98
|
for1Prong, angle,
|
|
94
99
|
curvePieces
|
|
95
100
|
);
|
|
96
101
|
|
|
102
|
+
// FUTURE - if antipodalPoints.length > 1 let's just add an n-prong;
|
|
97
103
|
if (antipodalPoints.length !== 1) {
|
|
98
|
-
if (antipodalPoints.length === 0) {
|
|
99
|
-
|
|
104
|
+
if (antipodalPoints.length === 0) {
|
|
105
|
+
if (isHoleClosing) {
|
|
106
|
+
console.log(yPos)
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (!isHoleClosing && !areAllAntipodesSame(antipodalPoints, maxCoordPowerOf2)) {
|
|
100
111
|
// At this point there is multiple antipodal points (zs) for the given
|
|
101
112
|
// source point so do not add the 2-prong, it will be caught when
|
|
102
113
|
// adding 3+-prongs.
|
|
114
|
+
|
|
103
115
|
return undefined;
|
|
104
116
|
}
|
|
105
117
|
}
|
|
@@ -111,9 +123,12 @@ function find2Prong(
|
|
|
111
123
|
return undefined;
|
|
112
124
|
}
|
|
113
125
|
|
|
126
|
+
const pDd = toP(curve.ps, s);
|
|
127
|
+
const p = pDd.map(c => c[0] + c[1]);
|
|
128
|
+
|
|
114
129
|
const z: PrePointOnShape = {
|
|
115
130
|
curve, t: s, isSource: false,
|
|
116
|
-
p
|
|
131
|
+
p, pDd
|
|
117
132
|
};
|
|
118
133
|
|
|
119
134
|
const circle = { center: x, radius: d };
|
|
@@ -122,7 +137,9 @@ function find2Prong(
|
|
|
122
137
|
const xz = squaredDistanceBetweenDd(x, z.p);
|
|
123
138
|
|
|
124
139
|
if (!isHoleClosing) {
|
|
125
|
-
if (yz === 0) {
|
|
140
|
+
if (yz === 0) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
126
143
|
|
|
127
144
|
// The lines below eliminate cases where the found 2-prong is too
|
|
128
145
|
// close to a one-prong
|
|
@@ -142,13 +159,19 @@ function find2Prong(
|
|
|
142
159
|
|
|
143
160
|
/** @internal */
|
|
144
161
|
function areAllAntipodesSame(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
point: AntipodalPoint[],
|
|
163
|
+
maxCoordPowerOf2: number): boolean {
|
|
164
|
+
|
|
165
|
+
const { curve, s: t, x } = point[0];
|
|
166
|
+
const tol = 2**(maxCoordPowerOf2 - 40);
|
|
167
|
+
for (let i=1; i<point.length; i++) {
|
|
168
|
+
// const { curve: curve_, s: t_ } = point[i];
|
|
169
|
+
// if (curve !== curve_ || t !== t_) {
|
|
170
|
+
// return false;
|
|
171
|
+
// }
|
|
172
|
+
|
|
173
|
+
const { x: x_ } = point[i];
|
|
174
|
+
if (abs(x[0] - x_[0]) > tol || abs(x[0] - x_[0]) > tol) {
|
|
152
175
|
return false;
|
|
153
176
|
}
|
|
154
177
|
}
|
|
@@ -19,7 +19,8 @@ import { getClosestPoint } from './get-closest-points.js';
|
|
|
19
19
|
*/
|
|
20
20
|
function getAntipodalPoints(
|
|
21
21
|
maxCoordPowerOf2: number,
|
|
22
|
-
nnorm: number[],
|
|
22
|
+
nnorm: number[],
|
|
23
|
+
nnormDd: number[][],
|
|
23
24
|
yPos: PrePointOnShape,
|
|
24
25
|
for1Prong: boolean,
|
|
25
26
|
angle: number,
|
|
@@ -30,7 +31,7 @@ function getAntipodalPoints(
|
|
|
30
31
|
const curvePiece = curvePieces[i];
|
|
31
32
|
|
|
32
33
|
const pInfos = getClosestPoint(
|
|
33
|
-
maxCoordPowerOf2, nnorm, yPos, for1Prong, angle,
|
|
34
|
+
maxCoordPowerOf2, nnorm, nnormDd, yPos, for1Prong, angle,
|
|
34
35
|
curvePiece
|
|
35
36
|
);
|
|
36
37
|
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { RootInterval } from 'flo-poly';
|
|
2
|
+
import type { CurvePiece } from "../../mat/curve-piece.js";
|
|
3
|
+
import type { PrePointOnShape } from "../../point-on-shape/point-on-shape.js";
|
|
4
|
+
import type { AntipodalPoint } from './antipodal-point.js';
|
|
5
|
+
import { lengthSquared } from "flo-vector2d";
|
|
6
|
+
import { roots, Horner } from 'flo-poly';
|
|
7
|
+
import { evalDeCasteljau, getMedialPointCoeffs, getMedialPointCoeffsBez0, getMedialPointCoeffsBez2_SameCurve, getMedialPointCoeffsBez3_SameCurve } from 'flo-bezier3';
|
|
8
|
+
|
|
9
|
+
const { sqrt, abs, max } = Math;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param maxCoordPowerOf2
|
|
14
|
+
* @param nnorm
|
|
15
|
+
* @param yPos The point on the shape
|
|
16
|
+
* @param for1Prong defaults to `false`;
|
|
17
|
+
* @param angle defaults to `0`;
|
|
18
|
+
* @param curvePiece The curve piece
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
function getClosestPoint(
|
|
23
|
+
maxCoordPowerOf2: number,
|
|
24
|
+
nnorm: number[],
|
|
25
|
+
nnormDd: number[][],
|
|
26
|
+
yPos: PrePointOnShape,
|
|
27
|
+
for1Prong: boolean,
|
|
28
|
+
angle: number,
|
|
29
|
+
curvePiece: CurvePiece): AntipodalPoint[] {
|
|
30
|
+
|
|
31
|
+
const { curve, ts: [tS,tE] } = curvePiece;
|
|
32
|
+
const { ps } = curve;
|
|
33
|
+
const { curve: touchedCurve, t, p: y, pDd: yDd } = yPos;
|
|
34
|
+
|
|
35
|
+
const isTouched = curve === touchedCurve;
|
|
36
|
+
const shouldDeflate = angle === 0 && isTouched;
|
|
37
|
+
|
|
38
|
+
const infos: AntipodalPoint[] = [];
|
|
39
|
+
let startPushed = false;
|
|
40
|
+
let endPushed = false;
|
|
41
|
+
|
|
42
|
+
let ss: RootInterval[];
|
|
43
|
+
if (tS !== tE &&
|
|
44
|
+
!(shouldDeflate && ps.length === 2) &&
|
|
45
|
+
!(isTouched && ps.length === 3 && for1Prong)) {
|
|
46
|
+
|
|
47
|
+
const { A, B, H } = shouldDeflate
|
|
48
|
+
? ps.length === 3
|
|
49
|
+
? getMedialPointCoeffsBez2_SameCurve(t, nnorm, ps)
|
|
50
|
+
: getMedialPointCoeffsBez3_SameCurve(t, nnorm, ps)
|
|
51
|
+
: getMedialPointCoeffs(y, nnorm, ps);
|
|
52
|
+
|
|
53
|
+
ss = roots(H, tS, tE) || [];
|
|
54
|
+
//-----------------------
|
|
55
|
+
|
|
56
|
+
for (let i=0; i<ss.length; i++) {
|
|
57
|
+
const ri = ss[i];
|
|
58
|
+
const { tS: sS, tE: sE, t: _s } = ri;
|
|
59
|
+
if (ri.multiplicity > 1) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (sE < tS || sS > tE) { continue; } // outside curve piece
|
|
64
|
+
if (sS < 0) { continue; } // outside curve piece
|
|
65
|
+
|
|
66
|
+
// clip to [0,1]
|
|
67
|
+
const s = sE > 1 ? 1 : _s;
|
|
68
|
+
|
|
69
|
+
//-----------------------
|
|
70
|
+
const AS = Horner(A, s);
|
|
71
|
+
const BS = Horner(B, s);
|
|
72
|
+
// const CS = Horner(C, s);
|
|
73
|
+
// const DS = Horner(D, s);
|
|
74
|
+
|
|
75
|
+
const _AS = abs(AS);
|
|
76
|
+
// const _CS = abs(CS);
|
|
77
|
+
|
|
78
|
+
// if (max(_AS, _CS) < 2**-40) { continue; }
|
|
79
|
+
if (max(_AS) < 2**-40) { continue; }
|
|
80
|
+
|
|
81
|
+
// const w = _AS > _CS
|
|
82
|
+
// ? -BS / AS
|
|
83
|
+
// : -DS / CS; // alternative
|
|
84
|
+
const w = -BS / AS;
|
|
85
|
+
|
|
86
|
+
if (w <= 0) {
|
|
87
|
+
// If `w` is negative the circle radius is negative -> discard
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const V = [w*nnorm[0], w*nnorm[1]];
|
|
92
|
+
const d = sqrt(lengthSquared(V));
|
|
93
|
+
|
|
94
|
+
if (d <= 2**(maxCoordPowerOf2 - 40)) {
|
|
95
|
+
// If `w` <= 2**-40 -> discard
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const x = [y[0] + V[0], y[1] + V[1]];
|
|
100
|
+
//-----------------------
|
|
101
|
+
|
|
102
|
+
if (ri.tS <= tS && ri.tE >= tS) {
|
|
103
|
+
startPushed = true;
|
|
104
|
+
}
|
|
105
|
+
if (ri.tS <= tE && ri.tE >= tE) {
|
|
106
|
+
endPushed = true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
// If the point is the first control point of the curve then we
|
|
111
|
+
// ensure the point becomes the last control point of the prior
|
|
112
|
+
// curve to induce some symmetery and simplify the algorithm.
|
|
113
|
+
const s_ = s === 0 ? 1 : s;
|
|
114
|
+
const curve_ = s === 0 ? curve.prev : curve;
|
|
115
|
+
|
|
116
|
+
const info: AntipodalPoint = {
|
|
117
|
+
curve: curve_,
|
|
118
|
+
s: s_,
|
|
119
|
+
d, x
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
infos.push(info);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
//------------------------------------------
|
|
129
|
+
const pLast = ps[ps.length - 1];
|
|
130
|
+
|
|
131
|
+
let dontPush1 = (
|
|
132
|
+
(t === 0 && curve === touchedCurve!.prev) ||
|
|
133
|
+
(t === 1 && curve === touchedCurve)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
//--------------------------------------
|
|
138
|
+
// Also check curve start control point
|
|
139
|
+
//--------------------------------------
|
|
140
|
+
const PS: { P: number[], t: number }[] = [];
|
|
141
|
+
if (tS === 0) {
|
|
142
|
+
// We never check points at `t === 0` since they are covered by the previous curve's endpoint
|
|
143
|
+
// which cannot be culled if this curve`s `t === 0` is included
|
|
144
|
+
} else if (tS === 1) {
|
|
145
|
+
if (!dontPush1 && !startPushed) {
|
|
146
|
+
PS.push({ P: pLast, t: 1 });
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
if (!startPushed) {
|
|
150
|
+
const pp = evalDeCasteljau(ps, tS);
|
|
151
|
+
PS.push({ P: pp, t: tS });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//--------------------------------------
|
|
156
|
+
// Also check curve end control point
|
|
157
|
+
//--------------------------------------
|
|
158
|
+
if (tS !== tE) {
|
|
159
|
+
if (tE === 0) {
|
|
160
|
+
// We never check points at `t === 0` since they are covered by the previous curve's endpoint
|
|
161
|
+
// which cannot be culled if this curve`s `t === 0` is included
|
|
162
|
+
} else if (tE === 1) {
|
|
163
|
+
if (!dontPush1 && !endPushed) {
|
|
164
|
+
PS.push({ P: pLast, t: 1 }); dontPush1 = true;
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
if (!endPushed) {
|
|
168
|
+
const pp = evalDeCasteljau(ps, tE);
|
|
169
|
+
PS.push({ P: pp, t: tE });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//------------------------------------------
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
for (let i=0; i<PS.length; i++) {
|
|
177
|
+
//-----------------------
|
|
178
|
+
const { P, t: s } = PS[i];
|
|
179
|
+
const { a0, b0 } = getMedialPointCoeffsBez0(y,nnorm,P);
|
|
180
|
+
|
|
181
|
+
if (abs(a0) <= 2**-40 || abs(b0) <= 2**-40) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const w = -b0 / a0;
|
|
186
|
+
|
|
187
|
+
// too close to point of origin *or* negative;
|
|
188
|
+
if (w < 2**-40) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const V = [w*nnorm[0], w*nnorm[1]];
|
|
193
|
+
const d = sqrt(lengthSquared(V));
|
|
194
|
+
|
|
195
|
+
const x = [y[0] + V[0], y[1] + V[1]];
|
|
196
|
+
|
|
197
|
+
const s_ = s === 0 ? 1 : s;
|
|
198
|
+
const curve_ = s === 0 ? curve.prev : curve;
|
|
199
|
+
|
|
200
|
+
const info: AntipodalPoint = {
|
|
201
|
+
curve: curve_,
|
|
202
|
+
s: s_,
|
|
203
|
+
d, x
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
infos.push(info);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return infos;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
export { getClosestPoint }
|
|
@@ -2,12 +2,19 @@ import type { RootInterval } from 'flo-poly';
|
|
|
2
2
|
import type { CurvePiece } from "../../mat/curve-piece.js";
|
|
3
3
|
import type { PrePointOnShape } from "../../point-on-shape/point-on-shape.js";
|
|
4
4
|
import type { AntipodalPoint } from './antipodal-point.js';
|
|
5
|
+
import { ddMultDouble1 } from 'double-double';
|
|
5
6
|
import { lengthSquared } from "flo-vector2d";
|
|
6
|
-
import { roots,
|
|
7
|
-
import { evalDeCasteljau, getMedialPointCoeffs, getMedialPointCoeffsBez0
|
|
7
|
+
import { roots, Horner, ddHorner } from 'flo-poly';
|
|
8
|
+
import { evalDeCasteljau, getMedialPointCoeffs, getMedialPointCoeffsBez0 } from 'flo-bezier3';
|
|
9
|
+
import { ddGetMedialPointCoeffs } from '../../get-medial-points/double-double/dd-get-medial-point-coeffs.js';
|
|
10
|
+
import { ddGetMedialPointCoeffsBez2_SameCurve } from '../../get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js';
|
|
11
|
+
import { ddGetMedialPointCoeffsBez3_SameCurve } from '../../get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js';
|
|
12
|
+
import { ddGetMedialPointCoeffsBez0 } from '../../get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js';
|
|
8
13
|
|
|
9
14
|
const { sqrt, abs, max } = Math;
|
|
10
15
|
|
|
16
|
+
const qmd = ddMultDouble1;
|
|
17
|
+
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* @param maxCoordPowerOf2
|
|
@@ -22,6 +29,7 @@ const { sqrt, abs, max } = Math;
|
|
|
22
29
|
function getClosestPoint(
|
|
23
30
|
maxCoordPowerOf2: number,
|
|
24
31
|
nnorm: number[],
|
|
32
|
+
nnormDd: number[][],
|
|
25
33
|
yPos: PrePointOnShape,
|
|
26
34
|
for1Prong: boolean,
|
|
27
35
|
angle: number,
|
|
@@ -29,7 +37,7 @@ function getClosestPoint(
|
|
|
29
37
|
|
|
30
38
|
const { curve, ts: [tS,tE] } = curvePiece;
|
|
31
39
|
const { ps } = curve;
|
|
32
|
-
const { curve: touchedCurve, t, p: y } = yPos;
|
|
40
|
+
const { curve: touchedCurve, t, p: y, pDd: yDd } = yPos;
|
|
33
41
|
|
|
34
42
|
const isTouched = curve === touchedCurve;
|
|
35
43
|
const shouldDeflate = angle === 0 && isTouched;
|
|
@@ -42,11 +50,14 @@ function getClosestPoint(
|
|
|
42
50
|
if (tS !== tE &&
|
|
43
51
|
!(shouldDeflate && ps.length === 2) &&
|
|
44
52
|
!(isTouched && ps.length === 3 && for1Prong)) {
|
|
53
|
+
|
|
45
54
|
const { A, B, H } = shouldDeflate
|
|
46
55
|
? ps.length === 3
|
|
47
|
-
?
|
|
48
|
-
:
|
|
49
|
-
:
|
|
56
|
+
? ddGetMedialPointCoeffsBez2_SameCurve(t, nnormDd, ps)
|
|
57
|
+
: ddGetMedialPointCoeffsBez3_SameCurve(t, nnormDd, ps)
|
|
58
|
+
: ddGetMedialPointCoeffs(yDd, nnormDd, ps);
|
|
59
|
+
|
|
60
|
+
// const Hd = H.map(h => h[0] + h[1]);
|
|
50
61
|
|
|
51
62
|
ss = roots(H, tS, tE) || [];
|
|
52
63
|
//-----------------------
|
|
@@ -65,8 +76,14 @@ function getClosestPoint(
|
|
|
65
76
|
const s = sE > 1 ? 1 : _s;
|
|
66
77
|
|
|
67
78
|
//-----------------------
|
|
68
|
-
const AS = Horner(A, s);
|
|
69
|
-
const BS = Horner(B, s);
|
|
79
|
+
// const AS = Horner(A, s);
|
|
80
|
+
// const BS = Horner(B, s);
|
|
81
|
+
|
|
82
|
+
const ASDd = ddHorner(A, s);
|
|
83
|
+
const BSDd = ddHorner(B, s);
|
|
84
|
+
const AS = ASDd[0] + ASDd[1];
|
|
85
|
+
const BS = BSDd[0] + BSDd[1];
|
|
86
|
+
|
|
70
87
|
// const CS = Horner(C, s);
|
|
71
88
|
// const DS = Horner(D, s);
|
|
72
89
|
|
|
@@ -86,7 +103,8 @@ function getClosestPoint(
|
|
|
86
103
|
continue;
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
const
|
|
106
|
+
const VDd = [qmd(w, nnormDd[0]), qmd(w, nnormDd[1])];
|
|
107
|
+
const V = [VDd[0][1], VDd[1][1]];
|
|
90
108
|
const d = sqrt(lengthSquared(V));
|
|
91
109
|
|
|
92
110
|
if (d <= 2**(maxCoordPowerOf2 - 40)) {
|
|
@@ -174,20 +192,21 @@ function getClosestPoint(
|
|
|
174
192
|
for (let i=0; i<PS.length; i++) {
|
|
175
193
|
//-----------------------
|
|
176
194
|
const { P, t: s } = PS[i];
|
|
177
|
-
const { a0, b0 } =
|
|
195
|
+
const { a0, b0 } = ddGetMedialPointCoeffsBez0(yDd, nnormDd, P);
|
|
178
196
|
|
|
179
|
-
if (abs(a0) <= 2**-40 || abs(b0) <= 2**-40) {
|
|
197
|
+
if (abs(a0[1]) <= 2**-40 || abs(b0[1]) <= 2**-40) {
|
|
180
198
|
continue;
|
|
181
199
|
}
|
|
182
200
|
|
|
183
|
-
const w = -b0 / a0;
|
|
201
|
+
const w = -b0[1] / a0[1];
|
|
184
202
|
|
|
185
203
|
// too close to point of origin *or* negative;
|
|
186
204
|
if (w < 2**-40) {
|
|
187
205
|
continue;
|
|
188
206
|
}
|
|
189
207
|
|
|
190
|
-
const
|
|
208
|
+
const VDd = [qmd(w, nnormDd[0]), qmd(w, nnormDd[1])];
|
|
209
|
+
const V = [VDd[0][1], VDd[1][1]];
|
|
191
210
|
const d = sqrt(lengthSquared(V));
|
|
192
211
|
|
|
193
212
|
const x = [y[0] + V[0], y[1] + V[1]];
|
|
@@ -209,3 +228,45 @@ function getClosestPoint(
|
|
|
209
228
|
|
|
210
229
|
|
|
211
230
|
export { getClosestPoint }
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Recovers a numerically stable ray parameter `t` from linear equations
|
|
236
|
+
* `A*t + B = 0` and (optionally) `C*t + D = 0` evaluated at a fixed `s`.
|
|
237
|
+
*
|
|
238
|
+
* If `C,D` are unavailable, this falls back to `-B/A`.
|
|
239
|
+
*/
|
|
240
|
+
// function chooseStableT(
|
|
241
|
+
// A: number,
|
|
242
|
+
// B: number,
|
|
243
|
+
// C: number,
|
|
244
|
+
// D: number) {
|
|
245
|
+
|
|
246
|
+
// const epsScale = max(1, abs(A), abs(B), abs(C), abs(D));
|
|
247
|
+
// const eps = Number.EPSILON * epsScale;
|
|
248
|
+
|
|
249
|
+
// const denomAB = abs(A);
|
|
250
|
+
// const hasAB = denomAB > eps;
|
|
251
|
+
// const denomCD = abs(C);
|
|
252
|
+
// const hasCD = denomCD > eps;
|
|
253
|
+
|
|
254
|
+
// if (!hasAB && !hasCD) {
|
|
255
|
+
// return undefined;
|
|
256
|
+
// }
|
|
257
|
+
// if (hasAB && !hasCD) {
|
|
258
|
+
// return -B / A;
|
|
259
|
+
// }
|
|
260
|
+
// if (!hasAB && hasCD) {
|
|
261
|
+
// return -D / C;
|
|
262
|
+
// }
|
|
263
|
+
|
|
264
|
+
// const tAB = -B / A;
|
|
265
|
+
// const tCD = -D / C;
|
|
266
|
+
|
|
267
|
+
// // Score each candidate by how well it satisfies the *other* equation.
|
|
268
|
+
// const scoreAB = abs(C*tAB + D) / (abs(C) + abs(D) + eps);
|
|
269
|
+
// const scoreCD = abs(A*tCD + B) / (abs(A) + abs(B) + eps);
|
|
270
|
+
|
|
271
|
+
// return scoreAB <= scoreCD ? tAB : tCD;
|
|
272
|
+
// }
|
|
@@ -11,15 +11,18 @@ const TOLERANCE = 1 + 2**-20;
|
|
|
11
11
|
/**
|
|
12
12
|
* Reduces the circle radius initially as an optimization step.
|
|
13
13
|
*
|
|
14
|
+
* @param rO maximum possible initial radius
|
|
15
|
+
*
|
|
14
16
|
* @internal
|
|
15
17
|
*/
|
|
16
18
|
function reduceRadius(
|
|
17
19
|
maxCoordPowerOf2: number,
|
|
20
|
+
rO: number,
|
|
18
21
|
curvePieces: CurvePiece[],
|
|
19
22
|
y: number[],
|
|
20
23
|
nnorm: number[]): number {
|
|
21
24
|
|
|
22
|
-
let
|
|
25
|
+
let minRadiusSqrd = rO**2;
|
|
23
26
|
let x = [y[0] + nnorm[0], y[1] + nnorm[1]];
|
|
24
27
|
|
|
25
28
|
for (let i=0; i<curvePieces.length; i++) {
|
|
@@ -31,7 +34,7 @@ function reduceRadius(
|
|
|
31
34
|
const pE = ps[ps.length - 1];
|
|
32
35
|
|
|
33
36
|
for (const P of [pS,pE]) {
|
|
34
|
-
if (squaredDistanceBetween(x,P) >
|
|
37
|
+
if (squaredDistanceBetween(x,P) > minRadiusSqrd) {
|
|
35
38
|
continue; // short-circuit
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -49,15 +52,15 @@ function reduceRadius(
|
|
|
49
52
|
const N = [w*nnorm[0], w*nnorm[1]];
|
|
50
53
|
const r = lengthSquared(N);
|
|
51
54
|
|
|
52
|
-
if (r <
|
|
53
|
-
|
|
55
|
+
if (r < minRadiusSqrd) {
|
|
56
|
+
minRadiusSqrd = r;
|
|
54
57
|
x = [y[0] + N[0], y[1] + N[1]];
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
// The extra bit is to account for floating point precision.
|
|
60
|
-
return TOLERANCE*
|
|
63
|
+
return TOLERANCE*minRadiusSqrd;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
2
2
|
import type { CurvePiece } from '../mat/curve-piece.js';
|
|
3
|
-
|
|
4
|
-
import { fromTo, len, scale, translate } from 'flo-vector2d';
|
|
5
|
-
import { circumCenter } from './timed-cc.js'; // TODO - testing - restore
|
|
3
|
+
import { circumCenter, fromTo, len, scale, translate } from 'flo-vector2d';
|
|
6
4
|
import { getCloseBoundaryPointsCertified } from '../closest-boundary-point/get-close-boundary-points-certified.js';
|
|
7
5
|
|
|
8
6
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CpNode } from '../cp-node/cp-node.js';
|
|
2
2
|
import type { CurvePiece } from '../mat/curve-piece.js';
|
|
3
|
-
|
|
4
|
-
import { circumCenter } from './timed-cc.js'; // TODO - testing - restore
|
|
3
|
+
import { circumCenter } from 'flo-vector2d';
|
|
5
4
|
import { getCloseBoundaryPointsCertified } from '../closest-boundary-point/get-close-boundary-points-certified.js';
|
|
6
5
|
|
|
7
6
|
|
|
@@ -2,9 +2,7 @@ import type { CpNode } from '../cp-node/cp-node.js';
|
|
|
2
2
|
import type { CurvePiece } from '../mat/curve-piece.js';
|
|
3
3
|
import type { ThreeProngInfo } from './three-prong-info.js';
|
|
4
4
|
import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
5
|
-
|
|
6
|
-
import { fromTo, len, distanceBetween, toUnitVector, rotate90Degrees, cross } from 'flo-vector2d';
|
|
7
|
-
import { circumCenter as getCircumCenter } from './timed-cc.js'; // TODO - testing - restore
|
|
5
|
+
import { circumCenter as getCircumCenter, fromTo, len, distanceBetween, toUnitVector, rotate90Degrees, cross } from 'flo-vector2d';
|
|
8
6
|
import { tangent } from 'flo-bezier3';
|
|
9
7
|
import { calcInitial3ProngCenter } from './calc-initial-3-prong-center.js';
|
|
10
8
|
import { getClosestPoints } from './get-closest-points.js';
|
|
@@ -69,7 +67,6 @@ function find3ProngForDelta3s(
|
|
|
69
67
|
|
|
70
68
|
if (isSharp(δ3s[0][0])) { return undefined; }
|
|
71
69
|
|
|
72
|
-
// TODO
|
|
73
70
|
//----------------------------
|
|
74
71
|
// const l1 = curvePiece3s[0].length;
|
|
75
72
|
// const l2 = curvePiece3s[1].length;
|