flo-mat 2.0.2 → 2.0.4
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/browser/index.js +8409 -8358
- package/browser/index.min.js +1 -1
- package/node/circle.d.ts +20 -20
- package/node/circle.js +31 -31
- package/node/compare-curvatures-at-interface.d.ts +19 -19
- package/node/compare-curvatures-at-interface.js +124 -124
- package/node/contact-point.d.ts +26 -26
- package/node/contact-point.js +25 -25
- package/node/cp-node/clone.d.ts +8 -8
- package/node/cp-node/clone.js +31 -31
- package/node/cp-node/remove.d.ts +9 -9
- package/node/cp-node/remove.js +19 -19
- package/node/cp-node.d.ts +202 -202
- package/node/cp-node.js +320 -320
- package/node/curve.d.ts +46 -46
- package/node/curve.js +88 -88
- package/node/debug/cp-node-for-debugging.d.ts +11 -11
- package/node/debug/cp-node-for-debugging.js +1 -1
- package/node/debug/debug-elem-types.d.ts +32 -32
- package/node/debug/debug-elem-types.js +1 -1
- package/node/debug/debug.d.ts +50 -50
- package/node/debug/debug.js +75 -75
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
- package/node/debug/functions/draw-elem/branch.d.ts +4 -4
- package/node/debug/functions/draw-elem/branch.js +22 -22
- package/node/debug/functions/draw-elem/culls.d.ts +4 -4
- package/node/debug/functions/draw-elem/culls.js +21 -21
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
- package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
- package/node/debug/functions/draw-elem/draw-elem.js +45 -45
- package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/dull-corner.js +10 -10
- package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
- package/node/debug/functions/draw-elem/leaves.js +12 -12
- package/node/debug/functions/draw-elem/loop.d.ts +4 -4
- package/node/debug/functions/draw-elem/loop.js +11 -11
- package/node/debug/functions/draw-elem/loops.d.ts +4 -4
- package/node/debug/functions/draw-elem/loops.js +6 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
- package/node/debug/functions/draw-elem/mat.d.ts +4 -4
- package/node/debug/functions/draw-elem/mat.js +30 -30
- package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/max-vertex.js +8 -8
- package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
- package/node/debug/functions/draw-elem/min-y.js +13 -13
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
- package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong.js +16 -16
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
- package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/three-prong.js +16 -16
- package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
- package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/two-prong.js +36 -36
- package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/vertex.js +27 -27
- package/node/debug/functions/general.d.ts +48 -48
- package/node/debug/functions/general.js +52 -52
- package/node/debug/functions/three-prong.d.ts +11 -11
- package/node/debug/functions/three-prong.js +184 -184
- package/node/debug/functions/two-prong.d.ts +13 -13
- package/node/debug/functions/two-prong.js +117 -117
- package/node/debug/three-prong-for-debugging.d.ts +31 -31
- package/node/debug/three-prong-for-debugging.js +20 -20
- package/node/debug/two-prong-for-debugging.d.ts +26 -26
- package/node/debug/two-prong-for-debugging.js +1 -1
- package/node/find-mats.d.ts +26 -26
- package/node/find-mats.js +122 -122
- package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
- package/node/get-boundary-bezier-parts-to-next.js +42 -42
- package/node/get-boundary-beziers-to-next.d.ts +8 -8
- package/node/get-boundary-beziers-to-next.js +44 -44
- package/node/get-bounding-box-.d.ts +2 -2
- package/node/get-bounding-box-.js +4 -4
- package/node/get-branches.d.ts +12 -12
- package/node/get-branches.js +68 -68
- package/node/get-curve/get-curve-between.d.ts +9 -9
- package/node/get-curve/get-curve-between.js +56 -56
- package/node/get-curve/get-edge-direction.d.ts +9 -9
- package/node/get-curve/get-edge-direction.js +53 -53
- package/node/get-curve-to-next.d.ts +9 -9
- package/node/get-curve-to-next.js +11 -11
- package/node/get-interface-ccw.d.ts +24 -24
- package/node/get-interface-ccw.js +97 -97
- package/node/index.d.ts +36 -36
- package/node/index.js +32 -32
- package/node/loop/get-max-coordinate.d.ts +10 -10
- package/node/loop/get-max-coordinate.js +43 -43
- package/node/loop.d.ts +16 -16
- package/node/loop.js +34 -34
- package/node/mat/add-to-cp-graph.d.ts +16 -16
- package/node/mat/add-to-cp-graph.js +30 -30
- package/node/mat/bezier-piece.d.ts +12 -12
- package/node/mat/bezier-piece.js +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -72
- package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
- package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
- package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
- package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
- package/node/mat/corner.d.ts +37 -37
- package/node/mat/corner.js +1 -1
- package/node/mat/create-new-cp-tree.d.ts +9 -9
- package/node/mat/create-new-cp-tree.js +23 -23
- package/node/mat/elem-type-two-prong.d.ts +3 -3
- package/node/mat/elem-type-two-prong.js +1 -1
- package/node/mat/find-mat/add-1-prong.d.ts +12 -12
- package/node/mat/find-mat/add-1-prong.js +42 -42
- package/node/mat/find-mat/add-2-prong.d.ts +21 -21
- package/node/mat/find-mat/add-2-prong.js +192 -192
- package/node/mat/find-mat/add-3-prong.d.ts +19 -19
- package/node/mat/find-mat/add-3-prong.js +54 -54
- package/node/mat/find-mat/add-debug-info.d.ts +9 -9
- package/node/mat/find-mat/add-debug-info.js +67 -67
- package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
- package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
- package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
- package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
- package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
- package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
- package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
- package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs.js +73 -73
- package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
- package/node/mat/find-mat/find-and-add-3-prongs.js +146 -146
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
- package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
- package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
- package/node/mat/find-mat/get-sharp-corners.js +17 -17
- package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
- package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
- package/node/mat/get-boundary-piece-beziers.js +58 -58
- package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
- package/node/mat/get-contact-circles-at-interface.js +20 -20
- package/node/mat/get-largest-vertex.d.ts +4 -4
- package/node/mat/get-largest-vertex.js +9 -9
- package/node/mat/get-leaves.d.ts +4 -4
- package/node/mat/get-leaves.js +12 -12
- package/node/mat/get-neighboring-cps.d.ts +14 -14
- package/node/mat/get-neighboring-cps.js +30 -30
- package/node/mat/get-two-prong-type.d.ts +5 -5
- package/node/mat/get-two-prong-type.js +8 -8
- package/node/mat/is-another-cp-closeby.d.ts +20 -20
- package/node/mat/is-another-cp-closeby.js +55 -55
- package/node/mat/simplify-mat-map-only.d.ts +23 -23
- package/node/mat/simplify-mat-map-only.js +80 -80
- package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
- package/node/mat/to-scale-axis/add-debug-info.js +13 -13
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
- package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
- package/node/mat/to-scale-axis/cull.d.ts +12 -12
- package/node/mat/to-scale-axis/cull.js +132 -132
- package/node/mat/trim-mat.d.ts +8 -8
- package/node/mat/trim-mat.js +16 -16
- package/node/mat.d.ts +22 -22
- package/node/mat.js +1 -1
- package/node/point-on-shape.d.ts +73 -73
- package/node/point-on-shape.js +167 -167
- package/node/simplify-mat.d.ts +16 -16
- package/node/simplify-mat.js +71 -71
- package/node/svg/get-loop-bounds.d.ts +12 -12
- package/node/svg/get-loop-bounds.js +80 -80
- package/node/svg/get-min-y-pos.d.ts +8 -8
- package/node/svg/get-min-y-pos.js +9 -9
- package/node/svg/get-shape-bounds.d.ts +9 -9
- package/node/svg/get-shape-bounds.js +35 -35
- package/node/sweep-line/sweep-line.d.ts +18 -18
- package/node/sweep-line/sweep-line.js +72 -72
- package/node/to-scale-axis.d.ts +16 -16
- package/node/to-scale-axis.js +74 -74
- package/node/traverse-edges.d.ts +10 -10
- package/node/traverse-edges.js +21 -21
- package/node/traverse-vertices.d.ts +12 -12
- package/node/traverse-vertices.js +27 -27
- package/package.json +15 -15
- package/tsconfig.json +0 -1
package/node/circle.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical circle representation.
|
|
3
|
-
*/
|
|
4
|
-
interface Circle {
|
|
5
|
-
center: number[];
|
|
6
|
-
radius: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Returns a scaled version of the given circle without changing its center.
|
|
10
|
-
* @param circle
|
|
11
|
-
* @param s multiplier
|
|
12
|
-
*/
|
|
13
|
-
declare function scaleCircle(circle: Circle, s: number): Circle;
|
|
14
|
-
/**
|
|
15
|
-
* Returns true if the first circle engulfs the second.
|
|
16
|
-
* @param c1
|
|
17
|
-
* @param c2
|
|
18
|
-
*/
|
|
19
|
-
declare function engulfsCircle(c1: Circle, c2: Circle): boolean;
|
|
20
|
-
export { Circle, scaleCircle, engulfsCircle };
|
|
1
|
+
/**
|
|
2
|
+
* Canonical circle representation.
|
|
3
|
+
*/
|
|
4
|
+
interface Circle {
|
|
5
|
+
center: number[];
|
|
6
|
+
radius: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Returns a scaled version of the given circle without changing its center.
|
|
10
|
+
* @param circle
|
|
11
|
+
* @param s multiplier
|
|
12
|
+
*/
|
|
13
|
+
declare function scaleCircle(circle: Circle, s: number): Circle;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the first circle engulfs the second.
|
|
16
|
+
* @param c1
|
|
17
|
+
* @param c2
|
|
18
|
+
*/
|
|
19
|
+
declare function engulfsCircle(c1: Circle, c2: Circle): boolean;
|
|
20
|
+
export { Circle, scaleCircle, engulfsCircle };
|
package/node/circle.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { squaredDistanceBetween } from 'flo-vector2d';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a scaled version of the given circle without changing its center.
|
|
4
|
-
* @param circle
|
|
5
|
-
* @param s multiplier
|
|
6
|
-
*/
|
|
7
|
-
function scaleCircle(circle, s) {
|
|
8
|
-
return { center: circle.center, radius: s * circle.radius };
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns true if the first circle engulfs the second.
|
|
12
|
-
* @param c1
|
|
13
|
-
* @param c2
|
|
14
|
-
*/
|
|
15
|
-
function engulfsCircle(c1, c2) {
|
|
16
|
-
if (c1.radius <= c2.radius) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const d = squaredDistanceBetween(c1.center, c2.center);
|
|
20
|
-
const dr = c1.radius - c2.radius;
|
|
21
|
-
const δ = dr * dr;
|
|
22
|
-
return δ > d;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returns a human-readable string description of the given circle.
|
|
26
|
-
* @param circle
|
|
27
|
-
*/
|
|
28
|
-
function toString(circle) {
|
|
29
|
-
return 'c: ' + circle.center + ' r: ' + circle.radius;
|
|
30
|
-
}
|
|
31
|
-
export { scaleCircle, engulfsCircle };
|
|
1
|
+
import { squaredDistanceBetween } from 'flo-vector2d';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a scaled version of the given circle without changing its center.
|
|
4
|
+
* @param circle
|
|
5
|
+
* @param s multiplier
|
|
6
|
+
*/
|
|
7
|
+
function scaleCircle(circle, s) {
|
|
8
|
+
return { center: circle.center, radius: s * circle.radius };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the first circle engulfs the second.
|
|
12
|
+
* @param c1
|
|
13
|
+
* @param c2
|
|
14
|
+
*/
|
|
15
|
+
function engulfsCircle(c1, c2) {
|
|
16
|
+
if (c1.radius <= c2.radius) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const d = squaredDistanceBetween(c1.center, c2.center);
|
|
20
|
+
const dr = c1.radius - c2.radius;
|
|
21
|
+
const δ = dr * dr;
|
|
22
|
+
return δ > d;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns a human-readable string description of the given circle.
|
|
26
|
+
* @param circle
|
|
27
|
+
*/
|
|
28
|
+
function toString(circle) {
|
|
29
|
+
return 'c: ' + circle.center + ' r: ' + circle.radius;
|
|
30
|
+
}
|
|
31
|
+
export { scaleCircle, engulfsCircle };
|
|
32
32
|
//# sourceMappingURL=circle.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compare the curvature, κ, between two curves at t === 0.
|
|
3
|
-
*
|
|
4
|
-
* Returns a positive number if κ for psI > κ for psO, negative if κ for psI < κ
|
|
5
|
-
* for psO or zero if the curve extensions are identical (i.e. in same K-family).
|
|
6
|
-
*
|
|
7
|
-
* Precondition: The point psI evaluated at zero must === the point psO
|
|
8
|
-
* evaluated at zero.
|
|
9
|
-
*
|
|
10
|
-
* // TODO - is this correct?
|
|
11
|
-
* Exact: Returns the exact result if the bithlength of all
|
|
12
|
-
* coordinates <= 53 - 5 === 48 and are bit-aligned.
|
|
13
|
-
*
|
|
14
|
-
* @param psI An order 1, 2 or 3 bezier, e.g. [[0,0],[1,1],[2,1],[2,0]]
|
|
15
|
-
* representing the incoming curve
|
|
16
|
-
* @param psO Another bezier representing the outgoing curve
|
|
17
|
-
*/
|
|
18
|
-
declare function compareCurvaturesAtInterface(psI: number[][], psO: number[][]): number;
|
|
19
|
-
export { compareCurvaturesAtInterface };
|
|
1
|
+
/**
|
|
2
|
+
* Compare the curvature, κ, between two curves at t === 0.
|
|
3
|
+
*
|
|
4
|
+
* Returns a positive number if κ for psI > κ for psO, negative if κ for psI < κ
|
|
5
|
+
* for psO or zero if the curve extensions are identical (i.e. in same K-family).
|
|
6
|
+
*
|
|
7
|
+
* Precondition: The point psI evaluated at zero must === the point psO
|
|
8
|
+
* evaluated at zero.
|
|
9
|
+
*
|
|
10
|
+
* // TODO - is this correct?
|
|
11
|
+
* Exact: Returns the exact result if the bithlength of all
|
|
12
|
+
* coordinates <= 53 - 5 === 48 and are bit-aligned.
|
|
13
|
+
*
|
|
14
|
+
* @param psI An order 1, 2 or 3 bezier, e.g. [[0,0],[1,1],[2,1],[2,0]]
|
|
15
|
+
* representing the incoming curve
|
|
16
|
+
* @param psO Another bezier representing the outgoing curve
|
|
17
|
+
*/
|
|
18
|
+
declare function compareCurvaturesAtInterface(psI: number[][], psO: number[][]): number;
|
|
19
|
+
export { compareCurvaturesAtInterface };
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { eSign, twoProduct, eDiff, expansionProduct, fastExpansionSum, scaleExpansion } from "big-float-ts";
|
|
2
|
-
import { tangentAt0, evaluate2ndDerivativeAt0, toPowerBasis_3rdDerivative } from "flo-bezier3";
|
|
3
|
-
/**
|
|
4
|
-
* Compare the curvature, κ, between two curves at t === 0.
|
|
5
|
-
*
|
|
6
|
-
* Returns a positive number if κ for psI > κ for psO, negative if κ for psI < κ
|
|
7
|
-
* for psO or zero if the curve extensions are identical (i.e. in same K-family).
|
|
8
|
-
*
|
|
9
|
-
* Precondition: The point psI evaluated at zero must === the point psO
|
|
10
|
-
* evaluated at zero.
|
|
11
|
-
*
|
|
12
|
-
* // TODO - is this correct?
|
|
13
|
-
* Exact: Returns the exact result if the bithlength of all
|
|
14
|
-
* coordinates <= 53 - 5 === 48 and are bit-aligned.
|
|
15
|
-
*
|
|
16
|
-
* @param psI An order 1, 2 or 3 bezier, e.g. [[0,0],[1,1],[2,1],[2,0]]
|
|
17
|
-
* representing the incoming curve
|
|
18
|
-
* @param psO Another bezier representing the outgoing curve
|
|
19
|
-
*/
|
|
20
|
-
function compareCurvaturesAtInterface(psI, psO) {
|
|
21
|
-
// Get x' and y' for incoming curve evaluated at 0
|
|
22
|
-
const [dxI, dyI] = tangentAt0(psI); // max bitlength increase / max shift === 3
|
|
23
|
-
// Get x'' and y'' for incoming curve evaluated at 0
|
|
24
|
-
const [ddxI, ddyI] = evaluate2ndDerivativeAt0(psI); // max bitlength increase / max shift === 5
|
|
25
|
-
// Get x' and y' for outgoing curve evaluated at 0
|
|
26
|
-
const [dxO, dyO] = tangentAt0(psO); // max bitlength increase / max shift === 3
|
|
27
|
-
// Get x'' and y'' for outgoing curve evaluated at 0
|
|
28
|
-
const [ddxO, ddyO] = evaluate2ndDerivativeAt0(psO); // max bitlength increase / max shift === 5
|
|
29
|
-
//console.log('κI: ', κ(psI, 0));
|
|
30
|
-
//console.log('κO: ', κ(psO, 0));
|
|
31
|
-
// Remember the formula for the signed curvature of a parametric curve:
|
|
32
|
-
// κ = x′y′′ - y′x′′ / sqrt(x′² + y′²)³
|
|
33
|
-
// κ² = (x′y′′ - y′x′′)² / (x′² + y′²)³
|
|
34
|
-
// This allows us to do an exact comparison of curvatures
|
|
35
|
-
// Simplifying the above gives (denoting the incoming curve with a subscript
|
|
36
|
-
// of 1 and the outgoing with a 2):
|
|
37
|
-
// κIncoming > κOutgoing
|
|
38
|
-
// <=> (x₁′y₁′′ - y₁′x₁′′)²(x₂′² + y₂′²)³ > (x₂′y₂′′ - y₂′x₂′′)²(x₁′² + y₁′²)³
|
|
39
|
-
// <=> a²b³ > c²d³
|
|
40
|
-
// Note b³ > 0 and d³ > 0
|
|
41
|
-
// max aggregate bitlength increase (let original bitlength === p):
|
|
42
|
-
// a -> 2 x ((p+3)+(p+5) + 1) === 4p + 18 -> max p in double precision === 8 -> too low
|
|
43
|
-
//let a = (dxI*ddyI - dyI*ddxI)**2;
|
|
44
|
-
// b -> 3 x ((p+3) + 1) === 3p + 12
|
|
45
|
-
//let b = (dxO*dxO + dyO*dyO )**3;
|
|
46
|
-
// c -> 2 x ((p+3)+(p+5) + 1) === 4p + 18
|
|
47
|
-
//let c = (dxO*ddyO - dyO*ddxO)**2;
|
|
48
|
-
// d -> 3 x ((p+3) + 1) === 3p + 12
|
|
49
|
-
//let d = (dxI*dxI + dyI*dyI )**3;
|
|
50
|
-
// We need to resort to exact floating point arithmetic at this point
|
|
51
|
-
const a = eDiff(twoProduct(dxI, ddyI), twoProduct(dyI, ddxI));
|
|
52
|
-
const c = eDiff(twoProduct(dxO, ddyO), twoProduct(dyO, ddxO));
|
|
53
|
-
const signA = eSign(a);
|
|
54
|
-
const signC = eSign(c);
|
|
55
|
-
if (signA !== signC) {
|
|
56
|
-
//console.log('branch 3');
|
|
57
|
-
return signA - signC;
|
|
58
|
-
}
|
|
59
|
-
const b = fastExpansionSum(twoProduct(dxO, dxO), twoProduct(dyO, dyO));
|
|
60
|
-
const d = fastExpansionSum(twoProduct(dxI, dxI), twoProduct(dyI, dyI));
|
|
61
|
-
const b2 = expansionProduct(b, b);
|
|
62
|
-
const b3 = expansionProduct(b2, b);
|
|
63
|
-
const d2 = expansionProduct(d, d);
|
|
64
|
-
const d3 = expansionProduct(d2, d);
|
|
65
|
-
if (signA !== 0 || signC !== 0) {
|
|
66
|
-
//console.log('branch 4');
|
|
67
|
-
const a2 = expansionProduct(a, a);
|
|
68
|
-
const c2 = expansionProduct(c, c);
|
|
69
|
-
// max aggregate bitlength increase (let original bitlength === p):
|
|
70
|
-
// κ -> (2 x ((p+3)+(p+5) + 1)) + (3 x ((p+3) + 1)) === 7p + 30
|
|
71
|
-
// e.g. for bit-aligned input bitlength p of 10 we get output bitlength
|
|
72
|
-
// of 100, or for p === 3 (the max exact bitlength allowed to have exact
|
|
73
|
-
// results without resorting to infinite precision) we get 51 bits.
|
|
74
|
-
const κI = expansionProduct(a2, b3);
|
|
75
|
-
const κO = expansionProduct(c2, d3);
|
|
76
|
-
const δκ = eSign(eDiff(κI, κO));
|
|
77
|
-
if (δκ !== 0) {
|
|
78
|
-
//console.log('branch 5');
|
|
79
|
-
// At this point signA === signC, both +tive or -tive
|
|
80
|
-
return signA > 0 ? δκ : -δκ;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// At this point signA === signC, both +tive or -tive or 0
|
|
84
|
-
// Now we have to look at the change of curvature w.r.t. the parameter t,
|
|
85
|
-
// i.e.
|
|
86
|
-
// κ′ = [(x′²+y′²)(x′y′′′-y′x′′′) - 3(x′y′′-y′x′′)(x′x′′+y′y′′)] / (x′²+y′²)^(5/2)
|
|
87
|
-
// Therefore: (denoting the incoming curve with a subscript of 1 and the outgoing with a 2)
|
|
88
|
-
// κ′Incoming > κ′Outgoing
|
|
89
|
-
// <=> [(x₁′²+y₁′²)(x₁′y₁′′′-y₁′x₁′′′) - 3(x₁′y₁′′-y₁′x₁′′)(x₁′x₁′′+y₁′y₁′′)]²(x₂′²+y₂′²)⁵ >
|
|
90
|
-
// [(x₂′²+y₂′²)(x₂′y₂′′′-y₂′x₂′′′) - 3(x₂′y₂′′-y₂′x₂′′)(x₂′x₂′′+y₂′y₂′′)]²(x₁′²+y₁′²)⁵
|
|
91
|
-
// <=> (de - 3af)²b⁵ > (bg - 3ch)²d⁵
|
|
92
|
-
// <=> i²b⁵ > j²d⁵
|
|
93
|
-
// Get x′′′ and y′′′ for incoming curve evaluated at 1
|
|
94
|
-
const [dddxI, dddyI] = toPowerBasis_3rdDerivative(psI); // max bitlength increase === max shift === 6
|
|
95
|
-
const [dddxO, dddyO] = toPowerBasis_3rdDerivative(psO); // max bitlength increase === max shift === 6
|
|
96
|
-
const e = eDiff(twoProduct(dxI, dddyI), twoProduct(dyI, dddxI));
|
|
97
|
-
const f = fastExpansionSum(twoProduct(dxI, ddxI), twoProduct(dyI, ddyI));
|
|
98
|
-
const g = eDiff(twoProduct(dxO, dddyO), twoProduct(dyO, dddxO));
|
|
99
|
-
const h = fastExpansionSum(twoProduct(dxO, ddxO), twoProduct(dyO, ddyO));
|
|
100
|
-
// (de - 3af)²b⁵ > (bg - 3ch)²d⁵
|
|
101
|
-
// i²b⁵ > j²d⁵
|
|
102
|
-
const i = eDiff(expansionProduct(d, e), scaleExpansion(expansionProduct(a, f), 3));
|
|
103
|
-
const j = eDiff(expansionProduct(b, g), scaleExpansion(expansionProduct(c, h), 3));
|
|
104
|
-
const signI = eSign(i);
|
|
105
|
-
const signJ = eSign(j);
|
|
106
|
-
if (signA !== signC) {
|
|
107
|
-
return signI - signJ;
|
|
108
|
-
}
|
|
109
|
-
if (signI === 0 && signJ === 0) {
|
|
110
|
-
// Both curve extensions are identical, i.e. in the same K-family
|
|
111
|
-
return 0;
|
|
112
|
-
}
|
|
113
|
-
const i2 = expansionProduct(i, i);
|
|
114
|
-
const b5 = expansionProduct(b2, b3);
|
|
115
|
-
const j2 = expansionProduct(j, j);
|
|
116
|
-
const d5 = expansionProduct(d2, d3);
|
|
117
|
-
const dκI = expansionProduct(i2, b5);
|
|
118
|
-
const dκO = expansionProduct(j2, d5);
|
|
119
|
-
const sgn = eSign(eDiff(dκI, dκO));
|
|
120
|
-
return signI > 0 ? sgn : -sgn;
|
|
121
|
-
// If the above returned value is still zero then the two curve extensions
|
|
122
|
-
// are identical, i.e. in the same K-family
|
|
123
|
-
}
|
|
124
|
-
export { compareCurvaturesAtInterface };
|
|
1
|
+
import { eSign, twoProduct, eDiff, expansionProduct, fastExpansionSum, scaleExpansion } from "big-float-ts";
|
|
2
|
+
import { tangentAt0, evaluate2ndDerivativeAt0, toPowerBasis_3rdDerivative } from "flo-bezier3";
|
|
3
|
+
/**
|
|
4
|
+
* Compare the curvature, κ, between two curves at t === 0.
|
|
5
|
+
*
|
|
6
|
+
* Returns a positive number if κ for psI > κ for psO, negative if κ for psI < κ
|
|
7
|
+
* for psO or zero if the curve extensions are identical (i.e. in same K-family).
|
|
8
|
+
*
|
|
9
|
+
* Precondition: The point psI evaluated at zero must === the point psO
|
|
10
|
+
* evaluated at zero.
|
|
11
|
+
*
|
|
12
|
+
* // TODO - is this correct?
|
|
13
|
+
* Exact: Returns the exact result if the bithlength of all
|
|
14
|
+
* coordinates <= 53 - 5 === 48 and are bit-aligned.
|
|
15
|
+
*
|
|
16
|
+
* @param psI An order 1, 2 or 3 bezier, e.g. [[0,0],[1,1],[2,1],[2,0]]
|
|
17
|
+
* representing the incoming curve
|
|
18
|
+
* @param psO Another bezier representing the outgoing curve
|
|
19
|
+
*/
|
|
20
|
+
function compareCurvaturesAtInterface(psI, psO) {
|
|
21
|
+
// Get x' and y' for incoming curve evaluated at 0
|
|
22
|
+
const [dxI, dyI] = tangentAt0(psI); // max bitlength increase / max shift === 3
|
|
23
|
+
// Get x'' and y'' for incoming curve evaluated at 0
|
|
24
|
+
const [ddxI, ddyI] = evaluate2ndDerivativeAt0(psI); // max bitlength increase / max shift === 5
|
|
25
|
+
// Get x' and y' for outgoing curve evaluated at 0
|
|
26
|
+
const [dxO, dyO] = tangentAt0(psO); // max bitlength increase / max shift === 3
|
|
27
|
+
// Get x'' and y'' for outgoing curve evaluated at 0
|
|
28
|
+
const [ddxO, ddyO] = evaluate2ndDerivativeAt0(psO); // max bitlength increase / max shift === 5
|
|
29
|
+
//console.log('κI: ', κ(psI, 0));
|
|
30
|
+
//console.log('κO: ', κ(psO, 0));
|
|
31
|
+
// Remember the formula for the signed curvature of a parametric curve:
|
|
32
|
+
// κ = x′y′′ - y′x′′ / sqrt(x′² + y′²)³
|
|
33
|
+
// κ² = (x′y′′ - y′x′′)² / (x′² + y′²)³
|
|
34
|
+
// This allows us to do an exact comparison of curvatures
|
|
35
|
+
// Simplifying the above gives (denoting the incoming curve with a subscript
|
|
36
|
+
// of 1 and the outgoing with a 2):
|
|
37
|
+
// κIncoming > κOutgoing
|
|
38
|
+
// <=> (x₁′y₁′′ - y₁′x₁′′)²(x₂′² + y₂′²)³ > (x₂′y₂′′ - y₂′x₂′′)²(x₁′² + y₁′²)³
|
|
39
|
+
// <=> a²b³ > c²d³
|
|
40
|
+
// Note b³ > 0 and d³ > 0
|
|
41
|
+
// max aggregate bitlength increase (let original bitlength === p):
|
|
42
|
+
// a -> 2 x ((p+3)+(p+5) + 1) === 4p + 18 -> max p in double precision === 8 -> too low
|
|
43
|
+
//let a = (dxI*ddyI - dyI*ddxI)**2;
|
|
44
|
+
// b -> 3 x ((p+3) + 1) === 3p + 12
|
|
45
|
+
//let b = (dxO*dxO + dyO*dyO )**3;
|
|
46
|
+
// c -> 2 x ((p+3)+(p+5) + 1) === 4p + 18
|
|
47
|
+
//let c = (dxO*ddyO - dyO*ddxO)**2;
|
|
48
|
+
// d -> 3 x ((p+3) + 1) === 3p + 12
|
|
49
|
+
//let d = (dxI*dxI + dyI*dyI )**3;
|
|
50
|
+
// We need to resort to exact floating point arithmetic at this point
|
|
51
|
+
const a = eDiff(twoProduct(dxI, ddyI), twoProduct(dyI, ddxI));
|
|
52
|
+
const c = eDiff(twoProduct(dxO, ddyO), twoProduct(dyO, ddxO));
|
|
53
|
+
const signA = eSign(a);
|
|
54
|
+
const signC = eSign(c);
|
|
55
|
+
if (signA !== signC) {
|
|
56
|
+
//console.log('branch 3');
|
|
57
|
+
return signA - signC;
|
|
58
|
+
}
|
|
59
|
+
const b = fastExpansionSum(twoProduct(dxO, dxO), twoProduct(dyO, dyO));
|
|
60
|
+
const d = fastExpansionSum(twoProduct(dxI, dxI), twoProduct(dyI, dyI));
|
|
61
|
+
const b2 = expansionProduct(b, b);
|
|
62
|
+
const b3 = expansionProduct(b2, b);
|
|
63
|
+
const d2 = expansionProduct(d, d);
|
|
64
|
+
const d3 = expansionProduct(d2, d);
|
|
65
|
+
if (signA !== 0 || signC !== 0) {
|
|
66
|
+
//console.log('branch 4');
|
|
67
|
+
const a2 = expansionProduct(a, a);
|
|
68
|
+
const c2 = expansionProduct(c, c);
|
|
69
|
+
// max aggregate bitlength increase (let original bitlength === p):
|
|
70
|
+
// κ -> (2 x ((p+3)+(p+5) + 1)) + (3 x ((p+3) + 1)) === 7p + 30
|
|
71
|
+
// e.g. for bit-aligned input bitlength p of 10 we get output bitlength
|
|
72
|
+
// of 100, or for p === 3 (the max exact bitlength allowed to have exact
|
|
73
|
+
// results without resorting to infinite precision) we get 51 bits.
|
|
74
|
+
const κI = expansionProduct(a2, b3);
|
|
75
|
+
const κO = expansionProduct(c2, d3);
|
|
76
|
+
const δκ = eSign(eDiff(κI, κO));
|
|
77
|
+
if (δκ !== 0) {
|
|
78
|
+
//console.log('branch 5');
|
|
79
|
+
// At this point signA === signC, both +tive or -tive
|
|
80
|
+
return signA > 0 ? δκ : -δκ;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// At this point signA === signC, both +tive or -tive or 0
|
|
84
|
+
// Now we have to look at the change of curvature w.r.t. the parameter t,
|
|
85
|
+
// i.e.
|
|
86
|
+
// κ′ = [(x′²+y′²)(x′y′′′-y′x′′′) - 3(x′y′′-y′x′′)(x′x′′+y′y′′)] / (x′²+y′²)^(5/2)
|
|
87
|
+
// Therefore: (denoting the incoming curve with a subscript of 1 and the outgoing with a 2)
|
|
88
|
+
// κ′Incoming > κ′Outgoing
|
|
89
|
+
// <=> [(x₁′²+y₁′²)(x₁′y₁′′′-y₁′x₁′′′) - 3(x₁′y₁′′-y₁′x₁′′)(x₁′x₁′′+y₁′y₁′′)]²(x₂′²+y₂′²)⁵ >
|
|
90
|
+
// [(x₂′²+y₂′²)(x₂′y₂′′′-y₂′x₂′′′) - 3(x₂′y₂′′-y₂′x₂′′)(x₂′x₂′′+y₂′y₂′′)]²(x₁′²+y₁′²)⁵
|
|
91
|
+
// <=> (de - 3af)²b⁵ > (bg - 3ch)²d⁵
|
|
92
|
+
// <=> i²b⁵ > j²d⁵
|
|
93
|
+
// Get x′′′ and y′′′ for incoming curve evaluated at 1
|
|
94
|
+
const [dddxI, dddyI] = toPowerBasis_3rdDerivative(psI); // max bitlength increase === max shift === 6
|
|
95
|
+
const [dddxO, dddyO] = toPowerBasis_3rdDerivative(psO); // max bitlength increase === max shift === 6
|
|
96
|
+
const e = eDiff(twoProduct(dxI, dddyI), twoProduct(dyI, dddxI));
|
|
97
|
+
const f = fastExpansionSum(twoProduct(dxI, ddxI), twoProduct(dyI, ddyI));
|
|
98
|
+
const g = eDiff(twoProduct(dxO, dddyO), twoProduct(dyO, dddxO));
|
|
99
|
+
const h = fastExpansionSum(twoProduct(dxO, ddxO), twoProduct(dyO, ddyO));
|
|
100
|
+
// (de - 3af)²b⁵ > (bg - 3ch)²d⁵
|
|
101
|
+
// i²b⁵ > j²d⁵
|
|
102
|
+
const i = eDiff(expansionProduct(d, e), scaleExpansion(expansionProduct(a, f), 3));
|
|
103
|
+
const j = eDiff(expansionProduct(b, g), scaleExpansion(expansionProduct(c, h), 3));
|
|
104
|
+
const signI = eSign(i);
|
|
105
|
+
const signJ = eSign(j);
|
|
106
|
+
if (signA !== signC) {
|
|
107
|
+
return signI - signJ;
|
|
108
|
+
}
|
|
109
|
+
if (signI === 0 && signJ === 0) {
|
|
110
|
+
// Both curve extensions are identical, i.e. in the same K-family
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
const i2 = expansionProduct(i, i);
|
|
114
|
+
const b5 = expansionProduct(b2, b3);
|
|
115
|
+
const j2 = expansionProduct(j, j);
|
|
116
|
+
const d5 = expansionProduct(d2, d3);
|
|
117
|
+
const dκI = expansionProduct(i2, b5);
|
|
118
|
+
const dκO = expansionProduct(j2, d5);
|
|
119
|
+
const sgn = eSign(eDiff(dκI, dκO));
|
|
120
|
+
return signI > 0 ? sgn : -sgn;
|
|
121
|
+
// If the above returned value is still zero then the two curve extensions
|
|
122
|
+
// are identical, i.e. in the same K-family
|
|
123
|
+
}
|
|
124
|
+
export { compareCurvaturesAtInterface };
|
|
125
125
|
//# sourceMappingURL=compare-curvatures-at-interface.js.map
|
package/node/contact-point.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { IPointOnShape } from './point-on-shape.js';
|
|
2
|
-
import { Circle } from './circle.js';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a point on the shape boundary for which MAT data has been
|
|
5
|
-
* calculated.
|
|
6
|
-
*/
|
|
7
|
-
interface ContactPoint {
|
|
8
|
-
/** Identifies the point on the shape boundary. */
|
|
9
|
-
pointOnShape: IPointOnShape;
|
|
10
|
-
/** The maximal disk circle touching this point. */
|
|
11
|
-
circle: Circle;
|
|
12
|
-
/** Internally used to order two points lying at the same planar point. */
|
|
13
|
-
order: number;
|
|
14
|
-
/** Internally used to order two points lying at the same planar point. */
|
|
15
|
-
order2: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Primarily for internal use.
|
|
19
|
-
*
|
|
20
|
-
* Compares the two contact points according to their order along the shape
|
|
21
|
-
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
22
|
-
* @param a The first contact point.
|
|
23
|
-
* @param b The second contact point.
|
|
24
|
-
*/
|
|
25
|
-
declare function compareCps(a: ContactPoint, b: ContactPoint): number;
|
|
26
|
-
export { ContactPoint, compareCps };
|
|
1
|
+
import { IPointOnShape } from './point-on-shape.js';
|
|
2
|
+
import { Circle } from './circle.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a point on the shape boundary for which MAT data has been
|
|
5
|
+
* calculated.
|
|
6
|
+
*/
|
|
7
|
+
interface ContactPoint {
|
|
8
|
+
/** Identifies the point on the shape boundary. */
|
|
9
|
+
pointOnShape: IPointOnShape;
|
|
10
|
+
/** The maximal disk circle touching this point. */
|
|
11
|
+
circle: Circle;
|
|
12
|
+
/** Internally used to order two points lying at the same planar point. */
|
|
13
|
+
order: number;
|
|
14
|
+
/** Internally used to order two points lying at the same planar point. */
|
|
15
|
+
order2: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Primarily for internal use.
|
|
19
|
+
*
|
|
20
|
+
* Compares the two contact points according to their order along the shape
|
|
21
|
+
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
22
|
+
* @param a The first contact point.
|
|
23
|
+
* @param b The second contact point.
|
|
24
|
+
*/
|
|
25
|
+
declare function compareCps(a: ContactPoint, b: ContactPoint): number;
|
|
26
|
+
export { ContactPoint, compareCps };
|
package/node/contact-point.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { comparePoss } from './point-on-shape.js';
|
|
2
|
-
/**
|
|
3
|
-
* Primarily for internal use.
|
|
4
|
-
*
|
|
5
|
-
* Compares the two contact points according to their order along the shape
|
|
6
|
-
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
7
|
-
* @param a The first contact point.
|
|
8
|
-
* @param b The second contact point.
|
|
9
|
-
*/
|
|
10
|
-
function compareCps(a, b) {
|
|
11
|
-
//let res = PointOnShape.compare(a.pointOnShape, b.pointOnShape);
|
|
12
|
-
let res = comparePoss(a.pointOnShape, b.pointOnShape);
|
|
13
|
-
if (res === undefined) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
if (res !== 0) {
|
|
17
|
-
return res;
|
|
18
|
-
}
|
|
19
|
-
res = a.order - b.order;
|
|
20
|
-
if (res !== 0) {
|
|
21
|
-
return res;
|
|
22
|
-
}
|
|
23
|
-
return a.order2 - b.order2;
|
|
24
|
-
}
|
|
25
|
-
export { compareCps };
|
|
1
|
+
import { comparePoss } from './point-on-shape.js';
|
|
2
|
+
/**
|
|
3
|
+
* Primarily for internal use.
|
|
4
|
+
*
|
|
5
|
+
* Compares the two contact points according to their order along the shape
|
|
6
|
+
* boundary. Returns > 0 if a > b, < 0 if a < b or 0 if a === b.
|
|
7
|
+
* @param a The first contact point.
|
|
8
|
+
* @param b The second contact point.
|
|
9
|
+
*/
|
|
10
|
+
function compareCps(a, b) {
|
|
11
|
+
//let res = PointOnShape.compare(a.pointOnShape, b.pointOnShape);
|
|
12
|
+
let res = comparePoss(a.pointOnShape, b.pointOnShape);
|
|
13
|
+
if (res === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (res !== 0) {
|
|
17
|
+
return res;
|
|
18
|
+
}
|
|
19
|
+
res = a.order - b.order;
|
|
20
|
+
if (res !== 0) {
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
return a.order2 - b.order2;
|
|
24
|
+
}
|
|
25
|
+
export { compareCps };
|
|
26
26
|
//# sourceMappingURL=contact-point.js.map
|
package/node/cp-node/clone.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
|
|
4
|
-
* since cloning a single [[CpNode]] necessarily implies cloning all
|
|
5
|
-
* [[CpNode]]s on the same MAT tree.
|
|
6
|
-
*/
|
|
7
|
-
declare function clone(cpNode: CpNode): CpNode;
|
|
8
|
-
export { clone };
|
|
1
|
+
import { CpNode } from "../cp-node.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
|
|
4
|
+
* since cloning a single [[CpNode]] necessarily implies cloning all
|
|
5
|
+
* [[CpNode]]s on the same MAT tree.
|
|
6
|
+
*/
|
|
7
|
+
declare function clone(cpNode: CpNode): CpNode;
|
|
8
|
+
export { clone };
|
package/node/cp-node/clone.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
2
|
-
/** @hidden */
|
|
3
|
-
const EDGES = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
4
|
-
/**
|
|
5
|
-
* Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
|
|
6
|
-
* since cloning a single [[CpNode]] necessarily implies cloning all
|
|
7
|
-
* [[CpNode]]s on the same MAT tree.
|
|
8
|
-
*/
|
|
9
|
-
function clone(cpNode) {
|
|
10
|
-
// Don't change this function to be recursive, the call stack may
|
|
11
|
-
// overflow if there are too many CpNodes.
|
|
12
|
-
const nodeMap = new Map();
|
|
13
|
-
const newCpNode = new CpNode(cpNode.cp, cpNode.isHoleClosing, cpNode.isIntersection);
|
|
14
|
-
nodeMap.set(cpNode, newCpNode);
|
|
15
|
-
const cpStack = [{ cpNode, newCpNode }];
|
|
16
|
-
while (cpStack.length) {
|
|
17
|
-
const { cpNode, newCpNode } = cpStack.pop();
|
|
18
|
-
for (const edge of EDGES) {
|
|
19
|
-
const node = cpNode[edge];
|
|
20
|
-
let newNode = nodeMap.get(node);
|
|
21
|
-
if (!newNode) {
|
|
22
|
-
newNode = new CpNode(node.cp, node.isHoleClosing, node.isIntersection);
|
|
23
|
-
nodeMap.set(node, newNode);
|
|
24
|
-
cpStack.push({ cpNode: node, newCpNode: newNode });
|
|
25
|
-
}
|
|
26
|
-
newCpNode[edge] = newNode;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return newCpNode;
|
|
30
|
-
}
|
|
31
|
-
export { clone };
|
|
1
|
+
import { CpNode } from "../cp-node.js";
|
|
2
|
+
/** @hidden */
|
|
3
|
+
const EDGES = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
4
|
+
/**
|
|
5
|
+
* Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
|
|
6
|
+
* since cloning a single [[CpNode]] necessarily implies cloning all
|
|
7
|
+
* [[CpNode]]s on the same MAT tree.
|
|
8
|
+
*/
|
|
9
|
+
function clone(cpNode) {
|
|
10
|
+
// Don't change this function to be recursive, the call stack may
|
|
11
|
+
// overflow if there are too many CpNodes.
|
|
12
|
+
const nodeMap = new Map();
|
|
13
|
+
const newCpNode = new CpNode(cpNode.cp, cpNode.isHoleClosing, cpNode.isIntersection);
|
|
14
|
+
nodeMap.set(cpNode, newCpNode);
|
|
15
|
+
const cpStack = [{ cpNode, newCpNode }];
|
|
16
|
+
while (cpStack.length) {
|
|
17
|
+
const { cpNode, newCpNode } = cpStack.pop();
|
|
18
|
+
for (const edge of EDGES) {
|
|
19
|
+
const node = cpNode[edge];
|
|
20
|
+
let newNode = nodeMap.get(node);
|
|
21
|
+
if (!newNode) {
|
|
22
|
+
newNode = new CpNode(node.cp, node.isHoleClosing, node.isIntersection);
|
|
23
|
+
nodeMap.set(node, newNode);
|
|
24
|
+
cpStack.push({ cpNode: node, newCpNode: newNode });
|
|
25
|
+
}
|
|
26
|
+
newCpNode[edge] = newNode;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return newCpNode;
|
|
30
|
+
}
|
|
31
|
+
export { clone };
|
|
32
32
|
//# sourceMappingURL=clone.js.map
|
package/node/cp-node/remove.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
-
import { CpNode } from "../cp-node.js";
|
|
3
|
-
/**
|
|
4
|
-
* Removes a cpNode from the MAT.
|
|
5
|
-
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
6
|
-
* @param cpNode The [[CpNode]] to remove.
|
|
7
|
-
*/
|
|
8
|
-
declare function removeCpNode(cpNode: CpNode, cpTree?: LlRbTree<CpNode>): void;
|
|
9
|
-
export { removeCpNode };
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { CpNode } from "../cp-node.js";
|
|
3
|
+
/**
|
|
4
|
+
* Removes a cpNode from the MAT.
|
|
5
|
+
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
6
|
+
* @param cpNode The [[CpNode]] to remove.
|
|
7
|
+
*/
|
|
8
|
+
declare function removeCpNode(cpNode: CpNode, cpTree?: LlRbTree<CpNode>): void;
|
|
9
|
+
export { removeCpNode };
|
package/node/cp-node/remove.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes a cpNode from the MAT.
|
|
3
|
-
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
4
|
-
* @param cpNode The [[CpNode]] to remove.
|
|
5
|
-
*/
|
|
6
|
-
function removeCpNode(cpNode, cpTree) {
|
|
7
|
-
const prev = cpNode.prev;
|
|
8
|
-
const next = cpNode.next;
|
|
9
|
-
prev.next = next;
|
|
10
|
-
next.prev = prev;
|
|
11
|
-
const nextOpposite = next.prevOnCircle;
|
|
12
|
-
const prevOpposite = prev.nextOnCircle;
|
|
13
|
-
nextOpposite.next = prevOpposite;
|
|
14
|
-
prevOpposite.prev = nextOpposite;
|
|
15
|
-
if (cpTree) {
|
|
16
|
-
cpTree.remove(cpNode, false);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export { removeCpNode };
|
|
1
|
+
/**
|
|
2
|
+
* Removes a cpNode from the MAT.
|
|
3
|
+
* @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
|
|
4
|
+
* @param cpNode The [[CpNode]] to remove.
|
|
5
|
+
*/
|
|
6
|
+
function removeCpNode(cpNode, cpTree) {
|
|
7
|
+
const prev = cpNode.prev;
|
|
8
|
+
const next = cpNode.next;
|
|
9
|
+
prev.next = next;
|
|
10
|
+
next.prev = prev;
|
|
11
|
+
const nextOpposite = next.prevOnCircle;
|
|
12
|
+
const prevOpposite = prev.nextOnCircle;
|
|
13
|
+
nextOpposite.next = prevOpposite;
|
|
14
|
+
prevOpposite.prev = nextOpposite;
|
|
15
|
+
if (cpTree) {
|
|
16
|
+
cpTree.remove(cpNode, false);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { removeCpNode };
|
|
20
20
|
//# sourceMappingURL=remove.js.map
|