flo-mat 3.0.9 → 3.0.10
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 +193 -190
- package/browser/index.min.js +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/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/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-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/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/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/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/mat/get-boundary-piece-beziers.js +7 -7
- package/node/mat/get-boundary-piece-beziers.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/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/package.json +5 -5
- 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/get-best-distance-squared.ts +6 -6
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +8 -8
- 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-salience.ts +2 -2
- package/src/cp-node/fs/get-speed.ts +1 -6
- package/src/curve/curve.ts +5 -5
- package/src/debug/functions/draw-elem/two-prong.ts +40 -40
- package/src/debug/functions/two-prong.ts +195 -195
- package/src/debug/two-prong-for-debugging.ts +26 -26
- 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 +8 -8
- 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 +16 -16
- package/src/find-3-prong.ts/find-3-prong.ts +2 -2
- package/src/find-3-prong.ts/get-closest-points.ts +4 -4
- package/src/find-mat/add-2-prongs-by-error.ts +7 -7
- package/src/index.ts +1 -1
- package/src/mat/get-boundary-piece-beziers.ts +7 -7
- package/src/mat/get-two-prong-type.ts +8 -8
- package/src/sat/cull.ts +10 -7
- package/src/sat/to-scale-axis.ts +18 -17
- package/src/utils/bezier-piece-to-bezier.ts +7 -7
- 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
package/browser/index.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/******/ // The require scope
|
|
2
|
-
/******/ var __webpack_require__ = {};
|
|
3
|
-
/******/
|
|
4
|
-
/************************************************************************/
|
|
5
|
-
/******/ /* webpack/runtime/define property getters */
|
|
6
|
-
/******/ (() => {
|
|
7
|
-
/******/ // define getter functions for harmony exports
|
|
8
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
9
|
-
/******/ for(var key in definition) {
|
|
10
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
11
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
12
|
-
/******/ }
|
|
13
|
-
/******/ }
|
|
14
|
-
/******/ };
|
|
15
|
-
/******/ })();
|
|
16
|
-
/******/
|
|
17
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
18
|
-
/******/ (() => {
|
|
19
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
20
|
-
/******/ })();
|
|
21
|
-
/******/
|
|
22
|
-
/************************************************************************/
|
|
23
1
|
|
|
24
2
|
;// ./node_modules/flo-boolean/node/loop/loop-from-beziers.js
|
|
25
3
|
/**
|
|
@@ -3167,7 +3145,7 @@ const cubicDegenPoint = { order: 3, realOrder: 0, collinear: true, nodeType: 'n/
|
|
|
3167
3145
|
* possible planar polynomial bezier curves (of order <= 3) are represented and
|
|
3168
3146
|
* all options are mutually exclusive.
|
|
3169
3147
|
*/
|
|
3170
|
-
const classifications = {
|
|
3148
|
+
const classifications = (/* unused pure expression or super */ null && ({
|
|
3171
3149
|
point,
|
|
3172
3150
|
lineGeneral,
|
|
3173
3151
|
lineDegenPoint,
|
|
@@ -3184,7 +3162,7 @@ const classifications = {
|
|
|
3184
3162
|
cubicDegenCollinearQuad,
|
|
3185
3163
|
cubicDegenLine,
|
|
3186
3164
|
cubicDegenPoint
|
|
3187
|
-
};
|
|
3165
|
+
}));
|
|
3188
3166
|
function classify_isPoint(ps) {
|
|
3189
3167
|
return classify(ps) === point;
|
|
3190
3168
|
}
|
|
@@ -3233,7 +3211,7 @@ function isCubicDegenLine(ps) {
|
|
|
3233
3211
|
function isCubicDegenPoint(ps) {
|
|
3234
3212
|
return classify(ps) === cubicDegenPoint;
|
|
3235
3213
|
}
|
|
3236
|
-
const classification = {
|
|
3214
|
+
const classification = (/* unused pure expression or super */ null && ({
|
|
3237
3215
|
isPoint: classify_isPoint,
|
|
3238
3216
|
isLineGeneral,
|
|
3239
3217
|
isLineDegenPoint,
|
|
@@ -3250,7 +3228,7 @@ const classification = {
|
|
|
3250
3228
|
isCubicDegenCollinearQuad,
|
|
3251
3229
|
isCubicDegenLine,
|
|
3252
3230
|
isCubicDegenPoint,
|
|
3253
|
-
};
|
|
3231
|
+
}));
|
|
3254
3232
|
/**
|
|
3255
3233
|
* Returns a classification of the given bezier curve.
|
|
3256
3234
|
*
|
|
@@ -6454,7 +6432,6 @@ function getRealProngCount(cpNode) {
|
|
|
6454
6432
|
|
|
6455
6433
|
|
|
6456
6434
|
|
|
6457
|
-
const { min, abs: get_speed_abs } = Math;
|
|
6458
6435
|
const getSpeed$ = memoize(getSpeed);
|
|
6459
6436
|
function getSpeed(cpNode) {
|
|
6460
6437
|
if (getRealProngCount(cpNode) !== 2) {
|
|
@@ -6820,79 +6797,109 @@ function getBoundaryBezierPartsToNext(cpNode) {
|
|
|
6820
6797
|
if (curveThis.loop !== curveNext.loop) {
|
|
6821
6798
|
// It is a hole-closer going over to the other loop - a kind of terminal
|
|
6822
6799
|
// CpNode.
|
|
6823
|
-
return undefined;
|
|
6800
|
+
// return undefined;
|
|
6801
|
+
return [];
|
|
6824
6802
|
}
|
|
6825
6803
|
const bezierPieces = [];
|
|
6826
6804
|
if (curveNext === curveThis) {
|
|
6827
|
-
bezierPieces.push({
|
|
6828
|
-
ps: posThis.curve.ps,
|
|
6829
|
-
ts: [posThis.t, posNext.t]
|
|
6830
|
-
});
|
|
6805
|
+
bezierPieces.push({ ps: posThis.curve.ps, ts: [posThis.t, posNext.t] });
|
|
6831
6806
|
}
|
|
6832
6807
|
else {
|
|
6833
|
-
bezierPieces.push({
|
|
6834
|
-
|
|
6835
|
-
ts: [posThis.t, 1]
|
|
6836
|
-
});
|
|
6837
|
-
addSkippedBeziers(bezierPieces, posThis.curve, posNext.curve, posNext.t);
|
|
6808
|
+
bezierPieces.push({ ps: posThis.curve.ps, ts: [posThis.t, 1] });
|
|
6809
|
+
addSkippedBezierPiecess(bezierPieces, posThis.curve, posNext.curve, posNext.t);
|
|
6838
6810
|
}
|
|
6839
6811
|
return bezierPieces;
|
|
6840
6812
|
}
|
|
6841
6813
|
/**
|
|
6842
|
-
* @internal
|
|
6843
6814
|
* Adds pieces of skipped beziers.
|
|
6815
|
+
* @internal
|
|
6844
6816
|
*/
|
|
6845
|
-
function
|
|
6817
|
+
function addSkippedBezierPiecess(bezierPieces, curveStart, curveEnd, t1) {
|
|
6846
6818
|
let curveThis = curveStart;
|
|
6847
6819
|
do {
|
|
6848
6820
|
curveThis = curveThis.next;
|
|
6849
|
-
const
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6821
|
+
const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
6822
|
+
bezierPieces.push({
|
|
6823
|
+
ps: curveThis.ps, ts: [0, tEnd]
|
|
6824
|
+
});
|
|
6853
6825
|
} while (curveThis !== curveEnd);
|
|
6854
6826
|
}
|
|
6855
6827
|
|
|
6856
6828
|
|
|
6857
6829
|
;// ./src/cp-node/fs/get-boundary-beziers-to-next.ts
|
|
6858
6830
|
|
|
6859
|
-
|
|
6860
|
-
const cpThis = cpNode;
|
|
6861
|
-
const cpNext = cpNode.next;
|
|
6862
|
-
const posThis = cpThis.cp.pointOnShape;
|
|
6863
|
-
const posNext = cpNext.cp.pointOnShape;
|
|
6864
|
-
const curveThis = posThis.curve;
|
|
6865
|
-
const curveNext = posNext.curve;
|
|
6866
|
-
if (curveThis.loop !== curveNext.loop) {
|
|
6867
|
-
// It is a hole-closer going over to the other loop - a kind of terminal
|
|
6868
|
-
// CpNode.
|
|
6869
|
-
// return undefined!;
|
|
6870
|
-
return [];
|
|
6871
|
-
}
|
|
6872
|
-
const beziers = [];
|
|
6873
|
-
if (curveNext === curveThis) {
|
|
6874
|
-
beziers.push(fromTo(posThis.curve.ps, posThis.t, posNext.t));
|
|
6875
|
-
}
|
|
6876
|
-
else {
|
|
6877
|
-
beziers.push(fromTo(posThis.curve.ps, posThis.t, 1));
|
|
6878
|
-
get_boundary_beziers_to_next_addSkippedBeziers(beziers, posThis.curve, posNext.curve, posNext.t);
|
|
6879
|
-
}
|
|
6880
|
-
return beziers;
|
|
6881
|
-
}
|
|
6831
|
+
|
|
6882
6832
|
/**
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
fromTo(curveThis.ps, 0, tEnd));
|
|
6894
|
-
} while (curveThis !== curveEnd);
|
|
6833
|
+
// * Returns the boundary beziers between this `CpNode` and the next
|
|
6834
|
+
// * one.
|
|
6835
|
+
// *
|
|
6836
|
+
// * * returns `[]` if the next `CpNode` is on a different loop,
|
|
6837
|
+
// * as this is a hole-closer and there are no boundary beziers between them.
|
|
6838
|
+
// *
|
|
6839
|
+
// * @param cpNode
|
|
6840
|
+
// */
|
|
6841
|
+
function getBoundaryBeziersToNext(cpNode) {
|
|
6842
|
+
return getBoundaryBezierPartsToNext(cpNode).map(bp => fromTo(bp.ps, bp.ts[0], bp.ts[1]));
|
|
6895
6843
|
}
|
|
6844
|
+
// /**
|
|
6845
|
+
// * Returns the boundary beziers between this `CpNode` and the next
|
|
6846
|
+
// * one.
|
|
6847
|
+
// *
|
|
6848
|
+
// * * returns `[]` if the next `CpNode` is on a different loop,
|
|
6849
|
+
// * as this is a hole-closer and there are no boundary beziers between them.
|
|
6850
|
+
// *
|
|
6851
|
+
// * @param cpNode
|
|
6852
|
+
// */
|
|
6853
|
+
// function getBoundaryBeziersToNext(
|
|
6854
|
+
// cpNode: CpNode): number[][][] {
|
|
6855
|
+
// const cpThis = cpNode;
|
|
6856
|
+
// const cpNext = cpNode.next;
|
|
6857
|
+
// const posThis = cpThis.cp.pointOnShape;
|
|
6858
|
+
// const posNext = cpNext.cp.pointOnShape;
|
|
6859
|
+
// const curveThis = posThis.curve;
|
|
6860
|
+
// const curveNext = posNext.curve;
|
|
6861
|
+
// if (curveThis.loop !== curveNext.loop) {
|
|
6862
|
+
// // It is a hole-closer going over to the other loop - a kind of terminal
|
|
6863
|
+
// // CpNode.
|
|
6864
|
+
// // return undefined!;
|
|
6865
|
+
// return [];
|
|
6866
|
+
// }
|
|
6867
|
+
// const beziers: number[][][] = [];
|
|
6868
|
+
// if (curveNext === curveThis) {
|
|
6869
|
+
// beziers.push(
|
|
6870
|
+
// fromTo(posThis.curve.ps, posThis.t, posNext.t)
|
|
6871
|
+
// );
|
|
6872
|
+
// } else {
|
|
6873
|
+
// beziers.push(
|
|
6874
|
+
// fromTo(posThis.curve.ps, posThis.t, 1)
|
|
6875
|
+
// );
|
|
6876
|
+
// addSkippedBeziers(
|
|
6877
|
+
// beziers,
|
|
6878
|
+
// posThis.curve,
|
|
6879
|
+
// posNext.curve,
|
|
6880
|
+
// posNext.t
|
|
6881
|
+
// );
|
|
6882
|
+
// }
|
|
6883
|
+
// return beziers;
|
|
6884
|
+
// }
|
|
6885
|
+
// /**
|
|
6886
|
+
// * Adds pieces of skipped beziers.
|
|
6887
|
+
// * @internal
|
|
6888
|
+
// */
|
|
6889
|
+
// function addSkippedBeziers(
|
|
6890
|
+
// beziers: number[][][],
|
|
6891
|
+
// curveStart: Curve,
|
|
6892
|
+
// curveEnd: Curve,
|
|
6893
|
+
// t1: number) {
|
|
6894
|
+
// let curveThis = curveStart;
|
|
6895
|
+
// do {
|
|
6896
|
+
// curveThis = curveThis.next;
|
|
6897
|
+
// const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
6898
|
+
// beziers.push(
|
|
6899
|
+
// fromTo(curveThis.ps, 0, tEnd)
|
|
6900
|
+
// );
|
|
6901
|
+
// } while (curveThis !== curveEnd);
|
|
6902
|
+
// }
|
|
6896
6903
|
|
|
6897
6904
|
|
|
6898
6905
|
;// ./src/cp-node/fs/remove-cp-node.ts
|
|
@@ -7039,13 +7046,6 @@ function getBranchBeziers(cpNode) {
|
|
|
7039
7046
|
}
|
|
7040
7047
|
|
|
7041
7048
|
|
|
7042
|
-
;// ./src/cp-node/fs/cp-nodes-to-boundary-beziers.ts
|
|
7043
|
-
|
|
7044
|
-
function cpNodesToBoundaryBeziers(cpNodes) {
|
|
7045
|
-
return cpNodes.flatMap(getBoundaryBeziersToNext);
|
|
7046
|
-
}
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
7049
|
;// ./src/cp-node/fs/get-all-between.ts
|
|
7050
7050
|
/**
|
|
7051
7051
|
* Returns all `CpNode`s between the two given ones (excluding the last one).
|
|
@@ -7093,11 +7093,9 @@ function getAllBetween(cpNodeS, cpNodeE, inclAllIfEqual = true) {
|
|
|
7093
7093
|
* include all `CpNode`s around the loop, otherwise include none.
|
|
7094
7094
|
*/
|
|
7095
7095
|
function getBoundaryBeziersBetween(cpNode1, cpNode2, inclAllIfEqual = true) {
|
|
7096
|
-
const
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
hasHoleCloser: allBetween.hasHoleCloser
|
|
7100
|
-
};
|
|
7096
|
+
const { cpNodes, hasHoleCloser } = getAllBetween(cpNode1, cpNode2, inclAllIfEqual);
|
|
7097
|
+
const pss = cpNodes.flatMap(getBoundaryBeziersToNext);
|
|
7098
|
+
return { pss, hasHoleCloser };
|
|
7101
7099
|
}
|
|
7102
7100
|
|
|
7103
7101
|
|
|
@@ -7126,8 +7124,8 @@ function getSalience(cpNode) {
|
|
|
7126
7124
|
const bp1 = cpNode1.cp.pointOnShape.p;
|
|
7127
7125
|
const bp2 = cpNode2.cp.pointOnShape.p;
|
|
7128
7126
|
const d = distanceBetween(bp1, bp2);
|
|
7129
|
-
const { pss
|
|
7130
|
-
const s = sum(
|
|
7127
|
+
const { pss, hasHoleCloser } = getBoundaryBeziersBetween(cpNode1, cpNode2);
|
|
7128
|
+
const s = sum(pss.map(ps => totalLength(ps)));
|
|
7131
7129
|
return hasHoleCloser ? Number.POSITIVE_INFINITY : s / d;
|
|
7132
7130
|
}
|
|
7133
7131
|
|
|
@@ -8263,7 +8261,7 @@ const all_roots_certified_eEstimate = eEstimate;
|
|
|
8263
8261
|
const all_roots_certified_hornerWithRunningError = hornerWithRunningError;
|
|
8264
8262
|
const all_roots_certified_eSign = eSign;
|
|
8265
8263
|
const all_roots_certified_max = Math.max;
|
|
8266
|
-
const
|
|
8264
|
+
const min = Math.min;
|
|
8267
8265
|
const all_roots_certified_abs = Math.abs;
|
|
8268
8266
|
const all_roots_certified_eps = Number.EPSILON;
|
|
8269
8267
|
const onePlusEps = 1 + all_roots_certified_eps;
|
|
@@ -8639,7 +8637,7 @@ function allRootsCertified(p, lb = 0, ub = 1, pE, getPExact, returnUndefinedForZ
|
|
|
8639
8637
|
mult *= d * onePlusEps;
|
|
8640
8638
|
}
|
|
8641
8639
|
// maxDdP is now calculated
|
|
8642
|
-
const AMinMax = A_ > 0 ?
|
|
8640
|
+
const AMinMax = A_ > 0 ? min(_A, A_) : all_roots_certified_max(_A, A_);
|
|
8643
8641
|
const δ = 2 * Number.EPSILON * all_roots_certified_max(1, all_roots_certified_abs(a_));
|
|
8644
8642
|
const dMax = maxDdP * (2 * δ); // since the first derivative === 0 somewhere in [_a,a_]
|
|
8645
8643
|
const yShift = A_ > 0 ? -dMax * 2 * δ : dMax * 2 * δ;
|
|
@@ -25567,8 +25565,9 @@ const DualSetFs = { has, add: dual_set_add, remove };
|
|
|
25567
25565
|
|
|
25568
25566
|
const { isOnSameCircle: cull_isOnSameCircle } = CpNodeFs;
|
|
25569
25567
|
/**
|
|
25568
|
+
* Returns the set of non-trivial forward edges starting from the given `CpNode`.
|
|
25570
25569
|
*
|
|
25571
|
-
* @param cpStart
|
|
25570
|
+
* @param cpStart the start `CpNode`
|
|
25572
25571
|
*/
|
|
25573
25572
|
function getNonTrivialForwardEdges(cpStart) {
|
|
25574
25573
|
let cpNode = cpStart;
|
|
@@ -25586,12 +25585,14 @@ function getNonTrivialForwardEdges(cpStart) {
|
|
|
25586
25585
|
return cps;
|
|
25587
25586
|
}
|
|
25588
25587
|
/**
|
|
25589
|
-
* @internal
|
|
25590
25588
|
* Returns the set of Vertices passing the following test: walk the MAT tree and
|
|
25591
25589
|
* keep all Vertices not in the current cull set and any Vertices that have a
|
|
25592
25590
|
* non-culled node further down the line toward the tree leaves.
|
|
25593
|
-
*
|
|
25594
|
-
* @param
|
|
25591
|
+
*
|
|
25592
|
+
* @param culls the `CpNode`s (referred to by circles) that should be culled
|
|
25593
|
+
* @param maxCpNode the start `CpNode` which must represent the maximal vertex
|
|
25594
|
+
*
|
|
25595
|
+
* @internal
|
|
25595
25596
|
*/
|
|
25596
25597
|
function cull(culls, maxCpNode) {
|
|
25597
25598
|
const leaves = getLeaves(maxCpNode);
|
|
@@ -25741,8 +25742,9 @@ function getSatCulls(cpNode, s) {
|
|
|
25741
25742
|
* boundary of the shape. The SAT is a simplification of the MAT that preserves
|
|
25742
25743
|
* less detail the higher the applied scale factor. The severity at which noise
|
|
25743
25744
|
* are removed depends on the local scale of the shape.
|
|
25744
|
-
*
|
|
25745
|
-
* @param
|
|
25745
|
+
*
|
|
25746
|
+
* @param mat the Medial Axis Transform (MAT) on which to apply the SAT
|
|
25747
|
+
* @param s the scale factor >= 1 (e.g. 1.3)
|
|
25746
25748
|
*/
|
|
25747
25749
|
function toScaleAxis(mat, s) {
|
|
25748
25750
|
let timingStart = 0;
|
|
@@ -26254,13 +26256,13 @@ function getPotentialClosestPointsOnCurveCertified(pow, curve, x, tRange = [0, 1
|
|
|
26254
26256
|
* Finds an initial distance such that the closest point can not be further than
|
|
26255
26257
|
* this distance away.
|
|
26256
26258
|
*/
|
|
26257
|
-
function getBestDistanceSquared(
|
|
26259
|
+
function getBestDistanceSquared(curvePieces, p) {
|
|
26258
26260
|
let bestSquaredDistance = Number.POSITIVE_INFINITY;
|
|
26259
|
-
for (let i = 0; i <
|
|
26260
|
-
const
|
|
26261
|
-
const ps =
|
|
26262
|
-
const p1 = evalDeCasteljau(ps,
|
|
26263
|
-
const p2 = evalDeCasteljau(ps,
|
|
26261
|
+
for (let i = 0; i < curvePieces.length; i++) {
|
|
26262
|
+
const curvePiece = curvePieces[i];
|
|
26263
|
+
const ps = curvePiece.curve.ps;
|
|
26264
|
+
const p1 = evalDeCasteljau(ps, curvePiece.ts[0]);
|
|
26265
|
+
const p2 = evalDeCasteljau(ps, curvePiece.ts[1]);
|
|
26264
26266
|
const d = Math.min(squaredDistanceBetween(p, p1), squaredDistanceBetween(p, p2));
|
|
26265
26267
|
if (d < bestSquaredDistance) {
|
|
26266
26268
|
bestSquaredDistance = d;
|
|
@@ -26335,22 +26337,22 @@ const get_bounding_box_getBoundingBox$ = memoize(getBoundingBox);
|
|
|
26335
26337
|
* @internal
|
|
26336
26338
|
* When checking distances, ignore all those with closest possible distance
|
|
26337
26339
|
* further than 'bestSquaredDistance', i.e. cull them.
|
|
26338
|
-
* @param
|
|
26340
|
+
* @param curvePieces
|
|
26339
26341
|
* @param p
|
|
26340
26342
|
* @param dSquared
|
|
26341
26343
|
*/
|
|
26342
|
-
function cullByLooseBoundingBox(
|
|
26343
|
-
const
|
|
26344
|
-
for (let i = 0; i <
|
|
26345
|
-
const
|
|
26346
|
-
const ps =
|
|
26344
|
+
function cullByLooseBoundingBox(curvePieces, p, dSquared) {
|
|
26345
|
+
const candidateCurvePieces = [];
|
|
26346
|
+
for (let i = 0; i < curvePieces.length; i++) {
|
|
26347
|
+
const curvePiece = curvePieces[i];
|
|
26348
|
+
const ps = curvePiece.curve.ps;
|
|
26347
26349
|
const boundingBox = get_bounding_box_getBoundingBox$(ps);
|
|
26348
26350
|
const d = getClosestSquareDistanceToRect(boundingBox, p);
|
|
26349
26351
|
if (d <= dSquared) {
|
|
26350
|
-
|
|
26352
|
+
candidateCurvePieces.push(curvePiece);
|
|
26351
26353
|
}
|
|
26352
26354
|
}
|
|
26353
|
-
return
|
|
26355
|
+
return candidateCurvePieces;
|
|
26354
26356
|
}
|
|
26355
26357
|
|
|
26356
26358
|
|
|
@@ -26402,22 +26404,22 @@ const getBoundingBoxTight_ = memoize(getBoundingBoxTight);
|
|
|
26402
26404
|
* @internal
|
|
26403
26405
|
* When checking distances, ignore all those with closest possible distance
|
|
26404
26406
|
* further than 'bestSquaredDistance', i.e. cull them.
|
|
26405
|
-
* @param
|
|
26407
|
+
* @param curvePieces
|
|
26406
26408
|
* @param p
|
|
26407
26409
|
* @param bestSquaredDistance
|
|
26408
26410
|
*/
|
|
26409
|
-
function cullByTightBoundingBox(
|
|
26410
|
-
const
|
|
26411
|
-
for (let i = 0; i <
|
|
26412
|
-
const
|
|
26413
|
-
const ps =
|
|
26411
|
+
function cullByTightBoundingBox(curvePieces, p, bestSquaredDistance) {
|
|
26412
|
+
const candidateCurvePieces = [];
|
|
26413
|
+
for (let i = 0; i < curvePieces.length; i++) {
|
|
26414
|
+
const curvePiece = curvePieces[i];
|
|
26415
|
+
const ps = curvePiece.curve.ps;
|
|
26414
26416
|
const tightBoundingBox = getBoundingBoxTight_(ps);
|
|
26415
26417
|
const d = getClosestSquaredDistanceToRotatedRect(tightBoundingBox, p);
|
|
26416
26418
|
if (d <= bestSquaredDistance) {
|
|
26417
|
-
|
|
26419
|
+
candidateCurvePieces.push(curvePiece);
|
|
26418
26420
|
}
|
|
26419
26421
|
}
|
|
26420
|
-
return
|
|
26422
|
+
return candidateCurvePieces;
|
|
26421
26423
|
}
|
|
26422
26424
|
|
|
26423
26425
|
|
|
@@ -26426,16 +26428,17 @@ function cullByTightBoundingBox(bezierPieces, p, bestSquaredDistance) {
|
|
|
26426
26428
|
|
|
26427
26429
|
|
|
26428
26430
|
/**
|
|
26429
|
-
* @
|
|
26430
|
-
* @param bezierPieces
|
|
26431
|
+
* @param curvePieces
|
|
26431
26432
|
* @param p
|
|
26432
26433
|
* @param extreme
|
|
26434
|
+
*
|
|
26435
|
+
* @internal
|
|
26433
26436
|
*/
|
|
26434
|
-
function
|
|
26435
|
-
const bestSquaredDistance = getBestDistanceSquared(
|
|
26436
|
-
|
|
26437
|
-
|
|
26438
|
-
return
|
|
26437
|
+
function cullCurvePieces1(curvePieces, p) {
|
|
26438
|
+
const bestSquaredDistance = getBestDistanceSquared(curvePieces, p);
|
|
26439
|
+
curvePieces = cullByLooseBoundingBox(curvePieces, p, bestSquaredDistance);
|
|
26440
|
+
curvePieces = cullByTightBoundingBox(curvePieces, p, bestSquaredDistance);
|
|
26441
|
+
return curvePieces;
|
|
26439
26442
|
}
|
|
26440
26443
|
|
|
26441
26444
|
|
|
@@ -26449,19 +26452,19 @@ function cullBezierPieces1(bezierPieces, p) {
|
|
|
26449
26452
|
* bezier pieces, including the beziers actually checked after culling.
|
|
26450
26453
|
*
|
|
26451
26454
|
* @param pow
|
|
26452
|
-
* @param
|
|
26455
|
+
* @param curvePieces
|
|
26453
26456
|
* @param x
|
|
26454
26457
|
* @param touchedCurve
|
|
26455
26458
|
* @param t
|
|
26456
26459
|
* @param for1Prong defaults to `false`;
|
|
26457
26460
|
* @param angle defaults to `0`
|
|
26458
26461
|
*/
|
|
26459
|
-
function getCloseBoundaryPointsCertified(pow,
|
|
26460
|
-
|
|
26462
|
+
function getCloseBoundaryPointsCertified(pow, curvePieces, x, touchedCurve = undefined, t = undefined, for1Prong = false, angle = 0) {
|
|
26463
|
+
curvePieces = cullCurvePieces1(curvePieces, x);
|
|
26461
26464
|
const pInfoss = [];
|
|
26462
|
-
for (let i = 0; i <
|
|
26463
|
-
const
|
|
26464
|
-
const pInfos = getPotentialClosestPointsOnCurveCertified(pow,
|
|
26465
|
+
for (let i = 0; i < curvePieces.length; i++) {
|
|
26466
|
+
const curvePiece = curvePieces[i];
|
|
26467
|
+
const pInfos = getPotentialClosestPointsOnCurveCertified(pow, curvePiece.curve, x, curvePiece.ts, touchedCurve, t, for1Prong, angle);
|
|
26465
26468
|
pInfoss.push(...pInfos);
|
|
26466
26469
|
}
|
|
26467
26470
|
/** the minimum max interval value */
|
|
@@ -26494,14 +26497,14 @@ const { max: calc_initial_3_prong_center_max, ceil, log2 } = Math;
|
|
|
26494
26497
|
* must be within the shape.
|
|
26495
26498
|
* @param δ3s - The three boundary pieces of which we need to find the three
|
|
26496
26499
|
* 3-prong points.
|
|
26497
|
-
* @param
|
|
26500
|
+
* @param curvePiece3s
|
|
26498
26501
|
* @param extreme
|
|
26499
26502
|
*/
|
|
26500
|
-
function calcInitial3ProngCenter(maxCoordinate, δ3s,
|
|
26503
|
+
function calcInitial3ProngCenter(maxCoordinate, δ3s, curvePiece3s) {
|
|
26501
26504
|
const circle = δ3s[0][0].cp.circle;
|
|
26502
26505
|
const twoProngCircleCenter = circle.center;
|
|
26503
26506
|
const pow = calc_initial_3_prong_center_max(0, ceil(log2(maxCoordinate / circle.radius))) + 1; // determines accuracy;
|
|
26504
|
-
const pos = getCloseBoundaryPointsCertified(pow,
|
|
26507
|
+
const pos = getCloseBoundaryPointsCertified(pow, curvePiece3s[1], twoProngCircleCenter)[0];
|
|
26505
26508
|
const meanPoints = [
|
|
26506
26509
|
δ3s[0][0].cp.pointOnShape.p,
|
|
26507
26510
|
pos.p,
|
|
@@ -26516,13 +26519,13 @@ function calcInitial3ProngCenter(maxCoordinate, δ3s, bezierPiece3s) {
|
|
|
26516
26519
|
/**
|
|
26517
26520
|
* @internal
|
|
26518
26521
|
* @param x
|
|
26519
|
-
* @param
|
|
26522
|
+
* @param curvePiece3s
|
|
26520
26523
|
* @param extreme
|
|
26521
26524
|
*/
|
|
26522
|
-
function getClosestPoints(x,
|
|
26523
|
-
return
|
|
26525
|
+
function getClosestPoints(x, curvePiece3s) {
|
|
26526
|
+
return curvePiece3s.map(curvePieces => {
|
|
26524
26527
|
return getCloseBoundaryPointsCertified(5, // TODO - see find-2-prong
|
|
26525
|
-
|
|
26528
|
+
curvePieces, x)[0];
|
|
26526
26529
|
});
|
|
26527
26530
|
}
|
|
26528
26531
|
|
|
@@ -26546,13 +26549,13 @@ function scale(p, c) {
|
|
|
26546
26549
|
* Find new x and ps that are a better estimate of the 3-prong circle.
|
|
26547
26550
|
* The potential function, V, is defined as the distance to the actual 3 prong
|
|
26548
26551
|
* circle center.
|
|
26549
|
-
* @param
|
|
26552
|
+
* @param curvePiece3s The three boundary pieces, each of which should contain
|
|
26550
26553
|
* a point of the 3-prong to be found.
|
|
26551
26554
|
* @param x The currently best guess at the center of the 3-prong circle.
|
|
26552
26555
|
* @param vectorToZeroV
|
|
26553
26556
|
* @param extreme
|
|
26554
26557
|
*/
|
|
26555
|
-
function calcBetterX(
|
|
26558
|
+
function calcBetterX(curvePiece3s, x, vectorToZeroV) {
|
|
26556
26559
|
const V = len(vectorToZeroV);
|
|
26557
26560
|
let nu = 1;
|
|
26558
26561
|
let better;
|
|
@@ -26563,7 +26566,7 @@ function calcBetterX(bezierPiece3s, x, vectorToZeroV) {
|
|
|
26563
26566
|
do {
|
|
26564
26567
|
const shift = scale(vectorToZeroV, nu);
|
|
26565
26568
|
newX = translate(shift, x);
|
|
26566
|
-
newPoss = getClosestPoints(newX,
|
|
26569
|
+
newPoss = getClosestPoints(newX, curvePiece3s);
|
|
26567
26570
|
// Point of zero V
|
|
26568
26571
|
const newCircleCenter = circumCenter(newPoss.map(pos => pos.p));
|
|
26569
26572
|
const newVectorToZeroV = from_to_fromTo(newX, newCircleCenter);
|
|
@@ -26595,11 +26598,11 @@ const calcVectorToZeroV_StraightToIt = from_to_fromTo;
|
|
|
26595
26598
|
* Finds a 3-prong using only the 3 given δs.
|
|
26596
26599
|
* @param δs The boundary pieces
|
|
26597
26600
|
* @param idx δ identifier
|
|
26598
|
-
* @param
|
|
26601
|
+
* @param curvePiecess
|
|
26599
26602
|
* @param maxCoordinate The maximum coordinate value used to calculate floating point
|
|
26600
26603
|
* tolerances.
|
|
26601
26604
|
*/
|
|
26602
|
-
function find3ProngForDelta3s(δs, idx, k,
|
|
26605
|
+
function find3ProngForDelta3s(δs, idx, k, curvePiecess, maxCoordinate) {
|
|
26603
26606
|
const TOLERANCE = 2 ** -32 * maxCoordinate;
|
|
26604
26607
|
const MAX_ITERATIONS = 10;
|
|
26605
26608
|
const δs_ = [
|
|
@@ -26607,34 +26610,34 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
|
|
|
26607
26610
|
δs[idx],
|
|
26608
26611
|
δs[δs.length - 1]
|
|
26609
26612
|
];
|
|
26610
|
-
const
|
|
26611
|
-
|
|
26612
|
-
|
|
26613
|
-
|
|
26613
|
+
const curvePieces_ = [
|
|
26614
|
+
curvePiecess[0],
|
|
26615
|
+
curvePiecess[idx],
|
|
26616
|
+
curvePiecess[δs.length - 1]
|
|
26614
26617
|
];
|
|
26615
26618
|
const δ3ss = [
|
|
26616
26619
|
[δs_[0], δs_[1], δs_[2]],
|
|
26617
26620
|
[δs_[1], δs_[2], δs_[0]],
|
|
26618
26621
|
[δs_[2], δs_[0], δs_[1]],
|
|
26619
26622
|
];
|
|
26620
|
-
const
|
|
26621
|
-
[
|
|
26622
|
-
[
|
|
26623
|
-
[
|
|
26623
|
+
const curvePiecess_ = [
|
|
26624
|
+
[curvePieces_[0], curvePieces_[1], curvePieces_[2]],
|
|
26625
|
+
[curvePieces_[1], curvePieces_[2], curvePieces_[0]],
|
|
26626
|
+
[curvePieces_[2], curvePieces_[0], curvePieces_[1]],
|
|
26624
26627
|
];
|
|
26625
26628
|
const δ3s = δ3ss[k];
|
|
26626
|
-
const
|
|
26629
|
+
const curvePiece3s = curvePiecess_[k];
|
|
26627
26630
|
if (find_3_prong_for_delta3s_isSharp(δ3s[0][0])) {
|
|
26628
26631
|
return undefined;
|
|
26629
26632
|
}
|
|
26630
26633
|
let poss = undefined;
|
|
26631
26634
|
let circumCenter_;
|
|
26632
26635
|
let j = 0; // Safeguard for slow convergence
|
|
26633
|
-
let x = calcInitial3ProngCenter(maxCoordinate, δ3s,
|
|
26636
|
+
let x = calcInitial3ProngCenter(maxCoordinate, δ3s, curvePiece3s);
|
|
26634
26637
|
let tolerance = Number.POSITIVE_INFINITY;
|
|
26635
26638
|
while (tolerance > TOLERANCE && j < MAX_ITERATIONS) {
|
|
26636
26639
|
j++;
|
|
26637
|
-
poss = getClosestPoints(x,
|
|
26640
|
+
poss = getClosestPoints(x, curvePiece3s);
|
|
26638
26641
|
if (!Number.isFinite(x[0]) || !Number.isFinite(x[1])) {
|
|
26639
26642
|
// TODO - the code can be cleaned up and sped up a lot if we don't
|
|
26640
26643
|
// use this function as is but instead use δs[0] and δs[2] as is
|
|
@@ -26651,7 +26654,7 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
|
|
|
26651
26654
|
// loop. This check, for instance, would be eliminated completely.
|
|
26652
26655
|
return undefined;
|
|
26653
26656
|
}
|
|
26654
|
-
const upds = calcBetterX(
|
|
26657
|
+
const upds = calcBetterX(curvePiece3s, x, vectorToZeroV);
|
|
26655
26658
|
x = upds.newX;
|
|
26656
26659
|
poss = upds.newPoss;
|
|
26657
26660
|
const V = len(vectorToZeroV); // The 'potential'
|
|
@@ -26712,9 +26715,9 @@ function find3ProngForDelta3s(δs, idx, k, bezierPiecess, maxCoordinate) {
|
|
|
26712
26715
|
// candidate for the 3-prong.
|
|
26713
26716
|
//-------------------------------------------------------------------------
|
|
26714
26717
|
const closestDs = [];
|
|
26715
|
-
for (let i = 0; i <
|
|
26718
|
+
for (let i = 0; i < curvePiecess.length; i++) {
|
|
26716
26719
|
const p = getCloseBoundaryPointsCertified(5, // TODO - see find-2-prong
|
|
26717
|
-
|
|
26720
|
+
curvePiecess[i], x)[0];
|
|
26718
26721
|
closestDs.push(distanceBetween(p.p, x));
|
|
26719
26722
|
}
|
|
26720
26723
|
const closestD = Math.min(...closestDs);
|
|
@@ -26756,7 +26759,7 @@ const isPosQuiteSharpCorner = memoize((pos) => {
|
|
|
26756
26759
|
function getBoundaryPieceBeziers(cpNodes) {
|
|
26757
26760
|
let cpThis = cpNodes[0];
|
|
26758
26761
|
const cpEnd = cpNodes[1];
|
|
26759
|
-
const
|
|
26762
|
+
const curvePieces = [];
|
|
26760
26763
|
// As opposed to going around the circle and taking the last exit
|
|
26761
26764
|
let goStraight = true;
|
|
26762
26765
|
do {
|
|
@@ -26775,28 +26778,28 @@ function getBoundaryPieceBeziers(cpNodes) {
|
|
|
26775
26778
|
}
|
|
26776
26779
|
else if (posNext.curve === posThis.curve &&
|
|
26777
26780
|
compareCps(cpThis.next.cp, cpThis.cp) > 0) {
|
|
26778
|
-
|
|
26781
|
+
curvePieces.push({ curve: posThis.curve, ts: [posThis.t, posNext.t] });
|
|
26779
26782
|
}
|
|
26780
26783
|
else {
|
|
26781
|
-
|
|
26784
|
+
curvePieces.push({ curve: posThis.curve, ts: [posThis.t, 1] });
|
|
26782
26785
|
if (posThis.curve.loop === posNext.curve.loop) {
|
|
26783
|
-
|
|
26786
|
+
addSkippedBeziers(curvePieces, posThis.curve, posNext.curve, posNext.t);
|
|
26784
26787
|
}
|
|
26785
26788
|
}
|
|
26786
26789
|
cpThis = cpThis.next;
|
|
26787
26790
|
} while (cpThis !== cpEnd);
|
|
26788
|
-
return
|
|
26791
|
+
return curvePieces;
|
|
26789
26792
|
}
|
|
26790
26793
|
/**
|
|
26791
26794
|
* @internal
|
|
26792
26795
|
* Adds pieces of skipped beziers
|
|
26793
26796
|
*/
|
|
26794
|
-
function
|
|
26797
|
+
function addSkippedBeziers(curvePieces, curveStart, curveEnd, t1) {
|
|
26795
26798
|
let curveThis = curveStart;
|
|
26796
26799
|
do {
|
|
26797
26800
|
curveThis = curveThis.next;
|
|
26798
26801
|
const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
26799
|
-
|
|
26802
|
+
curvePieces.push({ curve: curveThis, ts: [0, tEnd] });
|
|
26800
26803
|
} while (curveThis !== curveEnd);
|
|
26801
26804
|
}
|
|
26802
26805
|
|
|
@@ -26812,13 +26815,13 @@ function get_boundary_piece_beziers_addSkippedBeziers(bezierPieces, curveStart,
|
|
|
26812
26815
|
* tolerances.
|
|
26813
26816
|
*/
|
|
26814
26817
|
function find3Prong(δs, extreme) {
|
|
26815
|
-
const
|
|
26818
|
+
const curvePiecess = δs.map(getBoundaryPieceBeziers);
|
|
26816
26819
|
// The best candidate amongst the different 'permutations' of the given δs.
|
|
26817
26820
|
let threeProng;
|
|
26818
26821
|
let smallestError = Number.POSITIVE_INFINITY;
|
|
26819
26822
|
for (let i = 1; i < δs.length - 1; i++) {
|
|
26820
26823
|
for (let k = 0; k < 3; k++) {
|
|
26821
|
-
const threeProngInfo = find3ProngForDelta3s(δs, i, k,
|
|
26824
|
+
const threeProngInfo = find3ProngForDelta3s(δs, i, k, curvePiecess, extreme);
|
|
26822
26825
|
if (!threeProngInfo) {
|
|
26823
26826
|
continue;
|
|
26824
26827
|
}
|
|
@@ -27801,7 +27804,7 @@ function findEquidistantPointOnLineDd(x, y, z) {
|
|
|
27801
27804
|
|
|
27802
27805
|
|
|
27803
27806
|
/** @internal */
|
|
27804
|
-
function
|
|
27807
|
+
function getInitialCurvePieces(angle, isHoleClosing, loop, loops,
|
|
27805
27808
|
// cpTrees: Map<Loop,LlRbTree<CpNode>>,
|
|
27806
27809
|
meta, y, circle) {
|
|
27807
27810
|
const { cpTrees } = meta;
|
|
@@ -27838,16 +27841,16 @@ meta, y, circle) {
|
|
|
27838
27841
|
*
|
|
27839
27842
|
* Reduces the circle radius initially as an optimization step.
|
|
27840
27843
|
*/
|
|
27841
|
-
function reduceRadius(extreme,
|
|
27844
|
+
function reduceRadius(extreme, curvePieces, p, x) {
|
|
27842
27845
|
const TOLERANCE = 1 + 2 ** -10;
|
|
27843
27846
|
let minRadius = Number.POSITIVE_INFINITY;
|
|
27844
|
-
for (let i = 0; i <
|
|
27845
|
-
const
|
|
27846
|
-
const ps =
|
|
27847
|
+
for (let i = 0; i < curvePieces.length; i++) {
|
|
27848
|
+
const curvePiece = curvePieces[i];
|
|
27849
|
+
const ps = curvePiece.curve.ps;
|
|
27847
27850
|
// let min = Number.POSITIVE_INFINITY;
|
|
27848
27851
|
const num = 2;
|
|
27849
27852
|
for (let j = 0; j < (num + 1); j++) {
|
|
27850
|
-
const p_ = evalDeCasteljau(ps,
|
|
27853
|
+
const p_ = evalDeCasteljau(ps, curvePiece.ts[j / num]);
|
|
27851
27854
|
const cc = getCircleCenterFrom2PointsAndNormal(extreme, p, x, p_);
|
|
27852
27855
|
if (cc) {
|
|
27853
27856
|
let r = squaredDistanceBetween(p, cc);
|
|
@@ -27917,24 +27920,24 @@ function squaredDistanceBetweenDd(x, y) {
|
|
|
27917
27920
|
|
|
27918
27921
|
/**
|
|
27919
27922
|
* @internal
|
|
27920
|
-
* Cull all
|
|
27923
|
+
* Cull all curvePieces not within given radius of a given point.
|
|
27921
27924
|
* @param extreme
|
|
27922
|
-
* @param
|
|
27925
|
+
* @param curvePieces
|
|
27923
27926
|
* @param p
|
|
27924
27927
|
* @param rSquared
|
|
27925
27928
|
*/
|
|
27926
|
-
function
|
|
27929
|
+
function cullCurvePieces2(curvePieces, p, rSquared) {
|
|
27927
27930
|
const TOLERANCE = 1 + 2 ** -10;
|
|
27928
|
-
if (
|
|
27929
|
-
return
|
|
27931
|
+
if (curvePieces.length <= 1) {
|
|
27932
|
+
return curvePieces;
|
|
27930
27933
|
}
|
|
27931
27934
|
const newPieces = [];
|
|
27932
|
-
for (const
|
|
27933
|
-
const ps =
|
|
27935
|
+
for (const curvePiece of curvePieces) {
|
|
27936
|
+
const ps = curvePiece.curve.ps;
|
|
27934
27937
|
const rect = get_bounding_box_getBoundingBox$(ps);
|
|
27935
27938
|
const bd = getClosestSquareDistanceToRect(rect, p);
|
|
27936
27939
|
if (bd <= TOLERANCE * rSquared) {
|
|
27937
|
-
newPieces.push(
|
|
27940
|
+
newPieces.push(curvePiece);
|
|
27938
27941
|
}
|
|
27939
27942
|
}
|
|
27940
27943
|
return newPieces;
|
|
@@ -28138,12 +28141,12 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
|
|
|
28138
28141
|
const p = y.p;
|
|
28139
28142
|
// The boundary piece that should contain the other point of
|
|
28140
28143
|
// the 2-prong circle. (Defined by start and end points).
|
|
28141
|
-
let
|
|
28142
|
-
// console.log(
|
|
28144
|
+
let curvePieces = getInitialCurvePieces(angle, isHoleClosing, loop, loops, meta, y, { center: xO, radius: rO });
|
|
28145
|
+
// console.log(curvePieces.length);
|
|
28143
28146
|
/** The center of the two-prong (successively refined) */
|
|
28144
28147
|
let x = xO;
|
|
28145
28148
|
// The lines below is an optimization.
|
|
28146
|
-
const r_ = find_2_prong_sqrt(reduceRadius(maxCoordinate,
|
|
28149
|
+
const r_ = find_2_prong_sqrt(reduceRadius(maxCoordinate, curvePieces, p, xO));
|
|
28147
28150
|
if (rO > r_) {
|
|
28148
28151
|
x = interpolate(p, xO, r_ / rO);
|
|
28149
28152
|
}
|
|
@@ -28154,11 +28157,11 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
|
|
|
28154
28157
|
while (i < MAX_ITERATIONS) {
|
|
28155
28158
|
const xy = squaredDistanceBetweenDd(x, y.p);
|
|
28156
28159
|
if (i < 2) {
|
|
28157
|
-
|
|
28160
|
+
curvePieces = cullCurvePieces2(curvePieces, x, xy);
|
|
28158
28161
|
}
|
|
28159
28162
|
const pow = find_2_prong_max(0, find_2_prong_ceil(find_2_prong_log2(maxCoordinate / xy))) + 1; // determines accuracy
|
|
28160
28163
|
// console.log(pow);
|
|
28161
|
-
const _zs = getCloseBoundaryPointsCertified(pow,
|
|
28164
|
+
const _zs = getCloseBoundaryPointsCertified(pow, curvePieces, x, y.curve, y.t, for1Prong && i == 0 && rO !== 1 / minCurvature, angle).map(info => createPos(info.curve, info.t, false));
|
|
28162
28165
|
let maxD = Number.NEGATIVE_INFINITY;
|
|
28163
28166
|
let maxPos = undefined;
|
|
28164
28167
|
zs = [];
|
|
@@ -28216,7 +28219,7 @@ function find2Prong(meta, isHoleClosing, for1Prong, angle, y) {
|
|
|
28216
28219
|
}
|
|
28217
28220
|
}
|
|
28218
28221
|
const circle = { center: x, radius: distanceBetween(x, z.p) };
|
|
28219
|
-
// if (typeof _debug_ !== 'undefined') { addDebugInfo(
|
|
28222
|
+
// if (typeof _debug_ !== 'undefined') { addDebugInfo(curvePieces, false, x, y, z, circle!, δ!, xs, isHoleClosing); }
|
|
28220
28223
|
// return { circle, zs };
|
|
28221
28224
|
// zs = zs.filter(z => z !== undefined)
|
|
28222
28225
|
return { circle, zs: [z] };
|