flo-mat 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +69 -0
- package/README.md +9 -27
- package/browser/index.js +29604 -7008
- package/browser/index.min.js +1 -2
- package/node/circle.d.ts +20 -20
- package/node/circle.js +31 -31
- package/node/circle.js.map +1 -1
- package/node/compare-curvatures-at-interface.d.ts +19 -19
- package/node/compare-curvatures-at-interface.js +124 -124
- package/node/compare-curvatures-at-interface.js.map +1 -1
- package/node/contact-point.d.ts +26 -26
- package/node/contact-point.js +25 -25
- package/node/cp-node/clone.d.ts +8 -8
- package/node/cp-node/clone.js +31 -31
- package/node/cp-node/clone.js.map +1 -1
- package/node/cp-node/remove.d.ts +9 -9
- package/node/cp-node/remove.js +19 -19
- package/node/cp-node/remove.js.map +1 -1
- package/node/cp-node.d.ts +202 -202
- package/node/cp-node.js +320 -320
- package/node/cp-node.js.map +1 -1
- package/node/curve.d.ts +46 -46
- package/node/curve.js +88 -88
- package/node/curve.js.map +1 -1
- package/node/debug/cp-node-for-debugging.d.ts +11 -11
- package/node/debug/cp-node-for-debugging.js +1 -1
- package/node/debug/debug-elem-types.d.ts +32 -32
- package/node/debug/debug-elem-types.js +1 -1
- package/node/debug/debug.d.ts +50 -50
- package/node/debug/debug.js +75 -75
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/branch.d.ts +4 -4
- package/node/debug/functions/draw-elem/branch.js +22 -22
- package/node/debug/functions/draw-elem/branch.js.map +1 -1
- package/node/debug/functions/draw-elem/culls.d.ts +4 -4
- package/node/debug/functions/draw-elem/culls.js +21 -21
- package/node/debug/functions/draw-elem/culls.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
- package/node/debug/functions/draw-elem/draw-elem.js +45 -45
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/dull-corner.js +10 -10
- package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
- package/node/debug/functions/draw-elem/leaves.js +12 -12
- package/node/debug/functions/draw-elem/leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/loop.d.ts +4 -4
- package/node/debug/functions/draw-elem/loop.js +11 -11
- package/node/debug/functions/draw-elem/loops.d.ts +4 -4
- package/node/debug/functions/draw-elem/loops.js +6 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
- package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/mat.d.ts +4 -4
- package/node/debug/functions/draw-elem/mat.js +30 -30
- package/node/debug/functions/draw-elem/mat.js.map +1 -1
- package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/max-vertex.js +8 -8
- package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
- package/node/debug/functions/draw-elem/min-y.js +13 -13
- package/node/debug/functions/draw-elem/min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong.js +16 -16
- package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
- package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/three-prong.js +16 -16
- package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
- package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/two-prong.js +36 -36
- package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/vertex.js +27 -27
- package/node/debug/functions/draw-elem/vertex.js.map +1 -1
- package/node/debug/functions/general.d.ts +48 -48
- package/node/debug/functions/general.js +52 -52
- package/node/debug/functions/general.js.map +1 -1
- package/node/debug/functions/three-prong.d.ts +11 -11
- package/node/debug/functions/three-prong.js +184 -184
- package/node/debug/functions/three-prong.js.map +1 -1
- package/node/debug/functions/two-prong.d.ts +13 -13
- package/node/debug/functions/two-prong.js +117 -117
- package/node/debug/functions/two-prong.js.map +1 -1
- package/node/debug/three-prong-for-debugging.d.ts +31 -31
- package/node/debug/three-prong-for-debugging.js +20 -20
- package/node/debug/two-prong-for-debugging.d.ts +26 -26
- package/node/debug/two-prong-for-debugging.js +1 -1
- package/node/find-mats.d.ts +26 -26
- package/node/find-mats.js +122 -125
- package/node/find-mats.js.map +1 -1
- package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
- package/node/get-boundary-bezier-parts-to-next.js +42 -42
- package/node/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/get-boundary-beziers-to-next.d.ts +8 -8
- package/node/get-boundary-beziers-to-next.js +44 -44
- package/node/get-boundary-beziers-to-next.js.map +1 -1
- package/node/get-bounding-box-.d.ts +2 -2
- package/node/get-bounding-box-.js +4 -4
- package/node/get-branches.d.ts +12 -12
- package/node/get-branches.js +68 -68
- package/node/get-branches.js.map +1 -1
- package/node/get-curve/get-curve-between.d.ts +9 -9
- package/node/get-curve/get-curve-between.js +56 -56
- package/node/get-curve/get-curve-between.js.map +1 -1
- package/node/get-curve/get-edge-direction.d.ts +9 -9
- package/node/get-curve/get-edge-direction.js +53 -53
- package/node/get-curve/get-edge-direction.js.map +1 -1
- package/node/get-curve-to-next.d.ts +9 -9
- package/node/get-curve-to-next.js +11 -11
- package/node/get-interface-ccw.d.ts +24 -24
- package/node/get-interface-ccw.js +97 -97
- package/node/get-interface-ccw.js.map +1 -1
- package/node/index.d.ts +36 -36
- package/node/index.js +32 -32
- package/node/loop/get-max-coordinate.d.ts +10 -10
- package/node/loop/get-max-coordinate.js +43 -43
- package/node/loop/get-max-coordinate.js.map +1 -1
- package/node/loop.d.ts +16 -16
- package/node/loop.js +34 -34
- package/node/loop.js.map +1 -1
- package/node/mat/add-to-cp-graph.d.ts +16 -16
- package/node/mat/add-to-cp-graph.js +30 -30
- package/node/mat/add-to-cp-graph.js.map +1 -1
- package/node/mat/bezier-piece.d.ts +12 -12
- package/node/mat/bezier-piece.js +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -73
- package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
- package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
- package/node/mat/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
- package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +1 -1
- package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
- package/node/mat/corner.d.ts +37 -37
- package/node/mat/corner.js +1 -1
- package/node/mat/create-new-cp-tree.d.ts +9 -9
- package/node/mat/create-new-cp-tree.js +23 -23
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/elem-type-two-prong.d.ts +3 -3
- package/node/mat/elem-type-two-prong.js +1 -1
- package/node/mat/find-mat/add-1-prong.d.ts +12 -12
- package/node/mat/find-mat/add-1-prong.js +42 -42
- package/node/mat/find-mat/add-1-prong.js.map +1 -1
- package/node/mat/find-mat/add-2-prong.d.ts +21 -21
- package/node/mat/find-mat/add-2-prong.js +192 -192
- package/node/mat/find-mat/add-2-prong.js.map +1 -1
- package/node/mat/find-mat/add-3-prong.d.ts +19 -19
- package/node/mat/find-mat/add-3-prong.js +54 -54
- package/node/mat/find-mat/add-3-prong.js.map +1 -1
- package/node/mat/find-mat/add-debug-info.d.ts +9 -9
- package/node/mat/find-mat/add-debug-info.js +67 -69
- package/node/mat/find-mat/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +1 -1
- package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
- package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
- package/node/mat/find-mat/create-initial-cp-graph.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
- package/node/mat/find-mat/find-2-prong/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
- package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
- package/node/mat/find-mat/find-3-prong/calc-better-x.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
- package/node/mat/find-mat/find-3-prong/find-3-prong.js.map +1 -1
- package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
- package/node/mat/find-mat/find-3-prong/get-closest-points.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js.map +1 -1
- package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs.js +73 -74
- package/node/mat/find-mat/find-and-add-2-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
- package/node/mat/find-mat/find-and-add-3-prongs.js +146 -147
- package/node/mat/find-mat/find-and-add-3-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
- package/node/mat/find-mat/get-potential-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
- package/node/mat/find-mat/get-sharp-corners.js +17 -17
- package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
- package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
- package/node/mat/get-boundary-piece-beziers.js +58 -58
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
- package/node/mat/get-contact-circles-at-interface.js +20 -20
- package/node/mat/get-contact-circles-at-interface.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +4 -4
- package/node/mat/get-largest-vertex.js +9 -9
- package/node/mat/get-leaves.d.ts +4 -4
- package/node/mat/get-leaves.js +12 -12
- package/node/mat/get-leaves.js.map +1 -1
- package/node/mat/get-neighboring-cps.d.ts +14 -14
- package/node/mat/get-neighboring-cps.js +30 -30
- package/node/mat/get-neighboring-cps.js.map +1 -1
- package/node/mat/get-two-prong-type.d.ts +5 -5
- package/node/mat/get-two-prong-type.js +8 -8
- package/node/mat/is-another-cp-closeby.d.ts +20 -20
- package/node/mat/is-another-cp-closeby.js +55 -55
- package/node/mat/is-another-cp-closeby.js.map +1 -1
- package/node/mat/simplify-mat-map-only.d.ts +23 -23
- package/node/mat/simplify-mat-map-only.js +80 -80
- package/node/mat/simplify-mat-map-only.js.map +1 -1
- package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
- package/node/mat/to-scale-axis/add-debug-info.js +13 -13
- package/node/mat/to-scale-axis/add-debug-info.js.map +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
- package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
- package/node/mat/to-scale-axis/cull-non-cycles.js.map +1 -1
- package/node/mat/to-scale-axis/cull.d.ts +12 -12
- package/node/mat/to-scale-axis/cull.js +132 -132
- package/node/mat/to-scale-axis/cull.js.map +1 -1
- package/node/mat/trim-mat.d.ts +8 -8
- package/node/mat/trim-mat.js +16 -16
- package/node/mat/trim-mat.js.map +1 -1
- package/node/mat.d.ts +22 -22
- package/node/mat.js +1 -1
- package/node/point-on-shape.d.ts +73 -73
- package/node/point-on-shape.js +167 -167
- package/node/point-on-shape.js.map +1 -1
- package/node/simplify-mat.d.ts +16 -16
- package/node/simplify-mat.js +71 -71
- package/node/simplify-mat.js.map +1 -1
- package/node/svg/get-loop-bounds.d.ts +12 -12
- package/node/svg/get-loop-bounds.js +80 -80
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.d.ts +8 -8
- package/node/svg/get-min-y-pos.js +9 -9
- package/node/svg/get-shape-bounds.d.ts +9 -9
- package/node/svg/get-shape-bounds.js +35 -35
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.d.ts +18 -18
- package/node/sweep-line/sweep-line.js +72 -72
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/to-scale-axis.d.ts +16 -16
- package/node/to-scale-axis.js +74 -73
- package/node/to-scale-axis.js.map +1 -1
- package/node/traverse-edges.d.ts +10 -10
- package/node/traverse-edges.js +21 -21
- package/node/traverse-edges.js.map +1 -1
- package/node/traverse-vertices.d.ts +12 -12
- package/node/traverse-vertices.js +27 -27
- package/node/traverse-vertices.js.map +1 -1
- package/package.json +29 -24
- package/src/circle.ts +3 -3
- package/src/compare-curvatures-at-interface.ts +36 -36
- package/src/cp-node/clone.ts +6 -6
- package/src/cp-node/remove.ts +4 -4
- package/src/cp-node.ts +20 -20
- package/src/curve.ts +19 -19
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/branch.ts +4 -4
- package/src/debug/functions/draw-elem/culls.ts +4 -4
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +2 -2
- package/src/debug/functions/draw-elem/draw-elem.ts +1 -1
- package/src/debug/functions/draw-elem/dull-corner.ts +3 -3
- package/src/debug/functions/draw-elem/leaves.ts +4 -4
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +2 -2
- package/src/debug/functions/draw-elem/mat.ts +4 -4
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +3 -3
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +4 -4
- package/src/debug/functions/draw-elem/one-prong.ts +4 -4
- package/src/debug/functions/draw-elem/sharp-corner.ts +2 -2
- package/src/debug/functions/draw-elem/three-prong.ts +7 -7
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +1 -1
- package/src/debug/functions/draw-elem/two-prong.ts +1 -1
- package/src/debug/functions/draw-elem/vertex.ts +20 -14
- package/src/debug/functions/general.ts +3 -3
- package/src/debug/functions/three-prong.ts +37 -37
- package/src/debug/functions/two-prong.ts +15 -15
- package/src/find-mats.ts +19 -19
- package/src/get-boundary-bezier-parts-to-next.ts +8 -8
- package/src/get-boundary-beziers-to-next.ts +8 -8
- package/src/get-branches.ts +7 -7
- package/src/get-curve/get-curve-between.ts +21 -21
- package/src/get-curve/get-edge-direction.ts +13 -14
- package/src/get-interface-ccw.ts +12 -12
- package/src/loop/get-max-coordinate.ts +7 -7
- package/src/loop.ts +4 -4
- package/src/mat/add-to-cp-graph.ts +8 -8
- package/src/mat/closest-boundary-point/closest-points-on-curve.ts +5 -6
- package/src/mat/closest-boundary-point/cull-bezier-pieces.ts +1 -1
- package/src/mat/closest-boundary-point/cull-by-loose-bounding-box.ts +5 -5
- package/src/mat/closest-boundary-point/cull-by-tight-boundary-box.ts +5 -5
- package/src/mat/closest-boundary-point/get-best-distance-squared.ts +5 -5
- package/src/mat/closest-boundary-point/get-close-boundary-points.ts +15 -15
- package/src/mat/closest-boundary-point/get-closest-boundary-point.ts +4 -4
- package/src/mat/cmp-cp-on-delta.ts +5 -5
- package/src/mat/create-new-cp-tree.ts +3 -3
- package/src/mat/find-mat/add-1-prong.ts +5 -5
- package/src/mat/find-mat/add-2-prong.ts +42 -42
- package/src/mat/find-mat/add-3-prong.ts +1 -1
- package/src/mat/find-mat/add-debug-info.ts +18 -20
- package/src/mat/find-mat/create-get-interesting-points-on-loop.ts +4 -4
- package/src/mat/find-mat/create-initial-cp-graph.ts +11 -11
- package/src/mat/find-mat/find-2-prong/add-debug-info.ts +4 -4
- package/src/mat/find-mat/find-2-prong/cull-bezier-pieces.ts +5 -5
- package/src/mat/find-mat/find-2-prong/find-2-prong.ts +27 -27
- package/src/mat/find-mat/find-2-prong/find-equidistant-point-on-line.ts +7 -7
- package/src/mat/find-mat/find-2-prong/get-initial-bezier-pieces.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-better-x.ts +4 -4
- package/src/mat/find-mat/find-3-prong/calc-initial-3-prong-center.ts +3 -3
- package/src/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.ts +37 -37
- package/src/mat/find-mat/find-3-prong/find-3-prong.ts +16 -16
- package/src/mat/find-mat/find-3-prong/get-closest-points.ts +1 -1
- package/src/mat/find-mat/find-and-add-2-prongs-on-all-paths.ts +2 -2
- package/src/mat/find-mat/find-and-add-2-prongs.ts +14 -16
- package/src/mat/find-mat/find-and-add-3-prongs.ts +19 -19
- package/src/mat/find-mat/find-and-add-hole-closing-2-prongs.ts +6 -6
- package/src/mat/find-mat/get-potential-2-prongs.ts +4 -4
- package/src/mat/find-mat/get-sharp-corners.ts +4 -4
- package/src/mat/find-mat/get-total-abs-curvature.ts +1 -1
- package/src/mat/geometry/get-closest-squared-distance-to-rotated-rect.ts +3 -3
- package/src/mat/get-boundary-piece-beziers.ts +5 -5
- package/src/mat/get-contact-circles-at-interface.ts +1 -1
- package/src/mat/get-edges-as-array.ts +2 -2
- package/src/mat/get-leaves.ts +2 -2
- package/src/mat/get-neighboring-cps.ts +1 -1
- package/src/mat/is-another-cp-closeby.ts +9 -9
- package/src/mat/simplify-mat-map-only.ts +15 -15
- package/src/mat/to-scale-axis/add-debug-info.ts +6 -3
- package/src/mat/to-scale-axis/add-to-tree.ts +10 -10
- package/src/mat/to-scale-axis/calc-groups.ts +19 -19
- package/src/mat/to-scale-axis/create-spacial-tree.ts +4 -4
- package/src/mat/to-scale-axis/cull-non-cycles.ts +5 -5
- package/src/mat/to-scale-axis/cull.ts +5 -5
- package/src/mat/to-scale-axis/get-engulfed-vertices.ts +18 -18
- package/src/mat/trim-mat.ts +1 -1
- package/src/point-on-shape.ts +16 -16
- package/src/simplify-mat.ts +10 -10
- package/src/svg/get-curvature-at-interface.ts +6 -8
- package/src/svg/get-extreme.ts +1 -1
- package/src/svg/get-loop-bounds.ts +13 -13
- package/src/svg/get-shape-bounds.ts +4 -4
- package/src/sweep-line/are-boxes-intersecting.ts +4 -4
- package/src/sweep-line/sweep-line.ts +8 -8
- package/src/to-scale-axis.ts +18 -17
- package/src/traverse-edges.ts +2 -2
- package/src/traverse-vertices.ts +2 -2
- package/tsconfig.json +0 -1
- package/webpack.config.cjs +12 -63
- package/browser/index.min.js.LICENSE.txt +0 -2819
- package/browser/index.module.js +0 -7149
- package/browser/index.module.min.js +0 -2
- package/browser/index.module.min.js.LICENSE.txt +0 -2819
|
@@ -6,13 +6,11 @@ import { Mat } from '../../mat.js';
|
|
|
6
6
|
import { getBoundingBox_ } from '../../get-bounding-box-.js';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
/** @
|
|
10
|
-
declare
|
|
9
|
+
/** @internal */
|
|
10
|
+
declare const _debug_: Debug;
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
var timingStart: number;
|
|
15
|
-
}
|
|
13
|
+
let timingStart: number;
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
/** @hidden */
|
|
@@ -21,30 +19,30 @@ function addDebugInfo1(loops: Loop[]) {
|
|
|
21
19
|
|
|
22
20
|
timingStart = performance.now();
|
|
23
21
|
|
|
24
|
-
for (
|
|
22
|
+
for (const loop of loops) {
|
|
25
23
|
_debug_.fs.nameObj(loop,'l|');
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
const generated = _debug_.generated;
|
|
29
27
|
|
|
30
28
|
//generated.elems.loop.push(...loops);
|
|
31
29
|
//generated.elems.loops.push(loops);
|
|
32
30
|
|
|
33
|
-
for (
|
|
31
|
+
for (const loop of loops) {
|
|
34
32
|
let i = 0;
|
|
35
33
|
loop.curves.forEach(function(curve: Curve) {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const ps = curve.ps;
|
|
35
|
+
const hull = getBoundingHull(ps);
|
|
38
36
|
|
|
39
37
|
generated.elems.boundingHull.push(hull);
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
const looseBoundingBox = getBoundingBox_(ps);
|
|
42
40
|
generated.elems.looseBoundingBox.push(looseBoundingBox);
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
const tightBoundingBox = getBoundingBoxTight(ps);
|
|
45
43
|
generated.elems.tightBoundingBox.push(tightBoundingBox);
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
const corner = getCornerAtEnd(curve);
|
|
48
46
|
if (corner.isSharp) {
|
|
49
47
|
generated.elems.sharpCorner.push(curve);
|
|
50
48
|
} else if (corner.isDull) {
|
|
@@ -61,8 +59,8 @@ function addDebugInfo1(loops: Loop[]) {
|
|
|
61
59
|
function addDebugInfo2() {
|
|
62
60
|
if (typeof _debug_ === 'undefined') { return; }
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const timing = _debug_.generated.timing;
|
|
63
|
+
const now = performance.now();
|
|
66
64
|
timing.holeClosers += now - timingStart;
|
|
67
65
|
timingStart = now;
|
|
68
66
|
}
|
|
@@ -71,9 +69,9 @@ function addDebugInfo2() {
|
|
|
71
69
|
function addDebugInfo3() {
|
|
72
70
|
if (typeof _debug_ === 'undefined') { return; }
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
const generated = _debug_.generated;
|
|
73
|
+
const timing = generated.timing;
|
|
74
|
+
const now = performance.now();
|
|
77
75
|
|
|
78
76
|
timing.oneAnd2Prongs += now - timingStart;
|
|
79
77
|
timingStart = now;
|
|
@@ -83,8 +81,8 @@ function addDebugInfo3() {
|
|
|
83
81
|
function addDebugInfo4(mat: Mat) {
|
|
84
82
|
if (typeof _debug_ === 'undefined') { return; }
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const generated = _debug_.generated;
|
|
85
|
+
const timing = generated.timing;
|
|
88
86
|
|
|
89
87
|
generated.elems.mat.push(mat);
|
|
90
88
|
|
|
@@ -17,10 +17,10 @@ function getInterestingPointsOnLoop(
|
|
|
17
17
|
maxLength: number) {
|
|
18
18
|
|
|
19
19
|
return function(loop: Loop) {
|
|
20
|
-
|
|
20
|
+
const allPoints: IPointOnShape[] = [];
|
|
21
21
|
|
|
22
22
|
for (let i=0; i<loop.curves.length; i++) {
|
|
23
|
-
|
|
23
|
+
const curve = loop.curves[i];
|
|
24
24
|
|
|
25
25
|
// qqq if (lengthSquaredUpperBound(curve.ps) < minBezLength) {
|
|
26
26
|
if (controlPointLinesLength(curve.ps) < minBezLength) {
|
|
@@ -43,10 +43,10 @@ function getInterestingPointsOnLoop(
|
|
|
43
43
|
|
|
44
44
|
// let { maxima } = getCurvatureExtrema(curve.ps);
|
|
45
45
|
// qqq let { maxCurvatureTs, maxNegativeCurvatureTs } = getCurvatureExtrema(curve.ps);
|
|
46
|
-
|
|
46
|
+
const { maxima } = getCurvatureExtrema(curve.ps);
|
|
47
47
|
// let maxAbsCurvatures = maxima.map(t => new PointOnShape(curve, t));
|
|
48
48
|
// qqq let maxAbsCurvatures = [...maxCurvatureTs, ...maxNegativeCurvatureTs].map(t => new PointOnShape(curve, t));
|
|
49
|
-
|
|
49
|
+
const maxAbsCurvatures = [...maxima].map(t => new PointOnShape(curve, t));
|
|
50
50
|
|
|
51
51
|
allPoints.push(
|
|
52
52
|
...getContactCirclesAtInterface(curve),
|
|
@@ -20,22 +20,22 @@ function createInitialCpGraph(
|
|
|
20
20
|
let cpNode;
|
|
21
21
|
|
|
22
22
|
for (let k=0; k<sharpCornerss.length; k++) {
|
|
23
|
-
|
|
23
|
+
const sharpCorners = sharpCornerss[k];
|
|
24
24
|
|
|
25
|
-
// qqq
|
|
26
|
-
|
|
25
|
+
// qqq const cpTree = new LlRbTree(CpNode.comparator, [], true);
|
|
26
|
+
const cpTree = new LlRbTree(CpNode.comparator, false);
|
|
27
27
|
|
|
28
28
|
let cpNode1 = undefined;
|
|
29
29
|
let cpNode2 = undefined;
|
|
30
|
-
for (
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
30
|
+
for (const pos of sharpCorners) {
|
|
31
|
+
const ps = pos.curve.next.ps;
|
|
32
|
+
//const x = xMap.get(ps);
|
|
33
|
+
//const isIntersection = !!x;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
const circle = { center: pos.p, radius: 0 };
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const cp1: ContactPoint = { pointOnShape: pos, circle, order: -1, order2: 0 };
|
|
38
|
+
const cp2: ContactPoint = { pointOnShape: pos, circle, order: +1, order2: 0 };
|
|
39
39
|
|
|
40
40
|
cpNode1 = CpNode.insert(false, /*isIntersection*/ false, cpTree, cp1, cpNode2);
|
|
41
41
|
cpNode2 = CpNode.insert(false, /*isIntersection*/ false, cpTree, cp2, cpNode1);
|
|
@@ -49,7 +49,7 @@ function createInitialCpGraph(
|
|
|
49
49
|
|
|
50
50
|
if (!cpNode) { cpNode = cpNode1; }
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const loop = loops[k];
|
|
53
53
|
cpTrees.set(loop, cpTree);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
declare
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const _debug_: Debug;
|
|
3
3
|
|
|
4
4
|
import { Debug } from '../../../debug/debug.js';
|
|
5
5
|
import { IPointOnShape } from '../../../point-on-shape.js';
|
|
@@ -23,7 +23,7 @@ function addDebugInfo(
|
|
|
23
23
|
xs: TXForDebugging[],
|
|
24
24
|
holeClosing: boolean) {
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const twoProng: TwoProngForDebugging = {
|
|
27
27
|
generated: _debug_.generated,
|
|
28
28
|
bezierPieces,
|
|
29
29
|
pos,
|
|
@@ -38,7 +38,7 @@ function addDebugInfo(
|
|
|
38
38
|
cpNode: undefined
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const twoProngType = getTwoProngType(twoProng) as ElemType_TwoProng;
|
|
42
42
|
_debug_.generated.elems[twoProngType].push(twoProng);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -25,12 +25,12 @@ function cullBezierPieces(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
for (
|
|
30
|
-
|
|
28
|
+
const newPieces = [];
|
|
29
|
+
for (const bezierPiece of bezierPieces) {
|
|
30
|
+
const ps = bezierPiece.curve.ps;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const rect = getBoundingBox_(ps);
|
|
33
|
+
const bd = getClosestSquareDistanceToRect(rect, p);
|
|
34
34
|
if (bd <= rSquared * TOLERANCE) {
|
|
35
35
|
newPieces.push(bezierPiece);
|
|
36
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
declare
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const _debug_: Debug;
|
|
3
3
|
|
|
4
4
|
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
5
5
|
import { lineLineIntersection, distanceBetween, squaredDistanceBetween, interpolate, dot } from 'flo-vector2d';
|
|
@@ -67,7 +67,7 @@ function find2Prong(
|
|
|
67
67
|
|
|
68
68
|
// The boundary piece that should contain the other point of
|
|
69
69
|
// the 2-prong circle. (Defined by start and end points).
|
|
70
|
-
|
|
70
|
+
const { bezierPieces, δ } = getInitialBezierPieces(
|
|
71
71
|
isHoleClosing, k, loops, cpTrees, y
|
|
72
72
|
);
|
|
73
73
|
//console.log(bezierPieces.length)
|
|
@@ -88,14 +88,14 @@ function find2Prong(
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// The lines below is an optimization.
|
|
91
|
-
|
|
91
|
+
const r_ = reduceRadius(extreme, bezierPieces, p, x);
|
|
92
92
|
if (r > r_) {
|
|
93
93
|
x = interpolate(p, x, Math.sqrt(r_/r));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
/** Trace the convergence (for debugging). */
|
|
98
|
-
|
|
98
|
+
const xs: TXForDebugging[] = [];
|
|
99
99
|
/** The antipode of the two-prong (successively refined) */
|
|
100
100
|
let z: { pos: IPointOnShape; d: number };
|
|
101
101
|
let i = 0;
|
|
@@ -107,7 +107,7 @@ function find2Prong(
|
|
|
107
107
|
i++
|
|
108
108
|
|
|
109
109
|
/** squared distance between source boundary point and circle center */
|
|
110
|
-
|
|
110
|
+
const r = squaredDistanceBetween(x, y.p);
|
|
111
111
|
|
|
112
112
|
bezierPieces_ = cullBezierPieces(bezierPieces_, x, r);
|
|
113
113
|
|
|
@@ -120,11 +120,11 @@ function find2Prong(
|
|
|
120
120
|
|
|
121
121
|
if (z === undefined) {
|
|
122
122
|
if (typeof _debug_ !== 'undefined') {
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const elems = _debug_.generated.elems;
|
|
124
|
+
const elem = isHoleClosing
|
|
125
125
|
? elems.twoProng_holeClosing
|
|
126
126
|
: elems.twoProng_regular
|
|
127
|
-
|
|
127
|
+
const elemStr = isHoleClosing
|
|
128
128
|
? 'hole-closing: ' + elem.length
|
|
129
129
|
: 'regular: ' + elem.length;
|
|
130
130
|
console.log(
|
|
@@ -140,7 +140,7 @@ function find2Prong(
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** squared distance between anti-pode boundary point and circle center */
|
|
143
|
-
|
|
143
|
+
const d = squaredDistanceBetween(x, z.pos.p);
|
|
144
144
|
//if (i === 1 && d*oneProngTolerance >= r) {
|
|
145
145
|
if (i === 1 && r < d+oneProngTolerance) {
|
|
146
146
|
// It is a 1-prong.
|
|
@@ -174,9 +174,9 @@ function find2Prong(
|
|
|
174
174
|
|
|
175
175
|
// Find the point on the line connecting y with x that is
|
|
176
176
|
// equidistant from y and z. This will be our next x.
|
|
177
|
-
|
|
177
|
+
const nextX = findEquidistantPointOnLine(x, y.p, z.pos.p);
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
const squaredError = squaredDistanceBetween(x, nextX);
|
|
180
180
|
|
|
181
181
|
x = nextX;
|
|
182
182
|
|
|
@@ -235,28 +235,28 @@ function reduceRadius(
|
|
|
235
235
|
let prevP = undefined;
|
|
236
236
|
let minRadius = Number.POSITIVE_INFINITY;
|
|
237
237
|
for (let i=0; i<bezierPieces.length; i++) {
|
|
238
|
-
|
|
238
|
+
const bezierPiece = bezierPieces[i];
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
const ps = bezierPiece.curve.ps;
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
const p1 = evalDeCasteljau(ps, bezierPiece.ts[0]);
|
|
243
243
|
let r1 = Number.POSITIVE_INFINITY;
|
|
244
244
|
|
|
245
245
|
// Prevent evaluating the same points twice
|
|
246
246
|
if (!prevP || prevP[0] !== p1[0] || prevP[1] !== p1[1]) {
|
|
247
|
-
|
|
247
|
+
const cc1 = getCircleCenterFrom2PointsAndNormal(extreme, p, x, p1);
|
|
248
248
|
if (cc1) { r1 = squaredDistanceBetween(p, cc1); }
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
let r2 = Number.POSITIVE_INFINITY;
|
|
252
|
-
|
|
252
|
+
const p2 = evalDeCasteljau(ps, bezierPiece.ts[1]);
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
const cc2 = getCircleCenterFrom2PointsAndNormal(extreme, p, x, p2);
|
|
255
255
|
if (cc2) { r2 = squaredDistanceBetween(p, cc2); }
|
|
256
256
|
|
|
257
257
|
prevP = p2;
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
const d = Math.min(r1, r2);
|
|
260
260
|
|
|
261
261
|
if (d < minRadius) {
|
|
262
262
|
minRadius = d;
|
|
@@ -283,7 +283,7 @@ function getCircleCenterFrom2PointsAndNormal(
|
|
|
283
283
|
p1: number[]) {
|
|
284
284
|
|
|
285
285
|
// TODO - remove delta
|
|
286
|
-
|
|
286
|
+
const TOLERANCE = (1e-4 * extreme)**2;
|
|
287
287
|
|
|
288
288
|
// Ignore if p and p1 are too close together
|
|
289
289
|
if (squaredDistanceBetween(p,p1) < TOLERANCE) {
|
|
@@ -291,20 +291,20 @@ function getCircleCenterFrom2PointsAndNormal(
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/** The perpindicular bisector between the two given points on the circle */
|
|
294
|
-
|
|
294
|
+
const pb = [
|
|
295
295
|
(p[0] + p1[0]) / 2,
|
|
296
296
|
(p[1] + p1[1]) / 2,
|
|
297
297
|
];
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
const tan = [p1[0] - p[0], p1[1] - p[1]];
|
|
299
|
+
const norm = [-tan[1], tan[0]]; // Rotate by 90 degrees
|
|
300
|
+
const pb2 = [pb[0] + norm[0], pb[1] + norm[1]];
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
const res = lineLineIntersection([p,x], [pb, pb2]);
|
|
303
303
|
|
|
304
304
|
if (!res) { return undefined; }
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
const resO = [res[0] - p[0], res[1] - p[1]];
|
|
307
|
+
const xO = [x[0] - p[0], x[1] - p[1]];
|
|
308
308
|
if (dot(resO, xO) < 0) {
|
|
309
309
|
return undefined;
|
|
310
310
|
}
|
|
@@ -10,7 +10,7 @@ function findEquidistantPointOnLine(x: number[], y: number[], z: number[]) {
|
|
|
10
10
|
// Some basic algebra (not shown) finds the required point.
|
|
11
11
|
|
|
12
12
|
// Swap axes if x and y are more aligned to y-axis than to x-axis.
|
|
13
|
-
|
|
13
|
+
const swapAxes = Math.abs((x[1] - y[1]) / (x[0] - y[0])) > 1;
|
|
14
14
|
|
|
15
15
|
// Cache
|
|
16
16
|
let x1, x2, y1, y2, z1, z2;
|
|
@@ -26,12 +26,12 @@ function findEquidistantPointOnLine(x: number[], y: number[], z: number[]) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// a <= 1 (due to swapped axes)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const a = (x2 - y2) / (x1 - y1);
|
|
30
|
+
const b = y2 - a*y1;
|
|
31
|
+
const c = (y1*y1 + y2*y2 - z1*z1 - z2*z2) + 2*b*(z2 - y2);
|
|
32
|
+
const d = y1 - z1 + a*(y2 - z2);
|
|
33
|
+
const t1 = c/(2*d);
|
|
34
|
+
const t2 = a*t1 + b;
|
|
35
35
|
|
|
36
36
|
return swapAxes ? [t2,t1] : [t1,t2];
|
|
37
37
|
}
|
|
@@ -21,17 +21,17 @@ function getInitialBezierPieces(
|
|
|
21
21
|
if (isHoleClosing) {
|
|
22
22
|
bezierPieces = [];
|
|
23
23
|
for (let k2=0; k2<k; k2++) {
|
|
24
|
-
|
|
24
|
+
const pieces: BezierPiece[] = loops[k2].curves
|
|
25
25
|
.map(curve => ({ curve, ts: [0,1] }))
|
|
26
26
|
bezierPieces.push(...pieces);
|
|
27
27
|
}
|
|
28
28
|
} else {
|
|
29
29
|
//let order = PointOnShape.isDullCorner(y)
|
|
30
|
-
|
|
30
|
+
const order = isPosDullCorner(y)
|
|
31
31
|
? y.t === 1 ? -1 : +1
|
|
32
32
|
: 0;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const loop = loops[k];
|
|
34
|
+
const cpNode = getNeighbouringPoints(cpTrees.get(loop), y, order, 0)[0];
|
|
35
35
|
δ = [cpNode, cpNode];
|
|
36
36
|
if (!cpNode ||
|
|
37
37
|
// The special case if there is only a single sharp corner or
|
|
@@ -20,7 +20,7 @@ function calcBetterX(
|
|
|
20
20
|
x: number[],
|
|
21
21
|
vectorToZeroV: number[]) {
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const V = len(vectorToZeroV);
|
|
24
24
|
|
|
25
25
|
let nu = 1;
|
|
26
26
|
let better;
|
|
@@ -29,15 +29,15 @@ function calcBetterX(
|
|
|
29
29
|
let newV;
|
|
30
30
|
let i = 0; // Safeguard
|
|
31
31
|
do {
|
|
32
|
-
|
|
32
|
+
const shift = scale(vectorToZeroV, nu);
|
|
33
33
|
newX = translate(shift, x);
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
newPs = getClosestPoints(newX, bezierPiece3s);
|
|
37
37
|
|
|
38
38
|
// Point of zero V
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const newCircleCenter = circumCenter(newPs.map(pos => pos.p));
|
|
40
|
+
const newVectorToZeroV = fromTo(newX, newCircleCenter);
|
|
41
41
|
newV = len(newVectorToZeroV);
|
|
42
42
|
|
|
43
43
|
better = newV < V;
|
|
@@ -18,16 +18,16 @@ function calcInitial3ProngCenter(
|
|
|
18
18
|
δ3s: CpNode[][],
|
|
19
19
|
bezierPiece3s: BezierPiece[][]) {
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const twoProngCircleCenter = δ3s[0][0].cp.circle.center;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const posInfo = getClosestBoundaryPoint(
|
|
24
24
|
bezierPiece3s[1],
|
|
25
25
|
twoProngCircleCenter,
|
|
26
26
|
undefined, // curve
|
|
27
27
|
undefined // t
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const meanPoints = [
|
|
31
31
|
δ3s[0][0].cp.pointOnShape.p,
|
|
32
32
|
posInfo.pos.p,
|
|
33
33
|
δ3s[2][1].cp.pointOnShape.p,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
declare
|
|
1
|
+
/** @internal */
|
|
2
|
+
declare const _debug_: Debug;
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
fromTo, circumCenter, len, distanceBetween, toUnitVector, rotate90Degrees,
|
|
@@ -40,33 +40,33 @@ function find3ProngForDelta3s(
|
|
|
40
40
|
const TOLERANCE = extreme * 1e-10;
|
|
41
41
|
const MAX_ITERATIONS = 10;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const δs_ = [
|
|
44
44
|
δs[0],
|
|
45
45
|
δs[idx],
|
|
46
46
|
δs[δs.length-1]
|
|
47
47
|
];
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
const bezierPieces_ = [
|
|
50
50
|
bezierPiecess[0],
|
|
51
51
|
bezierPiecess[idx],
|
|
52
52
|
bezierPiecess[δs.length-1]
|
|
53
53
|
];
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const δ3ss = [
|
|
56
56
|
[δs_[0], δs_[1], δs_[2]],
|
|
57
57
|
[δs_[1], δs_[2], δs_[0]],
|
|
58
58
|
[δs_[2], δs_[0], δs_[1]],
|
|
59
59
|
];
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const bezierPiecess_ = [
|
|
62
62
|
[bezierPieces_[0], bezierPieces_[1], bezierPieces_[2]],
|
|
63
63
|
[bezierPieces_[1], bezierPieces_[2], bezierPieces_[0]],
|
|
64
64
|
[bezierPieces_[2], bezierPieces_[0], bezierPieces_[1]],
|
|
65
65
|
]
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const δ3s = δ3ss[k];
|
|
69
|
+
const bezierPiece3s = bezierPiecess_[k];
|
|
70
70
|
|
|
71
71
|
if (δ3s[0][0].isSharp()) { return undefined; }
|
|
72
72
|
|
|
@@ -77,9 +77,9 @@ function find3ProngForDelta3s(
|
|
|
77
77
|
let x = calcInitial3ProngCenter(δ3s, bezierPiece3s);
|
|
78
78
|
|
|
79
79
|
if (typeof _debug_ !== 'undefined') {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const threeProngs = _debug_.generated.elems.threeProng;
|
|
81
|
+
const d = threeProngs[threeProngs.length-1];
|
|
82
|
+
const trace = d.traces[d.traces.length-1];
|
|
83
83
|
trace.push(x);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -99,7 +99,7 @@ function find3ProngForDelta3s(
|
|
|
99
99
|
|
|
100
100
|
circumCenter_ = circumCenter(ps.map(x => x.p));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
const vectorToZeroV = calcVectorToZeroV_StraightToIt(x, circumCenter_);
|
|
103
103
|
|
|
104
104
|
if (!Number.isFinite(vectorToZeroV[0]) || !Number.isFinite(vectorToZeroV[1])) {
|
|
105
105
|
|
|
@@ -109,27 +109,27 @@ function find3ProngForDelta3s(
|
|
|
109
109
|
// loop. This check, for instance, would be eliminated completely.
|
|
110
110
|
return undefined;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
const upds = calcBetterX(bezierPiece3s, x, vectorToZeroV);
|
|
113
113
|
x = upds.newX;
|
|
114
114
|
ps = upds.newPs;
|
|
115
115
|
|
|
116
116
|
if (typeof _debug_ !== 'undefined') {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const threeProngs = _debug_.generated.elems.threeProng;
|
|
118
|
+
const d = threeProngs[threeProngs.length-1];
|
|
119
|
+
const trace = d.traces[d.traces.length-1];
|
|
120
120
|
trace.push(x);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
const V = len(vectorToZeroV); // The 'potential'
|
|
124
124
|
|
|
125
125
|
tolerance = Math.abs(V - upds.newV);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
const radius = (distanceBetween(x, ps[0].p) +
|
|
129
129
|
distanceBetween(x, ps[1].p) +
|
|
130
130
|
distanceBetween(x, ps[2].p)) / 3;
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
const circle = { center: x, radius };
|
|
133
133
|
|
|
134
134
|
//-------------------------------------------------------------------------
|
|
135
135
|
// Calculate the unit tangent vector at 3-prong circle points - they should
|
|
@@ -138,12 +138,12 @@ function find3ProngForDelta3s(
|
|
|
138
138
|
//-------------------------------------------------------------------------
|
|
139
139
|
let totalAngleError = 0;
|
|
140
140
|
for (let i=0; i<3; i++) {
|
|
141
|
-
|
|
141
|
+
const p = ps[i];
|
|
142
142
|
//----------------------------
|
|
143
143
|
// Tangent of circle at point
|
|
144
144
|
//----------------------------
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
const v = toUnitVector(fromTo(p.p, x));
|
|
146
|
+
const v1 = rotate90Degrees(v);
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
//-----------------------------------
|
|
@@ -151,13 +151,13 @@ function find3ProngForDelta3s(
|
|
|
151
151
|
//-----------------------------------
|
|
152
152
|
//if (PointOnShape.isDullCorner(p)) {
|
|
153
153
|
if (isPosDullCorner(p)) {
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
//const corner = Curve.getCornerAtEnd(p.curve);
|
|
155
|
+
const corner = getCornerAtEnd(p.curve);
|
|
156
|
+
const tans = corner.tangents;
|
|
157
|
+
const perps = tans.map( rotate90Degrees );
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
const angleError1 = Math.asin( cross( perps[0], v ) );
|
|
160
|
+
const angleError2 = Math.asin( cross( v, perps[1] ) );
|
|
161
161
|
|
|
162
162
|
let angleError = 0;
|
|
163
163
|
if (angleError1 > 0) { angleError += angleError1; }
|
|
@@ -168,7 +168,7 @@ function find3ProngForDelta3s(
|
|
|
168
168
|
//---------------------------
|
|
169
169
|
// Tangent of curve at point
|
|
170
170
|
//---------------------------
|
|
171
|
-
|
|
171
|
+
const v2 = toUnitVector( tangent(p.curve.ps, p.t) );
|
|
172
172
|
|
|
173
173
|
// Cross is more numerically stable than Vector.dot at angles a
|
|
174
174
|
// multiple of Math.PI **and** is close to the actual angle value
|
|
@@ -176,7 +176,7 @@ function find3ProngForDelta3s(
|
|
|
176
176
|
// tolerance.
|
|
177
177
|
|
|
178
178
|
// Should be close to zero and is close to the actual angle.
|
|
179
|
-
|
|
179
|
+
const cross_ = Math.abs( Math.asin( cross(v1, v2) ) );
|
|
180
180
|
|
|
181
181
|
totalAngleError += cross_;
|
|
182
182
|
}
|
|
@@ -187,21 +187,21 @@ function find3ProngForDelta3s(
|
|
|
187
187
|
// point to the 3-prong. It should be around 0. If not, this is not a good
|
|
188
188
|
// candidate for the 3-prong.
|
|
189
189
|
//-------------------------------------------------------------------------
|
|
190
|
-
|
|
190
|
+
const closestDs = [];
|
|
191
191
|
for (let i=0; i<bezierPiecess.length; i++) {
|
|
192
|
-
|
|
192
|
+
const p = getClosestBoundaryPoint(
|
|
193
193
|
bezierPiecess[i], x, undefined, undefined
|
|
194
194
|
);
|
|
195
195
|
|
|
196
196
|
closestDs.push( distanceBetween(p.pos.p, x) );
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
const closestD = Math.min(...closestDs);
|
|
199
|
+
const radiusDelta = Math.abs(radius - closestD);
|
|
200
200
|
|
|
201
201
|
// Weights below still need to be optimized.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
const W1 = 1;
|
|
203
|
+
const W2 = 1;
|
|
204
|
+
const error = W1*radiusDelta + W2*totalAngleError;
|
|
205
205
|
|
|
206
206
|
return { ps, circle, error, δ3s };
|
|
207
207
|
}
|