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
|
@@ -8,14 +8,14 @@ import { Circle } from '../geometry/circle.js';
|
|
|
8
8
|
* calculated.
|
|
9
9
|
*/
|
|
10
10
|
interface ContactPoint {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
/** Identifies the point on the shape boundary. */
|
|
12
|
+
pointOnShape: PointOnShape;
|
|
13
|
+
/** The maximal disk circle touching this point. */
|
|
14
|
+
circle: Circle;
|
|
15
|
+
/** Internally used to order two points lying at the same planar point. */
|
|
16
|
+
order: number;
|
|
17
|
+
/** Internally used to order two points lying at the same planar point. */
|
|
18
|
+
order2: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
@@ -28,14 +28,14 @@ interface ContactPoint {
|
|
|
28
28
|
* @param b The second contact point.
|
|
29
29
|
*/
|
|
30
30
|
function compareCps(a: ContactPoint, b: ContactPoint) {
|
|
31
|
-
|
|
31
|
+
let res = comparePoss(a.pointOnShape, b.pointOnShape);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
if (res !== 0) { return res; }
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
res = a.order - b.order;
|
|
36
|
+
if (res !== 0) { return res; }
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
return a.order2 - b.order2;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
package/src/corner/get-corner.ts
CHANGED
|
@@ -8,11 +8,11 @@ import { getInterfaceCcw } from './get-interface-ccw.js';
|
|
|
8
8
|
* Angle in degrees to radians.
|
|
9
9
|
*/
|
|
10
10
|
const DEGREES = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
//'0' : 0.0000,
|
|
12
|
+
0.25 : 0.0050,
|
|
13
|
+
1 : 0.0167,
|
|
14
|
+
4 : 0.0698,
|
|
15
|
+
16 : 0.2756,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
|
|
@@ -35,45 +35,45 @@ const DEGREE_LIMIT = DEGREES[4];
|
|
|
35
35
|
* @param psO The outgoing bezier that starts at the corner
|
|
36
36
|
*/
|
|
37
37
|
function getCorner(
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
psI: number[][],
|
|
39
|
+
psO: number[][]): Corner {
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
// getInterfaceCcw must return a number !== 0 if psI and psO are not the
|
|
42
|
+
// same as seen as a curve extension with t ∈ [-∞,+∞]
|
|
43
|
+
const { ccw, tangentI, tangentO, dotTangents } = getInterfaceCcw(psI, psO);
|
|
44
|
+
const isSharp = ccw < 0;
|
|
45
|
+
const isDull = ccw > 0;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
// These use square root and are thus not exact
|
|
48
|
+
const unitTangents = [
|
|
49
|
+
toUnitVector(tangentI.map(v => v[1])),
|
|
50
|
+
toUnitVector(tangentO.map(v => v[1])),
|
|
51
|
+
];
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// The cross calculated below should be exact due to beziers having been
|
|
54
|
+
// normalized!
|
|
55
|
+
const crossTangents = cross(unitTangents[0], unitTangents[1]);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
let isQuiteSharp: boolean;
|
|
58
|
+
let isQuiteDull: boolean;
|
|
59
|
+
// const dotTangents = dot(tangentAtIncoming, tangentAtOutgoing);
|
|
60
|
+
if (dotTangents > 0) {
|
|
61
|
+
// Curves go in same direction
|
|
62
|
+
isQuiteSharp = crossTangents < -DEGREE_LIMIT;
|
|
63
|
+
isQuiteDull = crossTangents > +DEGREE_LIMIT;
|
|
64
|
+
} else {
|
|
65
|
+
isQuiteSharp = isSharp;
|
|
66
|
+
isQuiteDull = isDull;
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
return {
|
|
70
|
+
tangents: unitTangents,
|
|
71
|
+
// crossTangents,
|
|
72
|
+
isSharp,
|
|
73
|
+
isDull,
|
|
74
|
+
isQuiteSharp,
|
|
75
|
+
isQuiteDull
|
|
76
|
+
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
|
|
@@ -48,8 +48,8 @@ function getInterfaceCcw(
|
|
|
48
48
|
const crossTangents = crossPrecise(p0,p1,p2); // sign will be correct
|
|
49
49
|
|
|
50
50
|
const xI = twoDiff(p1[0],p0[0]); // tangent x-coordinate
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const yI = twoDiff(p1[1],p0[1]); // tangent y-coordinate
|
|
52
|
+
const xO = twoDiff(p2[0],p1[0]); // tangent x-coordinate
|
|
53
53
|
const yO = twoDiff(p2[1],p1[1]); // tangent y-coordinate
|
|
54
54
|
|
|
55
55
|
const tangentI = [xI,yI];
|
|
@@ -57,7 +57,7 @@ function getInterfaceCcw(
|
|
|
57
57
|
const dotTangents = dotPrecise(tangentI,tangentO);
|
|
58
58
|
|
|
59
59
|
if (crossTangents !== 0 || dotTangents > 0) {
|
|
60
|
-
|
|
60
|
+
return {
|
|
61
61
|
ccw: crossTangents,
|
|
62
62
|
tangentI,
|
|
63
63
|
tangentO,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { compareCps } from "../contact-point/contact-point.js";
|
|
2
1
|
import { CpNode } from "./cp-node.js";
|
|
3
2
|
import { getHoleClosers } from "./fs/get-hole-closers.js";
|
|
4
3
|
import { getSpeed } from "./fs/get-speed.js";
|
|
@@ -34,111 +33,109 @@ import { getBoundaryBeziersBetween } from './fs/get-boundary-beziers-between.js'
|
|
|
34
33
|
import { getMatCurvesBetween } from './fs/get-mat-curves-between.js';
|
|
35
34
|
import { getInitialDegAngleBetweenMatCurves } from "./fs/get-angle-between-mat-curves.js";
|
|
36
35
|
import { getAllVertices } from "./fs/get-all-vertices.js";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const cpNodeComparator = (a: CpNode, b: CpNode) => compareCps(a.cp, b.cp);
|
|
36
|
+
import { cpNodeComparator } from './fs/cp-node-comparator.js';
|
|
40
37
|
|
|
41
38
|
|
|
42
39
|
const CpNodeFs = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Returns the children of this `CpNode` when seen as a MAT edge. Only
|
|
42
|
+
* children in a 'forward' direction are returned. These include all edges
|
|
43
|
+
* except the 'backward' edge given by `prevOnCircle`, even terminating
|
|
44
|
+
* edges.
|
|
45
|
+
*/
|
|
46
|
+
getChildren,
|
|
47
|
+
/**
|
|
48
|
+
* Similar to `getChildren` but returns the child nodes of the tree when
|
|
49
|
+
* `CpNode` is seen as a MAT vertex point (as opposed to edge). In this
|
|
50
|
+
* way the dual graph of the tree can easily be traversed - see e.g.
|
|
51
|
+
* `traverseVertices`. Generally, however, traversing the edges is
|
|
52
|
+
* preferred as it returns the entire Medial Axis (by utilizing
|
|
53
|
+
* `getMatCurveToNext` on each returned edge).
|
|
54
|
+
*/
|
|
55
|
+
getVertexForwardChildren,
|
|
56
|
+
/**
|
|
57
|
+
* Returns all `CpNode`s on the MAT that this `CpNode` is part of
|
|
58
|
+
* starting from the current one and going anti-clockwise around the shape.
|
|
59
|
+
*/
|
|
60
|
+
getAllOnLoop,
|
|
61
|
+
/**
|
|
62
|
+
* Return this (except if exclThis is truthy) and the the other CpNodes
|
|
63
|
+
* around the maximal disk vertex circle in an anti-clockwise order.
|
|
64
|
+
* @param exclThis If true the returned array does not include this
|
|
65
|
+
* `CpNode`.
|
|
66
|
+
*/
|
|
67
|
+
getAllOnCircle,
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if the 2 given `CpNode`s are on the same maximal disk
|
|
70
|
+
* circle.
|
|
71
|
+
* @param cpNode1 A `CpNode`.
|
|
72
|
+
* @param cpNode2 Another `CpNode`
|
|
73
|
+
*/
|
|
74
|
+
isOnSameCircle,
|
|
75
|
+
/**
|
|
76
|
+
* Returns true if this `CpNode` is terminating, i.e. implies a leaf MAT
|
|
77
|
+
* vertex.
|
|
78
|
+
*
|
|
79
|
+
* This is always the case for sharp corners and maximal disks with
|
|
80
|
+
* a single contact point. Note, however, that even in these cases there are
|
|
81
|
+
* two contact points stored (sitting 'on top' of each other) for the
|
|
82
|
+
* maximal disk. It can be seen as a limiting case of a two-prong where the
|
|
83
|
+
* distance between two of the contact points tend to zero. One point
|
|
84
|
+
* (represented by a `CpNode` of course) will be terminating with the
|
|
85
|
+
* other point being its `next`, whereas the other point will *not* be
|
|
86
|
+
* terminating and 'points' back into the shape.
|
|
87
|
+
*/
|
|
88
|
+
isTerminating,
|
|
89
|
+
/**
|
|
90
|
+
* Like isTerminating() but only returns true if all cpNodes on the circle
|
|
91
|
+
* (except this.prevOnCircle) is terminating.
|
|
92
|
+
*/
|
|
93
|
+
isFullyTerminating,
|
|
94
|
+
/**
|
|
95
|
+
* Returns the first `CpNode` (from this one by successively applying
|
|
96
|
+
* .nextOnCircle) that exits the circle.
|
|
97
|
+
*/
|
|
98
|
+
getFirstExit,
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if this `CpNode` represents a sharp corner, i.e. the
|
|
101
|
+
* limiting case of a two-prong having zero radius.
|
|
102
|
+
*
|
|
103
|
+
* Note that two `CpNode`s are stored for each sharp corner, one being
|
|
104
|
+
* terminating and one not. See `isTerminating` for more details.
|
|
105
|
+
*/
|
|
106
|
+
isSharp,
|
|
107
|
+
/**
|
|
108
|
+
* Returns true if this `CpNode`'s maximal disk has only one contact point
|
|
109
|
+
* on the shape boundary (up to planar coordinates). These includes sharp
|
|
110
|
+
* corners.
|
|
111
|
+
*
|
|
112
|
+
* Note, however, that two `CpNode`s are stored for each such point to
|
|
113
|
+
* preserve symmetry - see `isTerminating` for more details.
|
|
114
|
+
*/
|
|
115
|
+
isOneProng,
|
|
116
|
+
/**
|
|
117
|
+
* Returns the number of contact points on the maximal disk circle implied
|
|
118
|
+
* by this `CpNode`.
|
|
119
|
+
*
|
|
120
|
+
* Note, however, that even one-prongs and sharp corners will return 2 (see
|
|
121
|
+
* `isTerminating` for more details); if this is not desired use
|
|
122
|
+
* `getRealProngCount` instead which will return 1 in these cases.
|
|
123
|
+
*/
|
|
124
|
+
getProngCount,
|
|
125
|
+
/**
|
|
126
|
+
* Returns the number of contact points (up to planar coordinates) on the
|
|
127
|
+
* maximal disk circle implied by this `CpNode`.
|
|
128
|
+
*
|
|
129
|
+
* See also `getProngCount`.
|
|
130
|
+
*/
|
|
131
|
+
getRealProngCount,
|
|
132
|
+
/**
|
|
133
|
+
* Primarily for internal use.
|
|
134
|
+
*
|
|
135
|
+
* Compares the order of two `CpNode`s. The order is cyclic and depends
|
|
136
|
+
* on a `CpNode`'s relative position along the shape boundary.
|
|
137
|
+
*/
|
|
138
|
+
cpNodeComparator,
|
|
142
139
|
/**
|
|
143
140
|
* For debugging
|
|
144
141
|
* @param cpNode
|
|
@@ -196,38 +193,38 @@ const CpNodeFs = {
|
|
|
196
193
|
* @param cpNode The `CpNode` to remove.
|
|
197
194
|
*/
|
|
198
195
|
removeVertex,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Returns the bezier curve from the maximal disk of the given `CpNode` to the
|
|
198
|
+
* next `CpNode`'s maximal disk and thus directly represents a piece of the
|
|
199
|
+
* medial axis.
|
|
200
|
+
* @param cpNode
|
|
201
|
+
*/
|
|
202
|
+
getMatCurveToNext,
|
|
203
|
+
isTwoProng,
|
|
204
|
+
getBranch,
|
|
205
|
+
getBranchBeziers,
|
|
206
|
+
getSalience,
|
|
207
|
+
/**
|
|
208
|
+
* Returns the bezier curve from the maximal disk of one `CpNode` to another
|
|
209
|
+
* `CpNode`'s maximal disk.
|
|
210
|
+
* @param cpNodeFrom
|
|
211
|
+
* @param cpNodeTo
|
|
212
|
+
*/
|
|
213
|
+
getMatCurveBetween,
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
* Returns a line segment of unit length starting in the given Vertex center and
|
|
217
|
+
* pointing in the direction of the medial axis (viewed as a rooted tree).
|
|
218
|
+
* @param cpNode
|
|
219
|
+
*/
|
|
220
|
+
getEdgeDirection,
|
|
221
|
+
getBoundaryBeziersBetween,
|
|
222
|
+
getMatCurvesBetween,
|
|
223
|
+
getHoleClosers,
|
|
224
|
+
getSpeed,
|
|
225
|
+
getSmoothedSpeed$,
|
|
226
|
+
getInitialDegAngleBetweenMatCurves,
|
|
227
|
+
getAllVertices
|
|
231
228
|
}
|
|
232
229
|
|
|
233
230
|
|
package/src/cp-node/cp-node.ts
CHANGED
|
@@ -50,37 +50,37 @@ import { ContactPoint } from '../contact-point/contact-point.js';
|
|
|
50
50
|
* in opposite directions.
|
|
51
51
|
*/
|
|
52
52
|
interface CpNode {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
/** The shape boundary contact point, i.e. a `CpNode` without its edges. */
|
|
54
|
+
cp: ContactPoint;
|
|
55
|
+
/** If true, this `CpNode` belongs to a hole-closing maximal disk. */
|
|
56
|
+
isHoleClosing: boolean;
|
|
57
|
+
/** true if this cpNode is at a shape boundary intersection point, false otherwise */
|
|
58
|
+
isIntersection: boolean;
|
|
59
|
+
/** The previous (going clockwise around the boundary) contact point (`CpNode`).*/
|
|
60
|
+
prev: CpNode;
|
|
61
|
+
/** The next (going anti-clockwise around the boundary) contact point (`CpNode`). */
|
|
62
|
+
next: CpNode;
|
|
63
|
+
/**
|
|
64
|
+
* The previous `CpNode` (going clockwise around the inscribed circle
|
|
65
|
+
* defined by the maximal disk).
|
|
66
|
+
*/
|
|
67
|
+
prevOnCircle: CpNode;
|
|
68
|
+
/**
|
|
69
|
+
* The next `CpNode` (going anti-clockwise around
|
|
70
|
+
* the inscribed circle defined by the maximal disk).
|
|
71
|
+
*/
|
|
72
|
+
nextOnCircle: CpNode;
|
|
73
|
+
/**
|
|
74
|
+
* For hole closers only - the next `CpNode` ignoring the hole closer
|
|
75
|
+
*/
|
|
76
|
+
holeCloserNext?: CpNode | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* For hole closers only - the prev `CpNode` ignoring the hole closer
|
|
79
|
+
*/
|
|
80
|
+
holeCloserPrev?: CpNode | undefined;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
/** Only used in export */
|
|
83
|
+
id: number;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
package/src/cp-node/fs/clone.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { CpNode } from "../cp-node.js";
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
type Edge =
|
|
6
6
|
| 'prev'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
| 'next'
|
|
8
|
+
| 'prevOnCircle'
|
|
9
|
+
| 'nextOnCircle';
|
|
10
10
|
|
|
11
11
|
/** @internal */
|
|
12
12
|
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
@@ -38,7 +38,7 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
38
38
|
for (const edge of EDGES) {
|
|
39
39
|
const node = cpNode[edge];
|
|
40
40
|
let newNode = nodeMap.get(node);
|
|
41
|
-
if (!newNode) {
|
|
41
|
+
if (!newNode) {
|
|
42
42
|
newNode = cloneWithoutLinks(node);
|
|
43
43
|
|
|
44
44
|
nodeMap.set(node, newNode);
|
|
@@ -10,15 +10,15 @@ function findFirst(
|
|
|
10
10
|
|
|
11
11
|
if (f(cpStart)) { return cpStart; }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
let cpNode_ = cpNode.next;
|
|
14
|
+
while (cpNode_ !== cpStart) {
|
|
15
|
+
if (f(cpNode_)) {
|
|
16
16
|
return cpNode_;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
cpNode_ = cpNode_.next;
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
|
|
@@ -13,7 +13,7 @@ import type { Curve } from '../../curve/curve.js';
|
|
|
13
13
|
* @param cpNode
|
|
14
14
|
*/
|
|
15
15
|
function getBoundaryBezierPartsToNext(
|
|
16
|
-
cpNode: CpNode): BezierPiece[]
|
|
16
|
+
cpNode: CpNode): BezierPiece[] {
|
|
17
17
|
|
|
18
18
|
const cpThis = cpNode;
|
|
19
19
|
const cpNext = cpNode.next;
|
|
@@ -27,27 +27,22 @@ function getBoundaryBezierPartsToNext(
|
|
|
27
27
|
if (curveThis.loop !== curveNext.loop) {
|
|
28
28
|
// It is a hole-closer going over to the other loop - a kind of terminal
|
|
29
29
|
// CpNode.
|
|
30
|
-
return undefined;
|
|
30
|
+
// return undefined;
|
|
31
|
+
return [];
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const bezierPieces: BezierPiece[] = [];
|
|
34
35
|
|
|
35
36
|
if (curveNext === curveThis) {
|
|
36
37
|
bezierPieces.push(
|
|
37
|
-
{
|
|
38
|
-
ps: posThis.curve.ps,
|
|
39
|
-
ts: [posThis.t, posNext.t]
|
|
40
|
-
}
|
|
38
|
+
{ ps: posThis.curve.ps, ts: [posThis.t, posNext.t] }
|
|
41
39
|
);
|
|
42
40
|
} else {
|
|
43
41
|
bezierPieces.push(
|
|
44
|
-
{
|
|
45
|
-
ps: posThis.curve.ps,
|
|
46
|
-
ts: [posThis.t, 1]
|
|
47
|
-
}
|
|
42
|
+
{ ps: posThis.curve.ps, ts: [posThis.t, 1] }
|
|
48
43
|
);
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
addSkippedBezierPiecess(
|
|
51
46
|
bezierPieces,
|
|
52
47
|
posThis.curve,
|
|
53
48
|
posNext.curve,
|
|
@@ -60,10 +55,10 @@ function getBoundaryBezierPartsToNext(
|
|
|
60
55
|
|
|
61
56
|
|
|
62
57
|
/**
|
|
63
|
-
* @internal
|
|
64
58
|
* Adds pieces of skipped beziers.
|
|
59
|
+
* @internal
|
|
65
60
|
*/
|
|
66
|
-
function
|
|
61
|
+
function addSkippedBezierPiecess(
|
|
67
62
|
bezierPieces: BezierPiece[],
|
|
68
63
|
curveStart: Curve,
|
|
69
64
|
curveEnd: Curve,
|
|
@@ -72,11 +67,10 @@ function addSkippedBeziers(
|
|
|
72
67
|
let curveThis = curveStart;
|
|
73
68
|
do {
|
|
74
69
|
curveThis = curveThis.next;
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
bezierPieces.push(bezierPart);
|
|
70
|
+
const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
71
|
+
bezierPieces.push({
|
|
72
|
+
ps: curveThis.ps, ts: [0, tEnd]
|
|
73
|
+
});
|
|
80
74
|
} while (curveThis !== curveEnd);
|
|
81
75
|
}
|
|
82
76
|
|