flo-mat 3.0.9 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/jsog/check-jsog-eql-calc.spec.ts +81 -0
- package/__tests__/jsog/decode-jsog.ts +85 -0
- package/__tests__/jsog/get-mats1.ts +41 -0
- package/__tests__/{cp-node/fs → jsog}/mat-dummys.ts +51 -564
- package/__tests__/jsog/to-jsog-breath-first.ts +107 -0
- package/__tests__/jsog/to-jsog-depth-first.ts +55 -0
- package/browser/index.js +280 -236
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/cull-bezier-pieces.d.ts +5 -4
- package/node/closest-boundary-point/cull-bezier-pieces.js +9 -8
- package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +2 -2
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js +8 -8
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
- package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +2 -2
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js +8 -8
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
- package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
- package/node/closest-boundary-point/get-best-distance-squared.d.ts +1 -1
- package/node/closest-boundary-point/get-best-distance-squared.js +6 -6
- package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +2 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +7 -7
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/contact-point/contact-point.js.map +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node-fs.d.ts +2 -1
- package/node/cp-node/cp-node-fs.js +1 -2
- package/node/cp-node/cp-node-fs.js.map +1 -1
- package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
- package/node/cp-node/fs/cp-node-comparator.js +6 -0
- package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
- package/node/cp-node/fs/find-first.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +1 -1
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +11 -16
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-between.js +4 -6
- package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +10 -1
- package/node/cp-node/fs/get-boundary-beziers-to-next.js +70 -35
- package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-children.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-salience.js +2 -2
- package/node/cp-node/fs/get-salience.js.map +1 -1
- package/node/cp-node/fs/get-speed.js +0 -1
- package/node/cp-node/fs/get-speed.js.map +1 -1
- package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-one-prong.js.map +1 -1
- package/node/cp-node/fs/is-sharp.js.map +1 -1
- package/node/cp-node/fs/is-terminating.js.map +1 -1
- package/node/cp-node/fs/traverse-cp.js.map +1 -1
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/fs/traverse-vertices.js.map +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
- package/node/debug/functions/general.js.map +1 -1
- package/node/find-2-prong/add-1-prong.js.map +1 -1
- package/node/find-2-prong/cull-bezier-pieces.d.ts +4 -4
- package/node/find-2-prong/cull-bezier-pieces.js +9 -9
- package/node/find-2-prong/cull-bezier-pieces.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +8 -8
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
- package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -2
- package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
- package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +1 -1
- package/node/find-2-prong/reduce-radius.js +5 -5
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong.ts/calc-better-x.d.ts +2 -2
- package/node/find-3-prong.ts/calc-better-x.js +3 -3
- package/node/find-3-prong.ts/calc-better-x.js.map +1 -1
- package/node/find-3-prong.ts/calc-initial-3-prong-center.d.ts +2 -2
- package/node/find-3-prong.ts/calc-initial-3-prong-center.js +3 -3
- package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -1
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.d.ts +2 -2
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.js +16 -16
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong.ts/find-3-prong.js +2 -2
- package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
- package/node/find-3-prong.ts/get-closest-points.d.ts +2 -2
- package/node/find-3-prong.ts/get-closest-points.js +4 -4
- package/node/find-3-prong.ts/get-closest-points.js.map +1 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/index.d.ts +35 -1
- package/node/index.js +36 -1
- package/node/index.js.map +1 -1
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.js +7 -7
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/memoize-primitive.js.map +1 -1
- package/node/sat/add-debug-info.js.map +1 -1
- package/node/sat/cull.d.ts +7 -5
- package/node/sat/cull.js +7 -4
- package/node/sat/cull.js.map +1 -1
- package/node/sat/get-leaves.js.map +1 -1
- package/node/sat/to-scale-axis.d.ts +3 -2
- package/node/sat/to-scale-axis.js +3 -2
- package/node/sat/to-scale-axis.js.map +1 -1
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/package.json +6 -6
- package/src/add-n-prong.ts/join-spokes.ts +11 -11
- package/src/closest-boundary-point/cull-bezier-pieces.ts +12 -11
- package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +8 -8
- package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +8 -8
- package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
- package/src/closest-boundary-point/get-best-distance-squared.ts +6 -6
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +41 -41
- package/src/contact-point/contact-point.ts +13 -13
- package/src/corner/get-corner.ts +39 -39
- package/src/corner/get-interface-ccw.ts +3 -3
- package/src/cp-node/cp-node-fs.ts +132 -135
- package/src/cp-node/cp-node.ts +30 -30
- package/src/cp-node/fs/clone.ts +4 -4
- package/src/cp-node/fs/cp-node-comparator.ts +13 -0
- package/src/cp-node/fs/find-first.ts +6 -6
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +12 -18
- package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -7
- package/src/cp-node/fs/get-boundary-beziers-to-next.ts +79 -53
- package/src/cp-node/fs/get-branch-beziers.ts +1 -1
- package/src/cp-node/fs/get-branch.ts +1 -1
- package/src/cp-node/fs/get-children.ts +8 -8
- package/src/cp-node/fs/get-first-exit.ts +11 -11
- package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
- package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
- package/src/cp-node/fs/get-prong-count.ts +8 -8
- package/src/cp-node/fs/get-real-prong-count.ts +3 -3
- package/src/cp-node/fs/get-salience.ts +2 -2
- package/src/cp-node/fs/get-speed.ts +1 -6
- package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
- package/src/cp-node/fs/is-fully-terminating.ts +3 -3
- package/src/cp-node/fs/is-one-prong.ts +8 -8
- package/src/cp-node/fs/is-sharp.ts +1 -1
- package/src/cp-node/fs/is-terminating.ts +1 -1
- package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
- package/src/cp-node/fs/traverse-all-forward.ts +11 -11
- package/src/cp-node/fs/traverse-cp.ts +19 -17
- package/src/cp-node/fs/traverse-edges.ts +10 -10
- package/src/cp-node/fs/traverse-vertices.ts +17 -17
- package/src/curve/curve.ts +26 -26
- package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/culls.ts +2 -2
- package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
- package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
- package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
- package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
- package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
- package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/leaves.ts +2 -2
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +2 -2
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/three-prong.ts +19 -19
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/two-prong.ts +44 -44
- package/src/debug/functions/draw-elem/vertex.ts +28 -28
- package/src/debug/functions/general.ts +18 -18
- package/src/debug/functions/three-prong.ts +184 -184
- package/src/debug/functions/two-prong.ts +201 -201
- package/src/debug/two-prong-for-debugging.ts +26 -26
- package/src/find-2-prong/add-1-prong.ts +25 -25
- package/src/find-2-prong/add-debug-info.ts +38 -38
- package/src/find-2-prong/cull-bezier-pieces.ts +10 -10
- package/src/find-2-prong/find-2-prong.ts +158 -158
- package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
- package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
- package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
- package/src/find-2-prong/reduce-radius.ts +5 -5
- package/src/find-3-prong.ts/calc-better-x.ts +3 -3
- package/src/find-3-prong.ts/calc-initial-3-prong-center.ts +3 -3
- package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +17 -17
- package/src/find-3-prong.ts/find-3-prong.ts +23 -23
- package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
- package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
- package/src/find-3-prong.ts/get-closest-points.ts +4 -4
- package/src/find-mat/add-2-prongs-by-error.ts +8 -8
- package/src/find-mat/find-mats.ts +49 -49
- package/src/find-mat/fix-ordering.ts +2 -2
- package/src/find-mat/get-total-by.ts +12 -12
- package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
- package/src/get-curve/get-curve-between.ts +1 -1
- package/src/index.ts +41 -4
- package/src/mat/cmp-cp-on-delta.ts +1 -1
- package/src/mat/create-new-cp-tree.ts +12 -12
- package/src/mat/get-boundary-piece-beziers.ts +7 -7
- package/src/mat/get-edges-as-array.ts +9 -9
- package/src/mat/get-largest-3-prong.ts +8 -8
- package/src/mat/get-largest-three-prong.ts +5 -5
- package/src/mat/get-largest-vertex.ts +6 -6
- package/src/mat/get-two-prong-type.ts +9 -9
- package/src/mat/trim-mat.ts +1 -1
- package/src/memoize-primitive.ts +14 -14
- package/src/sat/add-debug-info.ts +4 -4
- package/src/sat/cull-by-salience.ts +1 -1
- package/src/sat/cull.ts +10 -7
- package/src/sat/get-leaves.ts +0 -1
- package/src/sat/to-scale-axis.ts +18 -17
- package/src/svg/get-extreme.ts +8 -8
- package/src/svg/get-loop-bounds.ts +84 -84
- package/src/svg/get-min-y-pos.ts +1 -1
- package/src/sweep-line/sweep-line.ts +23 -23
- package/src/utils/bezier-piece-to-bezier.ts +7 -7
- package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.d.ts +0 -3
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js +0 -6
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js.map +0 -1
- package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +0 -70
- package/src/cp-node/fs/cp-nodes-to-boundary-beziers.ts +0 -10
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
declare let _debug_: Debug;
|
|
2
|
-
|
|
3
|
-
import { drawFs } from 'flo-draw';
|
|
4
|
-
import { getObjClosestTo, distanceBetween, squaredDistanceBetween } from 'flo-vector2d';
|
|
5
|
-
import { Debug, Generated } from '../debug.js';
|
|
6
|
-
import { CpNode } from '../../cp-node/cp-node.js';
|
|
7
|
-
import { Circle } from '../../geometry/circle.js';
|
|
8
|
-
import { TwoProngForDebugging } from '../two-prong-for-debugging.js';
|
|
9
|
-
import { ElemType_TwoProng } from '../../mat/elem-type-two-prong.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** @internal */
|
|
13
|
-
interface ITwoProngDebugFunctions {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function logδ(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log(δ);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
function log(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
41
|
-
const twoProng = _debug_.generated.elems[type][n];
|
|
42
|
-
console.log(twoProng);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
function drawNormal(
|
|
50
|
-
g: SVGGElement,
|
|
51
|
-
twoProng: TwoProngForDebugging,
|
|
52
|
-
showDelay = 1000) {
|
|
53
|
-
|
|
54
|
-
drawFs.line(
|
|
55
|
-
g, [twoProng.pos.p, twoProng.circle.center], 'thin10 blue', showDelay
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
function logδBasic(
|
|
64
|
-
n: number,
|
|
65
|
-
type: ElemType_TwoProng = 'twoProng_regular') {
|
|
66
|
-
|
|
67
|
-
const delta = _debug_.generated.elems[type][n].δ;
|
|
68
|
-
|
|
69
|
-
function logδBasic_(x: CpNode) {
|
|
70
|
-
const pos = x.cp.pointOnShape;
|
|
71
|
-
return {
|
|
72
|
-
bez: pos.curve.ps,
|
|
73
|
-
t: pos.t
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.log(logδBasic_(delta[0]));
|
|
78
|
-
console.log(logδBasic_(delta[1]));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @internal
|
|
84
|
-
* Draws 3 lines from the given 3-prong center to its 3 contact points.
|
|
85
|
-
* @param n - The 3-prong's zero-based index.
|
|
86
|
-
*/
|
|
87
|
-
function drawSpokes(
|
|
88
|
-
g: SVGGElement,
|
|
89
|
-
twoProng: TwoProngForDebugging,
|
|
90
|
-
showDelay = 1000): void {
|
|
91
|
-
|
|
92
|
-
const cc = twoProng.circle.center;
|
|
93
|
-
const { pos, circle, cpNode, xs, z, δ } = twoProng;
|
|
1
|
+
// declare let _debug_: Debug;
|
|
2
|
+
|
|
3
|
+
// import { drawFs } from 'flo-draw';
|
|
4
|
+
// import { getObjClosestTo, distanceBetween, squaredDistanceBetween } from 'flo-vector2d';
|
|
5
|
+
// import { Debug, Generated } from '../debug.js';
|
|
6
|
+
// import { CpNode } from '../../cp-node/cp-node.js';
|
|
7
|
+
// import { Circle } from '../../geometry/circle.js';
|
|
8
|
+
// import { TwoProngForDebugging } from '../two-prong-for-debugging.js';
|
|
9
|
+
// import { ElemType_TwoProng } from '../../mat/elem-type-two-prong.js';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// /** @internal */
|
|
13
|
+
// interface ITwoProngDebugFunctions {
|
|
14
|
+
// logδ : (n: number, type?: ElemType_TwoProng) => void,
|
|
15
|
+
// log : (n: number, type?: ElemType_TwoProng) => void,
|
|
16
|
+
// drawNormal : typeof drawNormal,
|
|
17
|
+
// logδBasic : (n: number) => void,
|
|
18
|
+
// logNearest : (
|
|
19
|
+
// showSpokes? : boolean,
|
|
20
|
+
// showTrace? : boolean,
|
|
21
|
+
// showBoundaries? : boolean
|
|
22
|
+
// ) => (g: SVGGElement, p: number[], showDelay?: number, scale?: number) => void,
|
|
23
|
+
// traceConvergence: typeof traceConvergence,
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// /**
|
|
28
|
+
// * @internal
|
|
29
|
+
// */
|
|
30
|
+
// function logδ(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
31
|
+
// const δ =_debug_.generated.elems[type][n].δ;
|
|
94
32
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
33
|
+
// console.log(δ);
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// /**
|
|
38
|
+
// * @internal
|
|
39
|
+
// */
|
|
40
|
+
// function log(n: number, type: ElemType_TwoProng = 'twoProng_regular') {
|
|
41
|
+
// const twoProng = _debug_.generated.elems[type][n];
|
|
42
|
+
// console.log(twoProng);
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// /**
|
|
47
|
+
// * @internal
|
|
48
|
+
// */
|
|
49
|
+
// function drawNormal(
|
|
50
|
+
// g: SVGGElement,
|
|
51
|
+
// twoProng: TwoProngForDebugging,
|
|
52
|
+
// showDelay = 1000) {
|
|
53
|
+
|
|
54
|
+
// drawFs.line(
|
|
55
|
+
// g, [twoProng.pos.p, twoProng.circle.center], 'thin10 blue', showDelay
|
|
56
|
+
// );
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// /**
|
|
61
|
+
// * @internal
|
|
62
|
+
// */
|
|
63
|
+
// function logδBasic(
|
|
64
|
+
// n: number,
|
|
65
|
+
// type: ElemType_TwoProng = 'twoProng_regular') {
|
|
66
|
+
|
|
67
|
+
// const delta = _debug_.generated.elems[type][n].δ;
|
|
68
|
+
|
|
69
|
+
// function logδBasic_(x: CpNode) {
|
|
70
|
+
// const pos = x.cp.pointOnShape;
|
|
71
|
+
// return {
|
|
72
|
+
// bez: pos.curve.ps,
|
|
73
|
+
// t: pos.t
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
// console.log(logδBasic_(delta[0]));
|
|
78
|
+
// console.log(logδBasic_(delta[1]));
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
// /**
|
|
83
|
+
// * @internal
|
|
84
|
+
// * Draws 3 lines from the given 3-prong center to its 3 contact points.
|
|
85
|
+
// * @param n - The 3-prong's zero-based index.
|
|
86
|
+
// */
|
|
87
|
+
// function drawSpokes(
|
|
88
|
+
// g: SVGGElement,
|
|
89
|
+
// twoProng: TwoProngForDebugging,
|
|
90
|
+
// showDelay = 1000): void {
|
|
91
|
+
|
|
92
|
+
// const cc = twoProng.circle.center;
|
|
93
|
+
// const { pos, circle, cpNode, xs, z, δ } = twoProng;
|
|
94
|
+
|
|
95
|
+
// drawFs.line(g, [pos.p, cc], 'thin5 red', showDelay);
|
|
96
|
+
// drawFs.line(g, [z, cc], 'thin5 red', showDelay);
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// /**
|
|
101
|
+
// * @internal
|
|
102
|
+
// */
|
|
103
|
+
// function logNearest(
|
|
104
|
+
// showSpokes?: boolean,
|
|
105
|
+
// showTrace?: boolean,
|
|
106
|
+
// showBoundaries?: boolean) {
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
function traceConvergence(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/** @internal */
|
|
192
|
-
const twoProngDebugFunctions: ITwoProngDebugFunctions = {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
export { ITwoProngDebugFunctions, twoProngDebugFunctions };
|
|
203
|
-
|
|
108
|
+
// return (g: SVGGElement,
|
|
109
|
+
// p: number[],
|
|
110
|
+
// showDelay = 1000,
|
|
111
|
+
// scale = 1) => {
|
|
112
|
+
|
|
113
|
+
// const closestPerLoops: TwoProngForDebugging[] = [];
|
|
114
|
+
|
|
115
|
+
// const generated = _debug_.generated;
|
|
116
|
+
// const twoProng = getObjClosestTo<TwoProngForDebugging>(
|
|
117
|
+
// p,
|
|
118
|
+
// // generated.elems[type],
|
|
119
|
+
// generated.elems['twoProng_regular'],
|
|
120
|
+
// twoProng => twoProng.circle.center
|
|
121
|
+
// )!;
|
|
122
|
+
// closestPerLoops.push(twoProng!);
|
|
123
|
+
|
|
124
|
+
// console.log(twoProng);
|
|
125
|
+
|
|
126
|
+
// let n;
|
|
127
|
+
// //for (let i=0; i<_debug_.generated.elems[type].length; i++) {
|
|
128
|
+
// // const twoProng_ = _debug_.generated.elems[type][i];
|
|
129
|
+
// for (let i=0; i<_debug_.generated.elems['twoProng_regular'].length; i++) {
|
|
130
|
+
// const twoProng_ = _debug_.generated.elems['twoProng_regular'][i];
|
|
131
|
+
// if (twoProng_ === twoProng) {
|
|
132
|
+
// n = i;
|
|
133
|
+
// break;
|
|
134
|
+
// }
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
// if (showSpokes) {
|
|
138
|
+
// drawSpokes(g, twoProng, showDelay)
|
|
139
|
+
// }
|
|
140
|
+
|
|
141
|
+
// if (n !== undefined && showTrace) {
|
|
142
|
+
// traceConvergence(g, twoProng, showDelay, scale);
|
|
143
|
+
// }
|
|
144
|
+
// }
|
|
145
|
+
// }
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// /**
|
|
149
|
+
// * @internal
|
|
150
|
+
// * @param n - The 2-prong's zero-based index.
|
|
151
|
+
// * @param range
|
|
152
|
+
// */
|
|
153
|
+
// function traceConvergence(
|
|
154
|
+
// g: SVGGElement,
|
|
155
|
+
// twoProng: TwoProngForDebugging,
|
|
156
|
+
// showDelay = 1000,
|
|
157
|
+
// scale = 1) {
|
|
158
|
+
|
|
159
|
+
// const xs = twoProng.xs;
|
|
160
|
+
|
|
161
|
+
// console.log(twoProng);
|
|
162
|
+
// console.log(
|
|
163
|
+
// twoProng.xs.map(x => ({
|
|
164
|
+
// x: x.x,
|
|
165
|
+
// y: x.y,
|
|
166
|
+
// z: x.z,
|
|
167
|
+
// d: x.z ? squaredDistanceBetween(x.y.p, x.z.p) : 0,
|
|
168
|
+
// t: x.t,
|
|
169
|
+
// })
|
|
170
|
+
// )
|
|
171
|
+
// );
|
|
172
|
+
|
|
173
|
+
// console.log(xs.length)
|
|
174
|
+
// for (let i=0; i<xs.length; i++) {
|
|
175
|
+
// const x = twoProng.xs[i];
|
|
176
|
+
|
|
177
|
+
// const circle = { center: x.x, radius: distanceBetween(x.x, x.y.p) };
|
|
178
|
+
// drawFs.crossHair(g, x.x, 'red thin10 nofill', 0.002*scale, showDelay);
|
|
179
|
+
// drawFs.circle(g, circle, 'blue thin10 nofill', showDelay);
|
|
180
|
+
// if (x.z !== undefined) {
|
|
181
|
+
// drawFs.crossHair(
|
|
182
|
+
// g, x.z.p, 'yellow thin10 nofill', 0.001*scale, showDelay
|
|
183
|
+
// );
|
|
184
|
+
// }
|
|
185
|
+
// }
|
|
186
|
+
|
|
187
|
+
// // twoProngDebugFunctions.drawNormal(g, twoProng, showDelay);
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
// /** @internal */
|
|
192
|
+
// const twoProngDebugFunctions: ITwoProngDebugFunctions = {
|
|
193
|
+
// logδ,
|
|
194
|
+
// log,
|
|
195
|
+
// drawNormal,
|
|
196
|
+
// logδBasic,
|
|
197
|
+
// traceConvergence,
|
|
198
|
+
// logNearest,
|
|
199
|
+
// }
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
// export { ITwoProngDebugFunctions, twoProngDebugFunctions };
|
|
203
|
+
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { CpNode } from '../cp-node/cp-node.js';
|
|
2
|
-
import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
|
-
import { Circle } from '../geometry/circle.js';
|
|
4
|
-
import { CurvePiece } from '../mat/bezier-piece.js';
|
|
5
|
-
import { Generated } from './debug.js';
|
|
1
|
+
// import { CpNode } from '../cp-node/cp-node.js';
|
|
2
|
+
// import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
|
+
// import { Circle } from '../geometry/circle.js';
|
|
4
|
+
// import { CurvePiece } from '../mat/bezier-piece.js';
|
|
5
|
+
// import { Generated } from './debug.js';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
/** @internal */
|
|
9
|
-
interface TwoProngForDebugging {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
8
|
+
// /** @internal */
|
|
9
|
+
// interface TwoProngForDebugging {
|
|
10
|
+
// generated: Generated;
|
|
11
|
+
// bezierPieces: CurvePiece[];
|
|
12
|
+
// pos: PointOnShape;
|
|
13
|
+
// δ: CpNode[];
|
|
14
|
+
// z: number[];
|
|
15
|
+
// circle: Circle;
|
|
16
|
+
// xs: {
|
|
17
|
+
// x: number[];
|
|
18
|
+
// y: PointOnShape;
|
|
19
|
+
// z: PointOnShape;
|
|
20
|
+
// t: number;
|
|
21
|
+
// }[];
|
|
22
|
+
// failed: boolean;
|
|
23
|
+
// holeClosing: boolean;
|
|
24
|
+
// notAdded: boolean;
|
|
25
|
+
// deleted: boolean;
|
|
26
|
+
// cpNode: CpNode;
|
|
27
|
+
// }
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
export { TwoProngForDebugging }
|
|
30
|
+
// export { TwoProngForDebugging }
|
|
@@ -15,44 +15,44 @@ import { getPosCorner } from '../point-on-shape/get-pos-corner.js';
|
|
|
15
15
|
* @param pos
|
|
16
16
|
*/
|
|
17
17
|
function add1Prong(
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
meta: MatMeta,
|
|
19
|
+
radius: number,
|
|
20
20
|
center: number[],
|
|
21
21
|
pos: PointOnShape) {
|
|
22
22
|
|
|
23
23
|
if (isPosCorner(pos) && getPosCorner(pos).isDull) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
// This is a 1-prong at a dull corner.
|
|
25
|
+
|
|
26
|
+
// TODO IMPORTANT
|
|
27
|
+
// Remove this line, uncomment piece below it and implement the
|
|
28
|
+
// following strategy to find the 3-prongs: if deltas are conjoined due
|
|
29
|
+
// to dull corner, split the conjoinment by inserting successively
|
|
30
|
+
// closer (binary division) 2-prongs. If a 2-prong actually fails,
|
|
31
|
+
// simply remove the 1-prong at the dull corner. In this way **all**
|
|
32
32
|
// terminal points are found, e.g. zoom in on top left leg of ant.
|
|
33
33
|
// Afterthought: there is a better way - split points by two prongs.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
//toRemove.push(posNode); // this!
|
|
36
|
+
|
|
37
|
+
// if (typeof _debug_ !== 'undefined') {
|
|
38
38
|
// _debug_.generated.elems.oneProngAtDullCorner.push(pos);
|
|
39
39
|
// }
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
44
|
const circle: Circle = { radius, center };
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
|
|
46
|
+
const order = calcPosOrder(circle, pos);
|
|
47
|
+
// Make sure there isn't already a ContactPoint close by - it can cause
|
|
48
|
+
// floating point stability issues.
|
|
49
|
+
if (getCloseByCpIfExist(meta, pos, circle, order, 0, 1)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
const { anyFailed, cpNodes } = addToCpTree(false, false, circle, [-0.5, +0.5], meta, [pos, pos]);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
|
|
55
|
+
// if (typeof _debug_ !== 'undefined') {
|
|
56
56
|
// _debug_.generated.elems.oneProng.push(cpNodes);
|
|
57
57
|
// }
|
|
58
58
|
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
2
|
-
import { Circle } from '../geometry/circle.js';
|
|
3
|
-
import { CpNode } from '../cp-node/cp-node.js';
|
|
4
|
-
import { CurvePiece } from '../mat/bezier-piece.js';
|
|
5
|
-
import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
|
|
6
|
-
import { getTwoProngType } from '../mat/get-two-prong-type.js';
|
|
7
|
-
import { ElemType_TwoProng } from '../mat/elem-type-two-prong.js';
|
|
8
|
-
import { TXForDebugging } from './x-for-debugging.js';
|
|
1
|
+
// import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
2
|
+
// import { Circle } from '../geometry/circle.js';
|
|
3
|
+
// import { CpNode } from '../cp-node/cp-node.js';
|
|
4
|
+
// import { CurvePiece } from '../mat/bezier-piece.js';
|
|
5
|
+
// import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
|
|
6
|
+
// import { getTwoProngType } from '../mat/get-two-prong-type.js';
|
|
7
|
+
// import { ElemType_TwoProng } from '../mat/elem-type-two-prong.js';
|
|
8
|
+
// import { TXForDebugging } from './x-for-debugging.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
/** @internal */
|
|
12
|
-
function addDebugInfo(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
// /** @internal */
|
|
12
|
+
// function addDebugInfo(
|
|
13
|
+
// bezierPieces: CurvePiece[],
|
|
14
|
+
// failed: boolean,
|
|
15
|
+
// x: number[],
|
|
16
|
+
// y: PointOnShape,
|
|
17
|
+
// z: PointOnShape,
|
|
18
|
+
// circle: Circle,
|
|
19
|
+
// δ: CpNode[],
|
|
20
|
+
// xs: TXForDebugging[],
|
|
21
|
+
// holeClosing: boolean) {
|
|
22
22
|
|
|
23
|
-
// xs.push({ x, y, z, t: y.t });
|
|
23
|
+
// // xs.push({ x, y, z, t: y.t });
|
|
24
24
|
|
|
25
|
-
// const twoProng: TwoProngForDebugging = {
|
|
26
|
-
// generated: _debug_.generated,
|
|
27
|
-
// bezierPieces,
|
|
28
|
-
// pos: y,
|
|
29
|
-
// δ,
|
|
30
|
-
// z: z ? z.p : undefined!,
|
|
31
|
-
// circle,
|
|
32
|
-
// xs,
|
|
33
|
-
// failed,
|
|
34
|
-
// holeClosing,
|
|
35
|
-
// notAdded: false,
|
|
36
|
-
// deleted: false,
|
|
37
|
-
// cpNode: undefined!
|
|
38
|
-
// };
|
|
25
|
+
// // const twoProng: TwoProngForDebugging = {
|
|
26
|
+
// // generated: _debug_.generated,
|
|
27
|
+
// // bezierPieces,
|
|
28
|
+
// // pos: y,
|
|
29
|
+
// // δ,
|
|
30
|
+
// // z: z ? z.p : undefined!,
|
|
31
|
+
// // circle,
|
|
32
|
+
// // xs,
|
|
33
|
+
// // failed,
|
|
34
|
+
// // holeClosing,
|
|
35
|
+
// // notAdded: false,
|
|
36
|
+
// // deleted: false,
|
|
37
|
+
// // cpNode: undefined!
|
|
38
|
+
// // };
|
|
39
39
|
|
|
40
|
-
// const twoProngType = getTwoProngType(twoProng) as ElemType_TwoProng;
|
|
41
|
-
// _debug_.generated.elems[twoProngType].push(twoProng);
|
|
42
|
-
}
|
|
40
|
+
// // const twoProngType = getTwoProngType(twoProng) as ElemType_TwoProng;
|
|
41
|
+
// // _debug_.generated.elems[twoProngType].push(twoProng);
|
|
42
|
+
// }
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
export { addDebugInfo }
|
|
45
|
+
// export { addDebugInfo }
|
|
@@ -5,32 +5,32 @@ import { getBoundingBox$ } from '../geometry/get-bounding-box-.js';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
|
-
* Cull all
|
|
8
|
+
* Cull all curvePieces not within given radius of a given point.
|
|
9
9
|
* @param extreme
|
|
10
|
-
* @param
|
|
10
|
+
* @param curvePieces
|
|
11
11
|
* @param p
|
|
12
12
|
* @param rSquared
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
14
|
+
function cullCurvePieces2(
|
|
15
|
+
curvePieces: CurvePiece[],
|
|
16
16
|
p: number[],
|
|
17
17
|
rSquared: number) {
|
|
18
18
|
|
|
19
19
|
const TOLERANCE = 1 + 2**-10;
|
|
20
20
|
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
21
|
+
if (curvePieces.length <= 1) {
|
|
22
|
+
return curvePieces;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
const newPieces = [];
|
|
27
|
-
for (const
|
|
28
|
-
const ps =
|
|
27
|
+
for (const curvePiece of curvePieces) {
|
|
28
|
+
const ps = curvePiece.curve.ps;
|
|
29
29
|
|
|
30
30
|
const rect = getBoundingBox$(ps);
|
|
31
31
|
const bd = getClosestSquareDistanceToRect(rect, p);
|
|
32
32
|
if (bd <= TOLERANCE*rSquared) {
|
|
33
|
-
newPieces.push(
|
|
33
|
+
newPieces.push(curvePiece);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -38,4 +38,4 @@ function cullBezierPieces2(
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
export {
|
|
41
|
+
export { cullCurvePieces2 }
|