flo-mat 4.0.1 → 4.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/README.md +1 -1
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +49 -0
- package/__tests__/specific-cases/specific-cases.spec.ts +6 -0
- package/browser/index.js +9994 -12650
- package/browser/index.min.js +1 -1
- package/node/closest-boundary-point/foot-and-endpoint-info.d.ts +0 -3
- package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +2 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.d.ts +1 -2
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +34 -24
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +1 -1
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +6 -9
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
- package/node/cp-node/fs/insert-cp-node.d.ts +2 -2
- package/node/cp-node/fs/insert-cp-node.js.map +1 -1
- package/node/cp-node/fs/is-on-same-loop.d.ts +3 -0
- package/node/cp-node/fs/is-on-same-loop.js +6 -0
- package/node/cp-node/fs/is-on-same-loop.js.map +1 -0
- package/node/cp-node/fs/is-order-correct.d.ts +2 -2
- package/node/cp-node/fs/is-order-correct.js.map +1 -1
- package/node/cp-node/fs/traverse-cp.js.map +1 -1
- package/node/cp-node/fs/traverse-vertices.d.ts +1 -1
- package/node/cp-node/fs/traverse-vertices.js.map +1 -1
- package/node/debug/debug.d.ts +10 -15
- package/node/debug/debug.js +35 -46
- package/node/debug/debug.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-branch.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-branch.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js +2 -2
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-leaves.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-leaves.js +2 -2
- package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-mat.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-mat.js +1 -2
- package/node/debug/functions/draw-elem/draw-mat.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-min-y.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-three-prong.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-three-prong.js +2 -2
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-vertex.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-vertex.js +0 -2
- package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
- package/node/error-analysis/gamma.d.ts +32 -0
- package/node/error-analysis/gamma.js +39 -0
- package/node/error-analysis/gamma.js.map +1 -0
- package/node/find-2-prong/add-1-prong.js +1 -4
- package/node/find-2-prong/add-1-prong.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +5 -5
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/get-medial/get-closest-points.js +27 -23
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-3-prong/calc-better-x.d.ts +1 -1
- package/node/find-3-prong/calc-better-x.js +6 -4
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/calc-initial-3-prong-center.d.ts +1 -1
- package/node/find-3-prong/calc-initial-3-prong-center.js +4 -3
- 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 +22 -5
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prong.d.ts +2 -2
- package/node/find-3-prong/find-and-add-3-prong.js +15 -0
- package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs-on-loop.js +8 -21
- package/node/find-3-prong/find-and-add-3-prongs-on-loop.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs.d.ts +1 -4
- package/node/find-3-prong/find-and-add-3-prongs.js +1 -2
- package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
- package/node/find-3-prong/get-closest-points.d.ts +1 -1
- package/node/find-3-prong/get-closest-points.js +2 -2
- package/node/find-3-prong/get-closest-points.js.map +1 -1
- package/node/find-3-prong/timed-cc.d.ts +3 -0
- package/node/find-3-prong/timed-cc.js +5 -0
- package/node/find-3-prong/timed-cc.js.map +1 -0
- package/node/find-mat/create-initial-cp-tree.d.ts +2 -2
- package/node/find-mat/create-initial-cp-tree.js +2 -2
- package/node/find-mat/create-initial-cp-tree.js.map +1 -1
- package/node/find-mat/find-mat.d.ts +4 -4
- package/node/find-mat/find-mat.js +1 -2
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.js +2 -2
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +1 -6
- package/node/find-mat/get-meta.js +4 -25
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/index.d.ts +5 -2
- package/node/index.js +4 -1
- package/node/index.js.map +1 -1
- package/node/mat/create-new-cp-trees.d.ts +2 -2
- package/node/mat/create-new-cp-trees.js +2 -2
- package/node/mat/create-new-cp-trees.js.map +1 -1
- package/node/mat/get-cp-node-to-left-or-same.d.ts +2 -2
- package/node/mat/get-cp-node-to-left-or-same.js +2 -1
- package/node/mat/get-cp-node-to-left-or-same.js.map +1 -1
- package/node/mat/mat-meta.d.ts +2 -2
- package/node/point-on-shape/get-osculating-circle.js +2 -1
- package/node/point-on-shape/get-osculating-circle.js.map +1 -1
- package/node/reconstruct-from-mat/filter-zero-length.d.ts +10 -0
- package/node/reconstruct-from-mat/filter-zero-length.js +14 -0
- package/node/reconstruct-from-mat/filter-zero-length.js.map +1 -0
- package/node/reconstruct-from-mat/get-all-on-loop-by-loop.d.ts +7 -0
- package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js +38 -0
- package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js.map +1 -0
- package/node/reconstruct-from-mat/get-bezier-piece-length.d.ts +3 -0
- package/node/reconstruct-from-mat/get-bezier-piece-length.js +6 -0
- package/node/reconstruct-from-mat/get-bezier-piece-length.js.map +1 -0
- package/node/reconstruct-from-mat/get-boundary.d.ts +7 -0
- package/node/reconstruct-from-mat/get-boundary.js +18 -0
- package/node/reconstruct-from-mat/get-boundary.js.map +1 -0
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.d.ts +4 -0
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +15 -0
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -0
- package/node/reconstruct-from-mat/get-matching-beziers.d.ts +10 -0
- package/node/reconstruct-from-mat/get-matching-beziers.js +29 -0
- package/node/reconstruct-from-mat/get-matching-beziers.js.map +1 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.d.ts +6 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js +10 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js.map +1 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.d.ts +7 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js +47 -0
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js.map +1 -0
- package/node/reconstruct-from-mat/get-sats2.d.ts +10 -0
- package/node/reconstruct-from-mat/get-sats2.js +16 -0
- package/node/reconstruct-from-mat/get-sats2.js.map +1 -0
- package/node/reconstruct-from-mat/is-fully-terminating.d.ts +3 -0
- package/node/reconstruct-from-mat/is-fully-terminating.js +19 -0
- package/node/reconstruct-from-mat/is-fully-terminating.js.map +1 -0
- package/node/reconstruct-from-mat/matched-beziers.d.ts +10 -0
- package/node/reconstruct-from-mat/matched-beziers.js +2 -0
- package/node/reconstruct-from-mat/matched-beziers.js.map +1 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +4 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +28 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +12 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +46 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -0
- package/node/reconstruct-from-mat/split-tri-path.d.ts +5 -0
- package/node/reconstruct-from-mat/split-tri-path.js +209 -0
- package/node/reconstruct-from-mat/split-tri-path.js.map +1 -0
- package/node/sat/add-debug-info.js +1 -2
- package/node/sat/add-debug-info.js.map +1 -1
- package/node/utils/clip.d.ts +2 -0
- package/node/utils/clip.js +6 -0
- package/node/utils/clip.js.map +1 -0
- package/package.json +6 -7
- package/src/closest-boundary-point/foot-and-endpoint-info.ts +0 -3
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +0 -2
- package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +41 -27
- package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +5 -10
- package/src/cp-node/fs/insert-cp-node.ts +2 -2
- package/src/cp-node/fs/is-on-same-loop.ts +15 -0
- package/src/cp-node/fs/is-order-correct.ts +2 -2
- package/src/cp-node/fs/traverse-cp.ts +1 -1
- package/src/cp-node/fs/traverse-vertices.ts +1 -2
- package/src/debug/debug.ts +54 -72
- package/src/debug/functions/check-ordering.ts +0 -1
- package/src/debug/functions/draw-elem/draw-branch.ts +1 -3
- package/src/debug/functions/draw-elem/draw-cp-node.ts +3 -4
- package/src/debug/functions/draw-elem/draw-leaves.ts +3 -3
- package/src/debug/functions/draw-elem/draw-mat.ts +2 -5
- package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
- package/src/debug/functions/draw-elem/draw-three-prong.ts +3 -3
- package/src/debug/functions/draw-elem/draw-vertex.ts +1 -4
- package/src/error-analysis/gamma.ts +9 -2
- package/src/find-2-prong/add-1-prong.ts +1 -5
- package/src/find-2-prong/find-2-prong.ts +7 -6
- package/src/find-2-prong/get-medial/get-closest-points.ts +24 -26
- package/src/find-3-prong/calc-better-x.ts +7 -4
- package/src/find-3-prong/calc-initial-3-prong-center.ts +2 -3
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +23 -5
- package/src/find-3-prong/find-and-add-3-prong.ts +18 -4
- package/src/find-3-prong/find-and-add-3-prongs-on-loop.ts +7 -23
- package/src/find-3-prong/find-and-add-3-prongs.ts +5 -3
- package/src/find-3-prong/get-closest-points.ts +0 -2
- package/src/find-3-prong/timed-cc.ts +9 -0
- package/src/find-mat/create-initial-cp-tree.ts +3 -3
- package/src/find-mat/find-mat.ts +6 -8
- package/src/find-mat/find-mats.ts +4 -2
- package/src/find-mat/get-meta.ts +3 -38
- package/src/index.ts +6 -3
- package/src/mat/create-new-cp-trees.ts +3 -3
- package/src/mat/get-cp-node-to-left-or-same.ts +4 -3
- package/src/mat/mat-meta.ts +2 -2
- package/src/point-on-shape/get-osculating-circle.ts +2 -1
- package/src/reconstruct-from-mat/filter-zero-length.ts +23 -0
- package/src/reconstruct-from-mat/get-all-on-loop-by-loop.ts +52 -0
- package/src/reconstruct-from-mat/get-bezier-piece-length.ts +12 -0
- package/src/reconstruct-from-mat/get-boundary.ts +32 -0
- package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +24 -0
- package/src/reconstruct-from-mat/get-matching-beziers.ts +46 -0
- package/src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts +19 -0
- package/src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts +69 -0
- package/src/reconstruct-from-mat/get-sats2.ts +25 -0
- package/src/reconstruct-from-mat/is-fully-terminating.ts +27 -0
- package/src/reconstruct-from-mat/matched-beziers.ts +14 -0
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +45 -0
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +62 -0
- package/src/reconstruct-from-mat/split-tri-path.ts +280 -0
- package/src/sat/add-debug-info.ts +1 -2
- package/src/utils/clip.ts +13 -0
- package/wallaby.mjs +1 -0
- package/node/closest-boundary-point/get-p-from-box.d.ts +0 -3
- package/node/closest-boundary-point/get-p-from-box.js +0 -11
- package/node/closest-boundary-point/get-p-from-box.js.map +0 -1
- package/node/debug/functions/general.d.ts +0 -48
- package/node/debug/functions/general.js +0 -53
- package/node/debug/functions/general.js.map +0 -1
- package/node/point-on-shape/pos-to-human-string.d.ts +0 -8
- package/node/point-on-shape/pos-to-human-string.js +0 -12
- package/node/point-on-shape/pos-to-human-string.js.map +0 -1
- package/src/debug/elem-type-two-prong.ts +0 -8
- package/src/debug/functions/cmp-cp-on-delta.ts +0 -54
- package/src/debug/functions/general.ts +0 -79
- package/src/debug/functions/three-prong.ts +0 -249
- package/src/debug/functions/two-prong.ts +0 -203
- package/src/find-2-prong/add-debug-info.ts +0 -45
|
@@ -17,7 +17,6 @@ import { toP } from '../point-on-shape/to-p.js';
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
function getCloseBoundaryPointsCertified(
|
|
20
|
-
maxCoordPowerOf2: number,
|
|
21
20
|
curvePieces: CurvePiece[],
|
|
22
21
|
x: number[]): PrePointOnShape[] {
|
|
23
22
|
|
|
@@ -28,7 +27,6 @@ function getCloseBoundaryPointsCertified(
|
|
|
28
27
|
const curvePiece = curvePieces[i];
|
|
29
28
|
|
|
30
29
|
const _pInfos = getPotentialClosestPointsOnCurveCertified(
|
|
31
|
-
maxCoordPowerOf2,
|
|
32
30
|
curvePiece.curve,
|
|
33
31
|
x,
|
|
34
32
|
curvePiece.ts as [number,number]
|
|
@@ -1,62 +1,76 @@
|
|
|
1
1
|
import type { Curve } from "flo-boolean";
|
|
2
2
|
import type { FootAndEndpointInfo } from './foot-and-endpoint-info.js';
|
|
3
|
-
import {
|
|
4
|
-
import { getFootPointsOnBezierPolysCertified, getIntervalBox } from 'flo-bezier3';
|
|
3
|
+
import { roots } from 'flo-poly';
|
|
4
|
+
import { evalDeCasteljauDd, getFootPointsOnBezierPolysCertified, getIntervalBox } from 'flo-bezier3';
|
|
5
5
|
import { rootIntervalToDistanceSquaredInterval } from './root-interval-to-distance-squared-interval.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const { sqrt } = Math;
|
|
6
|
+
import { squaredDistanceBetweenDd } from "../find-2-prong/squared-distance-between-dd.js";
|
|
7
|
+
import { eps } from '../error-analysis/gamma.js';
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* @internal
|
|
13
12
|
*
|
|
14
|
-
* @param maxCoordPowerOf2
|
|
15
13
|
* @param curve the curve
|
|
16
14
|
* @param x the point from which to check
|
|
17
15
|
* @param tRange The allowed t range
|
|
18
16
|
*/
|
|
19
17
|
function getPotentialClosestPointsOnCurveCertified(
|
|
20
|
-
maxCoordPowerOf2: number,
|
|
21
18
|
curve: Curve,
|
|
22
19
|
x: number[],
|
|
23
20
|
tRange: [number, number]): FootAndEndpointInfo[] {
|
|
24
21
|
|
|
25
22
|
const [tS,tE] = tRange;
|
|
26
|
-
const ps = curve
|
|
23
|
+
const { ps } = curve;
|
|
24
|
+
|
|
25
|
+
const infos: FootAndEndpointInfo[] = [];
|
|
26
|
+
|
|
27
|
+
if (tS !== tE) {
|
|
28
|
+
const { polyDd: pDd, polyE: pDd_, getPolyExact } =
|
|
29
|
+
getFootPointsOnBezierPolysCertified(ps, x);
|
|
30
|
+
|
|
31
|
+
const ris = roots(pDd, tS, tE, pDd_, getPolyExact) || [];
|
|
32
|
+
|
|
33
|
+
infos.push(...ris.map(ri => {
|
|
34
|
+
const { tS: ts, tE: te, t: _t } = ri;
|
|
35
|
+
|
|
36
|
+
const t = _t < 0 ? 0 : _t > 1 ? 1 : _t;
|
|
37
|
+
|
|
38
|
+
const box = getIntervalBox(ps, [ts, te]);
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
getFootPointsOnBezierPolysCertified(ps, x);
|
|
40
|
+
const dSquaredI = rootIntervalToDistanceSquaredInterval(box, x);
|
|
30
41
|
|
|
31
|
-
|
|
42
|
+
const t_ = t === 0 ? 1 : t;
|
|
43
|
+
const curve_ = t === 0 ? curve.prev : curve;
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
return {
|
|
46
|
+
curve: curve_,
|
|
47
|
+
t: t_,
|
|
48
|
+
dSquaredI
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
35
52
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
const ts = tRange.slice();
|
|
54
|
+
if (tS === tE) {
|
|
55
|
+
ts.push(tS);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
infos.push(...ts.map(t => {
|
|
59
|
+
const p = evalDeCasteljauDd(ps, [0,t]).map(v => v[0] + v[1]);
|
|
39
60
|
|
|
40
|
-
const
|
|
41
|
-
const t = _t < 0 ? 0 : _t > 1 ? 1 : _t;
|
|
61
|
+
const d = squaredDistanceBetweenDd(p, x);
|
|
42
62
|
|
|
43
|
-
const
|
|
44
|
-
const p_ = getPFromBox(box);
|
|
45
|
-
|
|
46
|
-
const dSquaredI = rootIntervalToDistanceSquaredInterval(maxCoordPowerOf2, box, x);
|
|
63
|
+
const dSquaredI = [d*(1 - eps), d*(1 + eps)];
|
|
47
64
|
|
|
48
65
|
const t_ = t === 0 ? 1 : t;
|
|
49
66
|
const curve_ = t === 0 ? curve.prev : curve;
|
|
50
67
|
|
|
51
68
|
return {
|
|
52
69
|
curve: curve_,
|
|
53
|
-
p: p_,
|
|
54
70
|
t: t_,
|
|
55
|
-
|
|
56
|
-
dSquaredI,
|
|
57
|
-
box
|
|
71
|
+
dSquaredI
|
|
58
72
|
}
|
|
59
|
-
});
|
|
73
|
+
}));
|
|
60
74
|
|
|
61
75
|
return infos;
|
|
62
76
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { twoDiff,
|
|
2
|
-
import { ddMultDd, ddAddDd } from 'double-double';
|
|
1
|
+
import { twoDiff, ddMultDd, ddAddDd } from 'double-double';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
// We *have* to do the below to improve performance with bundlers❗ The assignee is a getter❗ The assigned is a pure function❗
|
|
6
|
-
const estimate = eEstimate;
|
|
7
3
|
const td = twoDiff;
|
|
8
|
-
// const emult = eMult;
|
|
9
|
-
// const eadd = eAdd;
|
|
10
4
|
const qmq = ddMultDd;
|
|
11
5
|
const qaq = ddAddDd;
|
|
12
6
|
|
|
@@ -25,7 +19,6 @@ const eps = Number.EPSILON;
|
|
|
25
19
|
* @internal
|
|
26
20
|
*/
|
|
27
21
|
function rootIntervalToDistanceSquaredInterval(
|
|
28
|
-
maxCoordPowerOf2: number,
|
|
29
22
|
box: number[][],
|
|
30
23
|
p: number[]) {
|
|
31
24
|
|
|
@@ -62,8 +55,10 @@ function rootIntervalToDistanceSquaredInterval(
|
|
|
62
55
|
const dc1Dd = qaq(qmq(ax,ax),qmq(by,by)); // ax**2 + bx**2
|
|
63
56
|
const dc1 = dc1Dd[1];
|
|
64
57
|
|
|
65
|
-
const dc1Min = dc1*(1 - 2**maxCoordPowerOf2*eps); // distance minus max error
|
|
66
|
-
const dc1Max = dc1*(1 + 2**maxCoordPowerOf2*eps); // distance plus max error
|
|
58
|
+
// const dc1Min = dc1*(1 - 2**maxCoordPowerOf2*eps); // distance minus max error
|
|
59
|
+
// const dc1Max = dc1*(1 + 2**maxCoordPowerOf2*eps); // distance plus max error
|
|
60
|
+
const dc1Min = dc1*(1 - eps); // distance minus max error
|
|
61
|
+
const dc1Max = dc1*(1 + eps); // distance plus max error
|
|
67
62
|
|
|
68
63
|
if (dc1Min <= minDSquared) {
|
|
69
64
|
minDSquared = dc1Min;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CpNode } from "../cp-node.js";
|
|
2
2
|
import type { PointOnShape } from "../../point-on-shape/point-on-shape.js";
|
|
3
3
|
import type { Mutable } from "../../utils/mutable.js";
|
|
4
|
-
import {
|
|
4
|
+
import { RbTree } from "flo-ll-rb-tree";
|
|
5
5
|
import { isOrderCorrect } from "./is-order-correct.js";
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ function insertCpNode(
|
|
|
9
9
|
insertIfOrderWrong: boolean,
|
|
10
10
|
isHoleClosing: boolean,
|
|
11
11
|
isIntersection: boolean,
|
|
12
|
-
cpTree:
|
|
12
|
+
cpTree: RbTree<CpNode>,
|
|
13
13
|
pos: PointOnShape,
|
|
14
14
|
_prev: CpNode | undefined,
|
|
15
15
|
lastInsertId: { id: number }): CpNode | undefined {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CpNode } from "../cp-node.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RbTree } from "flo-ll-rb-tree";
|
|
3
3
|
import { PointOnShape } from "../../point-on-shape/point-on-shape.js";
|
|
4
4
|
import { comparePoss } from "../../point-on-shape/compare-poss.js";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
function isOrderCorrect(
|
|
8
|
-
cpTree:
|
|
8
|
+
cpTree: RbTree<CpNode>,
|
|
9
9
|
pos: PointOnShape,
|
|
10
10
|
next: CpNode): boolean {
|
|
11
11
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CpNode } from '../cp-node.js';
|
|
2
|
-
import { CpNodeFs } from '../cp-node-fs.js';
|
|
1
|
+
import type { CpNode } from '../cp-node.js';
|
|
3
2
|
import { getAllOnCircle } from './get-all-on-circle.js';
|
|
4
3
|
import { isTerminating } from './is-terminating.js';
|
|
5
4
|
import { getVertexForwardChildren } from './get-vertex-forward-children.js';
|
package/src/debug/debug.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DrawElemFunctions } from './functions/draw-elem/draw-elem.js';
|
|
4
|
-
import { DebugElems } from './debug-elem-types.js';
|
|
1
|
+
import type { DrawElemFunctions } from './functions/draw-elem/draw-elem.js';
|
|
2
|
+
import type { DebugElems } from './debug-elem-types.js';
|
|
5
3
|
import { drawElemFs } from './functions/draw-elem/draw-elem.js';
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
/** @internal */
|
|
9
7
|
interface Debug {
|
|
10
8
|
/** Generated by debug object for later inspection */
|
|
11
|
-
|
|
9
|
+
elems: GeneratedElems;
|
|
10
|
+
timing: Timing;
|
|
11
|
+
|
|
12
12
|
/**
|
|
13
13
|
* These functions are meant to be used in the console, e.g. in the
|
|
14
14
|
* console try typing d.fs.twoProng.traceConvergence(0);
|
|
15
15
|
*/
|
|
16
|
-
fs:
|
|
17
|
-
directives:
|
|
16
|
+
fs: DebugFunctions;
|
|
17
|
+
directives: Directives;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
|
@@ -23,32 +23,23 @@ type GeneratedElems = { [T in keyof DebugElems]: DebugElems[T][] };
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
/** @internal */
|
|
26
|
-
interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
sats : number;
|
|
33
|
-
simplifyMat : number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/** @internal */
|
|
38
|
-
interface Generated {
|
|
39
|
-
elems: GeneratedElems;
|
|
40
|
-
timing: ITiming;
|
|
26
|
+
interface Timing {
|
|
27
|
+
holeClosers: number;
|
|
28
|
+
oneAnd2Prongs: number;
|
|
29
|
+
threeProngs: number;
|
|
30
|
+
sats: number;
|
|
31
|
+
simplifyMat: number;
|
|
41
32
|
}
|
|
42
33
|
|
|
43
34
|
|
|
44
35
|
/** @internal */
|
|
45
|
-
interface
|
|
46
|
-
drawElem
|
|
36
|
+
interface DebugFunctions {
|
|
37
|
+
drawElem: DrawElemFunctions,
|
|
47
38
|
}
|
|
48
39
|
|
|
49
40
|
|
|
50
41
|
/** @internal */
|
|
51
|
-
interface
|
|
42
|
+
interface Directives {
|
|
52
43
|
stopAfterHoleClosers: boolean,
|
|
53
44
|
stopAfterHoleClosersNum: number,
|
|
54
45
|
stopAfterTwoProngs: boolean,
|
|
@@ -68,59 +59,50 @@ function enableDebugForMat(debugOn: boolean) {
|
|
|
68
59
|
|
|
69
60
|
debug = {
|
|
70
61
|
...debug,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
...(!debug ? {} : !debug.generated ? {} : debug.generated),
|
|
62
|
+
elems: {
|
|
63
|
+
...debug?.elems,
|
|
74
64
|
// @ts-ignore
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
threeProngs : 0,
|
|
106
|
-
sats : 0,
|
|
107
|
-
simplifyMat : 0,
|
|
108
|
-
}
|
|
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 : [],
|
|
87
|
+
},
|
|
88
|
+
timing: {
|
|
89
|
+
...debug?.timing,
|
|
90
|
+
holeClosers: 0,
|
|
91
|
+
oneAnd2Prongs: 0,
|
|
92
|
+
threeProngs: 0,
|
|
93
|
+
sats: 0,
|
|
94
|
+
simplifyMat: 0,
|
|
109
95
|
},
|
|
110
96
|
fs: {
|
|
111
|
-
|
|
112
|
-
...(!debug ? {} : !debug.fs ? {} : debug.fs),
|
|
113
|
-
// @ts-ignore
|
|
97
|
+
...debug?.fs,
|
|
114
98
|
drawElem: {
|
|
115
|
-
|
|
116
|
-
...(!debug ? {} : !debug.fs ? {} : !debug.fs.drawElem ? {} : debug.fs.drawElem),
|
|
99
|
+
...debug?.fs?.drawElem,
|
|
117
100
|
...drawElemFs
|
|
118
|
-
}
|
|
119
|
-
...generalDebugFunctions
|
|
101
|
+
}
|
|
120
102
|
},
|
|
121
103
|
directives: {
|
|
122
104
|
//...debug?.directives,
|
|
123
|
-
...
|
|
105
|
+
...debug?.directives,
|
|
124
106
|
stopAfterHoleClosers: false,
|
|
125
107
|
stopAfterHoleClosersNum: undefined!,
|
|
126
108
|
stopAfterTwoProngs: false,
|
|
@@ -135,6 +117,6 @@ function enableDebugForMat(debugOn: boolean) {
|
|
|
135
117
|
|
|
136
118
|
|
|
137
119
|
export {
|
|
138
|
-
Debug, GeneratedElems,
|
|
139
|
-
|
|
120
|
+
Debug, GeneratedElems, Timing,
|
|
121
|
+
DebugFunctions, Directives, enableDebugForMat
|
|
140
122
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CpNode } from '../../../cp-node/cp-node.js';
|
|
3
|
-
import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
1
|
+
import type { CpNode } from '../../../cp-node/cp-node.js';
|
|
4
2
|
import { getMatCurveToNext } from '../../../cp-node/fs/get-mat-curve-to-next.js';
|
|
5
3
|
import { isTerminating } from '../../../cp-node/fs/is-terminating.js';
|
|
6
4
|
import { drawBeziersAsSinglePath } from '../draw/draw-beziers-as-single-path.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CpNode } from '../../../cp-node/cp-node.js';
|
|
2
2
|
import { drawFs } from 'flo-draw';
|
|
3
3
|
import { scaleCircle } from '../../../geometry/circle.js';
|
|
4
|
-
import {
|
|
5
|
-
import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
4
|
+
import { getAllOnCircle } from '../../../cp-node/fs/get-all-on-circle.js';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
/** @internal */
|
|
@@ -19,7 +18,7 @@ function drawCpNode(
|
|
|
19
18
|
);
|
|
20
19
|
const { center: c, radius: r } = circle;
|
|
21
20
|
|
|
22
|
-
const poss =
|
|
21
|
+
const poss = getAllOnCircle(cpNode)
|
|
23
22
|
.map(cpNode => cpNode.pointOnShape)
|
|
24
23
|
|
|
25
24
|
const { dot, circle: drawCircle, crossHair } = drawFs;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { CpNode } from '../../../cp-node/cp-node.js';
|
|
1
2
|
import { drawFs } from 'flo-draw';
|
|
2
|
-
import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
3
|
-
import { CpNode } from '../../../cp-node/cp-node.js';
|
|
4
3
|
import { drawCirclePercent } from './draw-circle-percent.js';
|
|
4
|
+
import { getAllOnCircle } from '../../../cp-node/fs/get-all-on-circle.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
@@ -22,7 +22,7 @@ function drawLeaves(
|
|
|
22
22
|
|
|
23
23
|
const $center = [drawCirclePercent(g, c, 0.5, 'pinker thin5 nofill')];
|
|
24
24
|
|
|
25
|
-
const poss =
|
|
25
|
+
const poss = getAllOnCircle(cpNode)
|
|
26
26
|
.map(cpNode => cpNode.pointOnShape);
|
|
27
27
|
|
|
28
28
|
const $ls: SVGElement[] = [];
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
import type { Mat } from '../../../mat/mat.js';
|
|
1
2
|
import { drawFs } from 'flo-draw';
|
|
2
|
-
import { Mat } from '../../../mat/mat.js';
|
|
3
3
|
import { traverseEdges } from '../../../cp-node/fs/traverse-edges.js';
|
|
4
4
|
import { getMatCurveToNext } from '../../../cp-node/fs/get-mat-curve-to-next.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { isTerminating } = CpNodeFs;
|
|
5
|
+
import { isTerminating } from '../../../cp-node/fs/is-terminating.js';
|
|
9
6
|
|
|
10
7
|
|
|
11
8
|
const altClasses = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PointOnShape } from '../../../point-on-shape/point-on-shape.js';
|
|
2
|
+
import { evalDeCasteljau } from 'flo-bezier3';
|
|
2
3
|
import { drawFs } from 'flo-draw';
|
|
3
|
-
import { PointOnShape } from '../../../point-on-shape/point-on-shape.js';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/** @internal */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { CpNode } from '../../../cp-node/cp-node.js';
|
|
1
2
|
import { drawFs } from 'flo-draw';
|
|
2
3
|
import { scaleCircle } from '../../../geometry/circle.js';
|
|
3
|
-
import {
|
|
4
|
-
import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
4
|
+
import { getAllOnCircle } from '../../../cp-node/fs/get-all-on-circle.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
@@ -20,7 +20,7 @@ function drawThreeProng(
|
|
|
20
20
|
const { center: c, radius: r } = circle;
|
|
21
21
|
|
|
22
22
|
// const poss = threeProng.poss;
|
|
23
|
-
const poss =
|
|
23
|
+
const poss = getAllOnCircle(threeProng)
|
|
24
24
|
.map(cpNode => cpNode.pointOnShape)
|
|
25
25
|
|
|
26
26
|
const { dot, circle: drawCircle, crossHair } = drawFs;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import type { CpNode } from '../../../cp-node/cp-node.js';
|
|
1
2
|
import { drawFs } from 'flo-draw';
|
|
2
|
-
import { CpNode } from '../../../cp-node/cp-node.js';
|
|
3
|
-
import { CpNodeFs } from '../../../cp-node/cp-node-fs.js';
|
|
4
|
-
|
|
5
|
-
const { getAllOnCircle } = CpNodeFs;
|
|
6
3
|
|
|
7
4
|
|
|
8
5
|
/** @internal */
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
/** `2 * 2^-53` -> 2x the standard round-of unit `=== Number.EPSILON` */
|
|
3
|
+
const eps = Number.EPSILON;
|
|
4
|
+
|
|
5
|
+
/** `2^-53` -> the standard round-of unit `=== eps/2` */
|
|
6
|
+
const u = eps / 2;
|
|
7
|
+
|
|
8
|
+
/** `2^-106` -> the standard round-of unit for double-double precision `=== (eps/2)**2` */
|
|
2
9
|
const uu = u*u;
|
|
3
10
|
|
|
4
11
|
|
|
@@ -38,4 +45,4 @@ function γγ(n: number): number {
|
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
|
|
41
|
-
export { γ,
|
|
48
|
+
export { γ, γγ, u, uu, eps }
|
|
@@ -50,11 +50,7 @@ function add1Prong(
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// if (typeof _debug_ !== 'undefined') {
|
|
56
|
-
// _debug_.generated.elems.oneProng.push(cpNodes);
|
|
57
|
-
// }
|
|
53
|
+
addToCpTree(false, false, circle, [-0.5, +0.5], meta, [pos, pos]);
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
|
|
@@ -83,11 +83,6 @@ function find2Prong(
|
|
|
83
83
|
const xy2 = reduceRadius(maxCoordPowerOf2, curvePieces, y, nnorm);
|
|
84
84
|
const xy = sqrt(xy2);
|
|
85
85
|
|
|
86
|
-
if (for1Prong && rO < (1 - oneProngTolerance)*xy) {
|
|
87
|
-
add1Prong(meta, rO, xO, yPos);
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
86
|
const l = sqrt(nnorm[0]**2 + nnorm[1]**2);
|
|
92
87
|
xO = [y[0] + nnorm[0]/l*xy, y[1] + nnorm[1]/l*xy];
|
|
93
88
|
|
|
@@ -110,6 +105,12 @@ function find2Prong(
|
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
const { x, d, curve, s } = antipodalPoints[0];
|
|
108
|
+
|
|
109
|
+
if (for1Prong && rO < (1 - oneProngTolerance)*d) {
|
|
110
|
+
add1Prong(meta, rO, xO, yPos);
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
|
|
113
114
|
const z: PrePointOnShape = {
|
|
114
115
|
curve, t: s, isSource: false,
|
|
115
116
|
p: toP(curve.ps, s)
|
|
@@ -126,7 +127,7 @@ function find2Prong(
|
|
|
126
127
|
// The lines below eliminate cases where the found 2-prong is too
|
|
127
128
|
// close to a one-prong
|
|
128
129
|
const squaredSeperationTolerance = max(
|
|
129
|
-
calcSeperationTolerance(rO, sqrt(xz), 2**2*errorTolerance),
|
|
130
|
+
calcSeperationTolerance(rO, sqrt(xz), (2**2)*errorTolerance),
|
|
130
131
|
minSquaredSeperationTolerance
|
|
131
132
|
);
|
|
132
133
|
if (yz <= squaredSeperationTolerance) {
|