flo-mat 2.0.0 → 2.0.2
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 +29720 -7345
- package/browser/index.min.js +1 -2
- package/node/circle.js +3 -3
- package/node/circle.js.map +1 -1
- package/node/compare-curvatures-at-interface.js +36 -36
- package/node/compare-curvatures-at-interface.js.map +1 -1
- package/node/cp-node/clone.js +6 -6
- package/node/cp-node/clone.js.map +1 -1
- package/node/cp-node/remove.js +4 -4
- package/node/cp-node/remove.js.map +1 -1
- package/node/cp-node.js +18 -18
- package/node/cp-node.js.map +1 -1
- package/node/curve.d.ts +1 -1
- package/node/curve.js +19 -19
- package/node/curve.js.map +1 -1
- package/node/debug/debug.d.ts +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/branch.js +4 -4
- package/node/debug/functions/draw-elem/branch.js.map +1 -1
- package/node/debug/functions/draw-elem/culls.js +4 -4
- package/node/debug/functions/draw-elem/culls.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.js +1 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +2 -2
- package/node/debug/functions/draw-elem/draw-elem.js +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/dull-corner.js +3 -3
- package/node/debug/functions/draw-elem/dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/leaves.js +4 -4
- package/node/debug/functions/draw-elem/leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/loose-bounding-box.js +2 -2
- package/node/debug/functions/draw-elem/loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/mat.js +4 -4
- package/node/debug/functions/draw-elem/mat.js.map +1 -1
- package/node/debug/functions/draw-elem/max-vertex.js +2 -2
- package/node/debug/functions/draw-elem/max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/min-y.js +3 -3
- package/node/debug/functions/draw-elem/min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/one-prong.js +4 -4
- package/node/debug/functions/draw-elem/one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/sharp-corner.js +2 -2
- package/node/debug/functions/draw-elem/sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/three-prong.js +7 -7
- package/node/debug/functions/draw-elem/three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.js +1 -1
- package/node/debug/functions/draw-elem/tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/two-prong.js +1 -1
- package/node/debug/functions/draw-elem/two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/vertex.js +13 -13
- package/node/debug/functions/draw-elem/vertex.js.map +1 -1
- package/node/debug/functions/general.d.ts +1 -1
- package/node/debug/functions/general.js +1 -1
- package/node/debug/functions/general.js.map +1 -1
- package/node/debug/functions/three-prong.d.ts +1 -1
- package/node/debug/functions/three-prong.js +37 -37
- package/node/debug/functions/three-prong.js.map +1 -1
- package/node/debug/functions/two-prong.d.ts +1 -1
- package/node/debug/functions/two-prong.js +15 -15
- package/node/debug/functions/two-prong.js.map +1 -1
- package/node/find-mats.js +16 -19
- package/node/find-mats.js.map +1 -1
- package/node/get-boundary-bezier-parts-to-next.js +8 -8
- package/node/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/get-boundary-beziers-to-next.js +8 -8
- package/node/get-boundary-beziers-to-next.js.map +1 -1
- package/node/get-branches.js +7 -7
- package/node/get-branches.js.map +1 -1
- package/node/get-curve/get-curve-between.js +21 -21
- package/node/get-curve/get-curve-between.js.map +1 -1
- package/node/get-curve/get-edge-direction.js +13 -13
- package/node/get-curve/get-edge-direction.js.map +1 -1
- package/node/get-interface-ccw.js +12 -12
- package/node/get-interface-ccw.js.map +1 -1
- package/node/loop/get-max-coordinate.js +9 -9
- package/node/loop/get-max-coordinate.js.map +1 -1
- package/node/loop.js +4 -4
- package/node/loop.js.map +1 -1
- package/node/mat/add-to-cp-graph.js +8 -8
- package/node/mat/add-to-cp-graph.js.map +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +5 -6
- package/node/mat/closest-boundary-point/closest-points-on-curve.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +1 -1
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +5 -5
- 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.js +5 -5
- 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.js +5 -5
- package/node/mat/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +15 -15
- package/node/mat/closest-boundary-point/get-close-boundary-points.js.map +1 -1
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +4 -4
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js.map +1 -1
- package/node/mat/create-new-cp-tree.js +3 -3
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/elem-type-two-prong.d.ts +1 -1
- package/node/mat/find-mat/add-1-prong.js +3 -3
- package/node/mat/find-mat/add-1-prong.js.map +1 -1
- package/node/mat/find-mat/add-2-prong.js +40 -40
- package/node/mat/find-mat/add-2-prong.js.map +1 -1
- package/node/mat/find-mat/add-3-prong.js +1 -1
- package/node/mat/find-mat/add-3-prong.js.map +1 -1
- package/node/mat/find-mat/add-debug-info.js +16 -18
- package/node/mat/find-mat/add-debug-info.js.map +1 -1
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +4 -4
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js.map +1 -1
- package/node/mat/find-mat/create-initial-cp-graph.js +11 -11
- package/node/mat/find-mat/create-initial-cp-graph.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +2 -2
- 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.js +5 -5
- 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.js +25 -25
- package/node/mat/find-mat/find-2-prong/find-2-prong.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +7 -7
- 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.js +4 -4
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +4 -4
- 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.js +3 -3
- 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.js +35 -35
- 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.js +14 -14
- 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.js +1 -1
- 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.js +2 -2
- 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.js +12 -13
- package/node/mat/find-mat/find-and-add-2-prongs.js.map +1 -1
- package/node/mat/find-mat/find-and-add-3-prongs.js +16 -17
- 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.js +6 -6
- 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.js +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js.map +1 -1
- package/node/mat/find-mat/get-sharp-corners.js +4 -4
- package/node/mat/find-mat/get-sharp-corners.js.map +1 -1
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +3 -3
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.js +5 -5
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-contact-circles-at-interface.js +1 -1
- package/node/mat/get-contact-circles-at-interface.js.map +1 -1
- package/node/mat/get-leaves.js +2 -2
- package/node/mat/get-leaves.js.map +1 -1
- package/node/mat/get-neighboring-cps.js +1 -1
- package/node/mat/get-neighboring-cps.js.map +1 -1
- package/node/mat/is-another-cp-closeby.js +9 -9
- package/node/mat/is-another-cp-closeby.js.map +1 -1
- package/node/mat/simplify-mat-map-only.js +15 -15
- package/node/mat/simplify-mat-map-only.js.map +1 -1
- package/node/mat/to-scale-axis/add-debug-info.js +1 -1
- package/node/mat/to-scale-axis/add-debug-info.js.map +1 -1
- package/node/mat/to-scale-axis/cull-non-cycles.js +5 -5
- package/node/mat/to-scale-axis/cull-non-cycles.js.map +1 -1
- package/node/mat/to-scale-axis/cull.js +5 -5
- package/node/mat/to-scale-axis/cull.js.map +1 -1
- package/node/mat/trim-mat.js +1 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/point-on-shape.d.ts +4 -4
- package/node/point-on-shape.js +16 -16
- package/node/point-on-shape.js.map +1 -1
- package/node/simplify-mat.js +10 -10
- package/node/simplify-mat.js.map +1 -1
- package/node/svg/get-loop-bounds.d.ts +1 -1
- package/node/svg/get-loop-bounds.js +13 -13
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +2 -2
- package/node/svg/get-shape-bounds.js +4 -4
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js +8 -8
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/to-scale-axis.js +16 -15
- package/node/to-scale-axis.js.map +1 -1
- package/node/traverse-edges.js +2 -2
- package/node/traverse-edges.js.map +1 -1
- package/node/traverse-vertices.js +2 -2
- package/node/traverse-vertices.js.map +1 -1
- package/package.json +30 -25
- 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/webpack.config.cjs +12 -63
- package/browser/index.min.js.LICENSE.txt +0 -2907
- package/browser/index.module.js +0 -7369
- package/browser/index.module.min.js +0 -2
- package/browser/index.module.min.js.LICENSE.txt +0 -2907
|
@@ -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 { exponent } from 'big-float-ts';
|
|
@@ -34,8 +34,8 @@ function add2Prong(
|
|
|
34
34
|
extreme : number): CpNode {
|
|
35
35
|
|
|
36
36
|
//let orderSource = PointOnShape.calcOrder(circle, posSource);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const orderSource = calcPosOrder(circle, posSource);
|
|
38
|
+
const orderAntipodes = posAntipodes.map(
|
|
39
39
|
posAntipode => {
|
|
40
40
|
//console.log(circle.center)
|
|
41
41
|
//return PointOnShape.calcOrder(circle, posAntipode.pos);
|
|
@@ -58,8 +58,8 @@ function add2Prong(
|
|
|
58
58
|
|
|
59
59
|
let isCloseByAntipodes = false;
|
|
60
60
|
for (let i=0; i<posAntipodes.length; i++) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const posAntipode = posAntipodes[i];
|
|
62
|
+
const orderAntipode = orderAntipodes[i];
|
|
63
63
|
|
|
64
64
|
if (isAnotherCpCloseby(cpGraphs, posAntipode.pos, circle, orderAntipode, 0, extreme, 'red')) {
|
|
65
65
|
isCloseByAntipodes = true;
|
|
@@ -80,22 +80,22 @@ function add2Prong(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Antipode
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
const newCpAntipodes: CpNode[] = [];
|
|
84
|
+
const cpAntipodes: ContactPoint[] = [];
|
|
85
|
+
const cpTreeAntipodes: LlRbTree<CpNode>[] = [];
|
|
86
|
+
const deltaAntipodes: CpNode[][] = [];
|
|
87
|
+
const loopAntipodes: Loop[] = [];
|
|
88
88
|
for (let i=0; i<posAntipodes.length; i++) {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const posAntipode = posAntipodes[i];
|
|
90
|
+
const orderAntipode = orderAntipodes[i];
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
const cpAntipode: ContactPoint = { pointOnShape: posAntipode.pos, circle, order: orderAntipode, order2: 0 };
|
|
93
93
|
cpAntipodes.push(cpAntipode);
|
|
94
|
-
|
|
94
|
+
const loopAntipode = posAntipode.pos.curve.loop;
|
|
95
95
|
loopAntipodes.push(loopAntipode);
|
|
96
|
-
|
|
96
|
+
const cpTreeAntipode = cpGraphs.get(loopAntipode);
|
|
97
97
|
cpTreeAntipodes.push(cpTreeAntipode);
|
|
98
|
-
|
|
98
|
+
const deltaAntipode = getNeighbouringPoints(
|
|
99
99
|
cpTreeAntipode, posAntipode.pos, orderAntipode, 0
|
|
100
100
|
);
|
|
101
101
|
deltaAntipodes.push(deltaAntipode);
|
|
@@ -111,13 +111,13 @@ function add2Prong(
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
// Source
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const cpSource: ContactPoint = { pointOnShape: posSource, circle, order: orderSource, order2: 0 };
|
|
115
|
+
const loopSource = posSource.curve.loop;
|
|
116
|
+
const cpTreeSource = cpGraphs.get(loopSource);
|
|
117
|
+
const deltaSource = getNeighbouringPoints(
|
|
118
118
|
cpTreeSource, posSource, orderSource, 0
|
|
119
119
|
);
|
|
120
|
-
|
|
120
|
+
const newCpSource = CpNode.insert(
|
|
121
121
|
holeClosing,
|
|
122
122
|
false,
|
|
123
123
|
cpTreeSource,
|
|
@@ -134,19 +134,19 @@ function add2Prong(
|
|
|
134
134
|
newCpAntipodes[0].prevOnCircle = newCpSource;
|
|
135
135
|
newCpAntipodes[0].nextOnCircle = newCpSource;
|
|
136
136
|
} else {
|
|
137
|
-
|
|
137
|
+
const cpNodes = newCpAntipodes.slice();
|
|
138
138
|
cpNodes.push(newCpSource);
|
|
139
139
|
|
|
140
140
|
// Order points according to their angle with the x-axis
|
|
141
141
|
cpNodes.sort(byAngle(circle));
|
|
142
142
|
|
|
143
143
|
for (let i=0; i<cpNodes.length; i++) {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const iNext = (i+1 === cpNodes.length) ? 0 : i+1;
|
|
145
|
+
const iPrev = (i === 0) ? cpNodes.length-1 : i-1;
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
const cpNodeCurr = cpNodes[i];
|
|
148
|
+
const cpNodeNext = cpNodes[iNext];
|
|
149
|
+
const cpNodePrev = cpNodes[iPrev];
|
|
150
150
|
|
|
151
151
|
cpNodeCurr.nextOnCircle = cpNodeNext;
|
|
152
152
|
cpNodeCurr.prevOnCircle = cpNodePrev;
|
|
@@ -157,11 +157,11 @@ function add2Prong(
|
|
|
157
157
|
if (holeClosing) {
|
|
158
158
|
// TODO - important - take care of case where there are more than 1 antipode
|
|
159
159
|
// Duplicate ContactPoints
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
const cpB2: ContactPoint = { pointOnShape: posAntipodes[0].pos, circle, order: cpAntipodes[0].order, order2: +1 };
|
|
161
|
+
const newCpB2Node = CpNode.insert(true, false, cpTreeAntipodes[0], cpB2, newCpAntipodes[0]);
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
const cpB1: ContactPoint = { pointOnShape: posSource, circle, order: cpSource.order, order2: -1 };
|
|
164
|
+
const newCpB1Node = CpNode.insert(true, false, cpTreeSource, cpB1, newCpSource.prev);
|
|
165
165
|
|
|
166
166
|
// Connect graph
|
|
167
167
|
newCpB1Node.prevOnCircle = newCpB2Node;
|
|
@@ -185,7 +185,7 @@ function add2Prong(
|
|
|
185
185
|
elems = _debug_.generated.elems['twoProng_regular'];
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
const elem = elems[elems.length-1];
|
|
189
189
|
|
|
190
190
|
if (!newCpSource) { console.log('asas')}
|
|
191
191
|
elem.cpNode = newCpSource;
|
|
@@ -230,10 +230,10 @@ function getSize(x: number, y: number) {
|
|
|
230
230
|
|
|
231
231
|
/** @hidden */
|
|
232
232
|
function byAngle(circle: Circle) {
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
const c = circle.center;
|
|
234
|
+
const r = circle.radius;
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
const exp = exponent(r);
|
|
237
237
|
|
|
238
238
|
return function(_a: CpNode, _b: CpNode) {
|
|
239
239
|
let a = _a.cp.pointOnShape.p;
|
|
@@ -244,14 +244,14 @@ function byAngle(circle: Circle) {
|
|
|
244
244
|
b = [b[0]-c[0], b[1]-c[1]];
|
|
245
245
|
|
|
246
246
|
// Scale
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
const ax = scale(a[0], exp);
|
|
248
|
+
const ay = scale(a[1], exp);
|
|
249
|
+
const bx = scale(b[0], exp);
|
|
250
|
+
const by = scale(b[1], exp);
|
|
251
251
|
|
|
252
252
|
// Get 'size'
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
const sa = getSize(ax, ay);
|
|
254
|
+
const sb = getSize(bx, by);
|
|
255
255
|
|
|
256
256
|
return sb - sa;
|
|
257
257
|
}
|
|
@@ -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,
|