flo-mat 3.0.7 → 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.
Files changed (117) hide show
  1. package/browser/index.js +215 -208
  2. package/browser/index.min.js +1 -1
  3. package/node/closest-boundary-point/cull-bezier-pieces.d.ts +5 -4
  4. package/node/closest-boundary-point/cull-bezier-pieces.js +9 -8
  5. package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
  6. package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +2 -2
  7. package/node/closest-boundary-point/cull-by-loose-bounding-box.js +8 -8
  8. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
  9. package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +2 -2
  10. package/node/closest-boundary-point/cull-by-tight-boundary-box.js +8 -8
  11. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
  12. package/node/closest-boundary-point/get-best-distance-squared.d.ts +1 -1
  13. package/node/closest-boundary-point/get-best-distance-squared.js +6 -6
  14. package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -1
  15. package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +2 -2
  16. package/node/closest-boundary-point/get-close-boundary-points-certified.js +7 -7
  17. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  18. package/node/cp-node/cp-node-fs.d.ts +11 -11
  19. package/node/cp-node/cp-node-fs.js +11 -11
  20. package/node/cp-node/cp-node.d.ts +15 -15
  21. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +1 -1
  22. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +11 -16
  23. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
  24. package/node/cp-node/fs/get-boundary-beziers-between.js +4 -6
  25. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  26. package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +10 -1
  27. package/node/cp-node/fs/get-boundary-beziers-to-next.js +70 -35
  28. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  29. package/node/cp-node/fs/get-salience.js +2 -2
  30. package/node/cp-node/fs/get-salience.js.map +1 -1
  31. package/node/cp-node/fs/get-speed.js +0 -1
  32. package/node/cp-node/fs/get-speed.js.map +1 -1
  33. package/node/find-2-prong/cull-bezier-pieces.d.ts +4 -4
  34. package/node/find-2-prong/cull-bezier-pieces.js +9 -9
  35. package/node/find-2-prong/cull-bezier-pieces.js.map +1 -1
  36. package/node/find-2-prong/find-2-prong.js +8 -8
  37. package/node/find-2-prong/find-2-prong.js.map +1 -1
  38. package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -2
  39. package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
  40. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
  41. package/node/find-2-prong/reduce-radius.d.ts +1 -1
  42. package/node/find-2-prong/reduce-radius.js +5 -5
  43. package/node/find-2-prong/reduce-radius.js.map +1 -1
  44. package/node/find-3-prong.ts/calc-better-x.d.ts +2 -2
  45. package/node/find-3-prong.ts/calc-better-x.js +3 -3
  46. package/node/find-3-prong.ts/calc-better-x.js.map +1 -1
  47. package/node/find-3-prong.ts/calc-initial-3-prong-center.d.ts +2 -2
  48. package/node/find-3-prong.ts/calc-initial-3-prong-center.js +3 -3
  49. package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -1
  50. package/node/find-3-prong.ts/find-3-prong-for-delta3s.d.ts +2 -2
  51. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js +16 -16
  52. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -1
  53. package/node/find-3-prong.ts/find-3-prong.js +2 -2
  54. package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
  55. package/node/find-3-prong.ts/get-closest-points.d.ts +2 -2
  56. package/node/find-3-prong.ts/get-closest-points.js +4 -4
  57. package/node/find-3-prong.ts/get-closest-points.js.map +1 -1
  58. package/node/find-mat/find-mat.js +4 -0
  59. package/node/find-mat/find-mat.js.map +1 -1
  60. package/node/find-mat/get-meta.js.map +1 -1
  61. package/node/index.d.ts +1 -0
  62. package/node/index.js +1 -1
  63. package/node/index.js.map +1 -1
  64. package/node/mat/get-boundary-piece-beziers.js +7 -7
  65. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  66. package/node/mat/mat.d.ts +1 -1
  67. package/node/point-on-shape/compare-poss.d.ts +3 -3
  68. package/node/point-on-shape/compare-poss.js +3 -3
  69. package/node/point-on-shape/get-osculating-circle.d.ts +1 -1
  70. package/node/point-on-shape/get-osculating-circle.js +1 -1
  71. package/node/point-on-shape/pos-to-human-string.d.ts +1 -1
  72. package/node/point-on-shape/pos-to-human-string.js +1 -1
  73. package/node/sat/cull.d.ts +7 -5
  74. package/node/sat/cull.js +7 -4
  75. package/node/sat/cull.js.map +1 -1
  76. package/node/sat/to-scale-axis.d.ts +3 -2
  77. package/node/sat/to-scale-axis.js +3 -2
  78. package/node/sat/to-scale-axis.js.map +1 -1
  79. package/package.json +5 -5
  80. package/src/closest-boundary-point/cull-bezier-pieces.ts +12 -11
  81. package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +8 -8
  82. package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +8 -8
  83. package/src/closest-boundary-point/get-best-distance-squared.ts +6 -6
  84. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +8 -8
  85. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +12 -18
  86. package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -7
  87. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +79 -53
  88. package/src/cp-node/fs/get-salience.ts +2 -2
  89. package/src/cp-node/fs/get-speed.ts +1 -6
  90. package/src/curve/curve.ts +5 -5
  91. package/src/debug/functions/draw-elem/two-prong.ts +40 -40
  92. package/src/debug/functions/two-prong.ts +195 -195
  93. package/src/debug/two-prong-for-debugging.ts +26 -26
  94. package/src/find-2-prong/add-debug-info.ts +38 -38
  95. package/src/find-2-prong/cull-bezier-pieces.ts +10 -10
  96. package/src/find-2-prong/find-2-prong.ts +8 -8
  97. package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
  98. package/src/find-2-prong/reduce-radius.ts +5 -5
  99. package/src/find-3-prong.ts/calc-better-x.ts +3 -3
  100. package/src/find-3-prong.ts/calc-initial-3-prong-center.ts +3 -3
  101. package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +16 -16
  102. package/src/find-3-prong.ts/find-3-prong.ts +2 -2
  103. package/src/find-3-prong.ts/get-closest-points.ts +4 -4
  104. package/src/find-mat/add-2-prongs-by-error.ts +7 -7
  105. package/src/find-mat/find-mat.ts +6 -0
  106. package/src/find-mat/get-meta.ts +7 -1
  107. package/src/index.ts +2 -2
  108. package/src/mat/get-boundary-piece-beziers.ts +7 -7
  109. package/src/mat/get-two-prong-type.ts +8 -8
  110. package/src/sat/cull.ts +10 -7
  111. package/src/sat/to-scale-axis.ts +18 -17
  112. package/src/utils/bezier-piece-to-bezier.ts +7 -7
  113. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.d.ts +0 -3
  114. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js +0 -6
  115. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js.map +0 -1
  116. package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +0 -70
  117. package/src/cp-node/fs/cp-nodes-to-boundary-beziers.ts +0 -10
@@ -10,22 +10,22 @@ import { CurvePiece } from '../mat/curve-piece.js';
10
10
  */
11
11
  function reduceRadius(
12
12
  extreme: number,
13
- bezierPieces: CurvePiece[],
13
+ curvePieces: CurvePiece[],
14
14
  p: number[],
15
15
  x: number[]) {
16
16
 
17
17
  const TOLERANCE = 1 + 2**-10;
18
18
 
19
19
  let minRadius = Number.POSITIVE_INFINITY;
20
- for (let i=0; i<bezierPieces.length; i++) {
21
- const bezierPiece = bezierPieces[i];
20
+ for (let i=0; i<curvePieces.length; i++) {
21
+ const curvePiece = curvePieces[i];
22
22
 
23
- const ps = bezierPiece.curve.ps;
23
+ const ps = curvePiece.curve.ps;
24
24
 
25
25
  // let min = Number.POSITIVE_INFINITY;
26
26
  const num = 2;
27
27
  for (let j=0; j<(num + 1); j++) {
28
- const p_ = evalDeCasteljau(ps, bezierPiece.ts[j/num]);
28
+ const p_ = evalDeCasteljau(ps, curvePiece.ts[j/num]);
29
29
  const cc = getCircleCenterFrom2PointsAndNormal(extreme, p, x, p_);
30
30
  if (cc) {
31
31
  let r = squaredDistanceBetween(p, cc);
@@ -9,14 +9,14 @@ import { getClosestPoints } from './get-closest-points.js';
9
9
  * Find new x and ps that are a better estimate of the 3-prong circle.
10
10
  * The potential function, V, is defined as the distance to the actual 3 prong
11
11
  * circle center.
12
- * @param bezierPiece3s The three boundary pieces, each of which should contain
12
+ * @param curvePiece3s The three boundary pieces, each of which should contain
13
13
  * a point of the 3-prong to be found.
14
14
  * @param x The currently best guess at the center of the 3-prong circle.
15
15
  * @param vectorToZeroV
16
16
  * @param extreme
17
17
  */
18
18
  function calcBetterX(
19
- bezierPiece3s: CurvePiece[][],
19
+ curvePiece3s: CurvePiece[][],
20
20
  x: number[],
21
21
  vectorToZeroV: number[]) {
22
22
 
@@ -33,7 +33,7 @@ function calcBetterX(
33
33
  newX = translate(shift, x);
34
34
 
35
35
 
36
- newPoss = getClosestPoints(newX, bezierPiece3s);
36
+ newPoss = getClosestPoints(newX, curvePiece3s);
37
37
 
38
38
  // Point of zero V
39
39
  const newCircleCenter = circumCenter(newPoss.map(pos => pos!.p));
@@ -13,13 +13,13 @@ const { max, ceil, log2 } = Math;
13
13
  * must be within the shape.
14
14
  * @param δ3s - The three boundary pieces of which we need to find the three
15
15
  * 3-prong points.
16
- * @param bezierPiece3s
16
+ * @param curvePiece3s
17
17
  * @param extreme
18
18
  */
19
19
  function calcInitial3ProngCenter(
20
20
  maxCoordinate: number,
21
21
  δ3s: CpNode[][],
22
- bezierPiece3s: CurvePiece[][]) {
22
+ curvePiece3s: CurvePiece[][]) {
23
23
 
24
24
  const circle = δ3s[0][0].cp.circle;
25
25
  const twoProngCircleCenter = circle.center;
@@ -27,7 +27,7 @@ function calcInitial3ProngCenter(
27
27
  const pow = max(0,ceil(log2(maxCoordinate/circle.radius))) + 1; // determines accuracy;
28
28
  const pos = getCloseBoundaryPointsCertified(
29
29
  pow,
30
- bezierPiece3s[1],
30
+ curvePiece3s[1],
31
31
  twoProngCircleCenter
32
32
  )[0];
33
33
 
@@ -27,7 +27,7 @@ const calcVectorToZeroV_StraightToIt = fromTo;
27
27
  * Finds a 3-prong using only the 3 given δs.
28
28
  * @param δs The boundary pieces
29
29
  * @param idx δ identifier
30
- * @param bezierPiecess
30
+ * @param curvePiecess
31
31
  * @param maxCoordinate The maximum coordinate value used to calculate floating point
32
32
  * tolerances.
33
33
  */
@@ -35,7 +35,7 @@ function find3ProngForDelta3s(
35
35
  δs: CpNode[][],
36
36
  idx: number,
37
37
  k: number,
38
- bezierPiecess: CurvePiece[][],
38
+ curvePiecess: CurvePiece[][],
39
39
  maxCoordinate: number) {
40
40
 
41
41
  const TOLERANCE = 2**-32*maxCoordinate;
@@ -47,10 +47,10 @@ function find3ProngForDelta3s(
47
47
  δs[δs.length-1]
48
48
  ];
49
49
 
50
- const bezierPieces_ = [
51
- bezierPiecess[0],
52
- bezierPiecess[idx],
53
- bezierPiecess[δs.length-1]
50
+ const curvePieces_ = [
51
+ curvePiecess[0],
52
+ curvePiecess[idx],
53
+ curvePiecess[δs.length-1]
54
54
  ];
55
55
 
56
56
  const δ3ss = [
@@ -59,15 +59,15 @@ function find3ProngForDelta3s(
59
59
  [δs_[2], δs_[0], δs_[1]],
60
60
  ];
61
61
 
62
- const bezierPiecess_ = [
63
- [bezierPieces_[0], bezierPieces_[1], bezierPieces_[2]],
64
- [bezierPieces_[1], bezierPieces_[2], bezierPieces_[0]],
65
- [bezierPieces_[2], bezierPieces_[0], bezierPieces_[1]],
62
+ const curvePiecess_ = [
63
+ [curvePieces_[0], curvePieces_[1], curvePieces_[2]],
64
+ [curvePieces_[1], curvePieces_[2], curvePieces_[0]],
65
+ [curvePieces_[2], curvePieces_[0], curvePieces_[1]],
66
66
  ]
67
67
 
68
68
 
69
69
  const δ3s = δ3ss[k];
70
- const bezierPiece3s = bezierPiecess_[k];
70
+ const curvePiece3s = curvePiecess_[k];
71
71
 
72
72
  if (isSharp(δ3s[0][0])) { return undefined; }
73
73
 
@@ -75,13 +75,13 @@ function find3ProngForDelta3s(
75
75
  let poss: PointOnShape[] = undefined!;
76
76
  let circumCenter_;
77
77
  let j = 0; // Safeguard for slow convergence
78
- let x = calcInitial3ProngCenter(maxCoordinate, δ3s, bezierPiece3s);
78
+ let x = calcInitial3ProngCenter(maxCoordinate, δ3s, curvePiece3s);
79
79
 
80
80
  let tolerance = Number.POSITIVE_INFINITY;
81
81
  while (tolerance > TOLERANCE && j < MAX_ITERATIONS) {
82
82
  j++;
83
83
 
84
- poss = getClosestPoints(x, bezierPiece3s);
84
+ poss = getClosestPoints(x, curvePiece3s);
85
85
  if (!Number.isFinite(x[0]) || !Number.isFinite(x[1])) {
86
86
 
87
87
  // TODO - the code can be cleaned up and sped up a lot if we don't
@@ -103,7 +103,7 @@ function find3ProngForDelta3s(
103
103
  // loop. This check, for instance, would be eliminated completely.
104
104
  return undefined;
105
105
  }
106
- const upds = calcBetterX(bezierPiece3s, x, vectorToZeroV);
106
+ const upds = calcBetterX(curvePiece3s, x, vectorToZeroV);
107
107
  x = upds.newX;
108
108
  poss = upds.newPoss;
109
109
 
@@ -173,10 +173,10 @@ function find3ProngForDelta3s(
173
173
  // candidate for the 3-prong.
174
174
  //-------------------------------------------------------------------------
175
175
  const closestDs = [];
176
- for (let i=0; i<bezierPiecess.length; i++) {
176
+ for (let i=0; i<curvePiecess.length; i++) {
177
177
  const p = getCloseBoundaryPointsCertified(
178
178
  5, // TODO - see find-2-prong
179
- bezierPiecess[i], x
179
+ curvePiecess[i], x
180
180
  )[0];
181
181
 
182
182
  closestDs.push( distanceBetween(p.p, x) );
@@ -15,7 +15,7 @@ import { getBoundaryPieceBeziers } from '../mat/get-boundary-piece-beziers.js';
15
15
  function find3Prong(
16
16
  δs: CpNode[][], extreme: number) {
17
17
 
18
- const bezierPiecess = δs.map(getBoundaryPieceBeziers);
18
+ const curvePiecess = δs.map(getBoundaryPieceBeziers);
19
19
 
20
20
  // The best candidate amongst the different 'permutations' of the given δs.
21
21
  let threeProng: {
@@ -27,7 +27,7 @@ function find3Prong(
27
27
  for (let i=1; i<δs.length-1; i++) {
28
28
  for (let k=0; k<3; k++) {
29
29
  const threeProngInfo =
30
- find3ProngForDelta3s(δs, i, k, bezierPiecess, extreme);
30
+ find3ProngForDelta3s(δs, i, k, curvePiecess, extreme);
31
31
  if (!threeProngInfo) { continue; }
32
32
 
33
33
  const { circle, poss: poss, error, δ3s } = threeProngInfo;
@@ -5,17 +5,17 @@ import { getCloseBoundaryPointsCertified } from '../closest-boundary-point/get-c
5
5
  /**
6
6
  * @internal
7
7
  * @param x
8
- * @param bezierPiece3s
8
+ * @param curvePiece3s
9
9
  * @param extreme
10
10
  */
11
11
  function getClosestPoints(
12
12
  x: number[],
13
- bezierPiece3s: CurvePiece[][]) {
13
+ curvePiece3s: CurvePiece[][]) {
14
14
 
15
- return bezierPiece3s.map(bezierPieces => {
15
+ return curvePiece3s.map(curvePieces => {
16
16
  return getCloseBoundaryPointsCertified(
17
17
  5, // TODO - see find-2-prong
18
- bezierPieces, x
18
+ curvePieces, x
19
19
  )[0];
20
20
  });
21
21
  }
@@ -1,18 +1,18 @@
1
- import { drawFs } from "flo-draw";
1
+ // import { drawFs } from "flo-draw";
2
2
  import { closestPointOnBezier } from "flo-bezier3";
3
3
  import { CpNode } from "../cp-node/cp-node.js";
4
4
  import { findAndAdd2Prong } from "../find-2-prong/find-and-add-2-prong.js";
5
5
  import { MatMeta } from "../mat/mat-meta.js";
6
6
  import { getHalfAngle } from "./get-half-angles.js";
7
7
  import { getMatCurveToNext } from "../cp-node/fs/get-mat-curve-to-next.js";
8
- import { getAllOnCircle } from "../cp-node/fs/get-all-on-circle.js";
8
+ // import { getAllOnCircle } from "../cp-node/fs/get-all-on-circle.js";
9
9
  import { isTerminating } from "../cp-node/fs/is-terminating.js";
10
- import { findAndAdd3Prongs } from "../find-3-prong.ts/find-and-add-3-prongs.js";
11
- import { getBoundaryBezierPartsToNext } from "../cp-node/fs/get-boundary-bezier-parts-to-next.js";
12
- import { drawBezierPieces } from "../debug/functions/draw/draw-bezier-pieces.js";
10
+ // import { findAndAdd3Prongs } from "../find-3-prong.ts/find-and-add-3-prongs.js";
11
+ // import { getBoundaryBezierPartsToNext } from "../cp-node/fs/get-boundary-bezier-parts-to-next.js";
12
+ // import { drawBezierPieces } from "../debug/functions/draw/draw-bezier-pieces.js";
13
13
  import { getAllOnLoop } from "../cp-node/fs/get-all-on-loop.js";
14
- import { PointOnShape } from "../point-on-shape/point-on-shape.js";
15
- import { getBoundaryBeziersToNext } from "../cp-node/fs/get-boundary-beziers-to-next.js";
14
+ // import { PointOnShape } from "../point-on-shape/point-on-shape.js";
15
+ // import { getBoundaryBeziersToNext } from "../cp-node/fs/get-boundary-beziers-to-next.js";
16
16
  import { isPosQuiteDullCorner } from "../point-on-shape/is-pos-quite-dull-corner.js";
17
17
  import { MatOptions } from "./mat-options.js";
18
18
 
@@ -54,6 +54,12 @@ function findMat(
54
54
  maxCoordinate, squaredDiagonalLength, loops, cpTrees, pointToCpNode,
55
55
  lastInsertId, ..._meta
56
56
  };
57
+ // const cpTrees: Map<Loop, LlRbTree<CpNode>> = new Map();
58
+ // const lastInsertId = { id: 0 };
59
+ // createInitialCpTree(loops, cpTrees, sharpCornersPerLoop, lastInsertId);
60
+
61
+ // const meta = getMeta(maxCoordinate, squaredDiagonalLength, loops, cpTrees, lastInsertId);
62
+
57
63
 
58
64
  let cpNode: CpNode | undefined;
59
65
 
@@ -122,4 +122,10 @@ function addDebugInfo4() {
122
122
  }
123
123
 
124
124
 
125
- export { getPointToCpNode, getPartialMeta, addDebugInfo2, addDebugInfo3, addDebugInfo4 }
125
+ export {
126
+ getPointToCpNode,
127
+ getPartialMeta,
128
+ addDebugInfo2,
129
+ addDebugInfo3,
130
+ addDebugInfo4
131
+ }
package/src/index.ts CHANGED
@@ -49,5 +49,5 @@ export { getSharpCornersOnLoop } from './find-mat/get-sharp-corners.js';
49
49
  export { getFor2ProngsOnLoop } from './find-mat/get-for-2-prongs-on-loop.js';
50
50
  export { getPotentialClosestPointsOnCurveCertified } from './closest-boundary-point/get-potential-closest-points-on-curve-certified.js';
51
51
  export { getCloseBoundaryPointsCertified } from './closest-boundary-point/get-close-boundary-points-certified.js';
52
- // export { getMeta } from './find-mat/get-meta.js';
53
- export { findAndAddHoleClosing2Prongs } from './find-2-prong/find-and-add-hole-closing-2-prongs.js';
52
+ export { getPartialMeta, getPointToCpNode } from './find-mat/get-meta.js';
53
+ export { findAndAddHoleClosing2Prongs } from './find-2-prong/find-and-add-hole-closing-2-prongs.js';
@@ -17,7 +17,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
17
17
  let cpThis = cpNodes[0];
18
18
  const cpEnd = cpNodes[1];
19
19
 
20
- const bezierPieces: CurvePiece[] = [];
20
+ const curvePieces: CurvePiece[] = [];
21
21
 
22
22
  // As opposed to going around the circle and taking the last exit
23
23
  let goStraight = true;
@@ -41,17 +41,17 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
41
41
  } else if (posNext.curve === posThis.curve &&
42
42
  compareCps(cpThis.next.cp, cpThis.cp) > 0) {
43
43
 
44
- bezierPieces.push(
44
+ curvePieces.push(
45
45
  { curve: posThis.curve, ts: [posThis.t, posNext.t] }
46
46
  );
47
47
  } else {
48
- bezierPieces.push(
48
+ curvePieces.push(
49
49
  { curve: posThis.curve, ts: [posThis.t, 1] }
50
50
  );
51
51
 
52
52
  if (posThis.curve.loop === posNext.curve.loop) {
53
53
  addSkippedBeziers(
54
- bezierPieces,
54
+ curvePieces,
55
55
  posThis.curve,
56
56
  posNext.curve,
57
57
  posNext.t
@@ -63,7 +63,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
63
63
  } while (cpThis !== cpEnd);
64
64
 
65
65
 
66
- return bezierPieces;
66
+ return curvePieces;
67
67
  }
68
68
 
69
69
 
@@ -72,7 +72,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
72
72
  * Adds pieces of skipped beziers
73
73
  */
74
74
  function addSkippedBeziers(
75
- bezierPieces: CurvePiece[],
75
+ curvePieces: CurvePiece[],
76
76
  curveStart: Curve,
77
77
  curveEnd: Curve,
78
78
  t1: number) {
@@ -81,7 +81,7 @@ function addSkippedBeziers(
81
81
  do {
82
82
  curveThis = curveThis.next;
83
83
  const tEnd = curveThis === curveEnd ? t1 : 1;
84
- bezierPieces.push({ curve: curveThis, ts: [0, tEnd] });
84
+ curvePieces.push({ curve: curveThis, ts: [0, tEnd] });
85
85
  } while (curveThis !== curveEnd);
86
86
  }
87
87
 
@@ -1,13 +1,13 @@
1
- import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
2
- import { ElemType_TwoProng } from './elem-type-two-prong.js';
1
+ // import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
2
+ // import { ElemType_TwoProng } from './elem-type-two-prong.js';
3
3
 
4
4
 
5
- /** @internal */
6
- function getTwoProngType(e: TwoProngForDebugging): ElemType_TwoProng {
7
- if (e.holeClosing) { return 'twoProng_holeClosing' }
5
+ // /** @internal */
6
+ // function getTwoProngType(e: TwoProngForDebugging): ElemType_TwoProng {
7
+ // if (e.holeClosing) { return 'twoProng_holeClosing' }
8
8
 
9
- return 'twoProng_regular';
10
- }
9
+ // return 'twoProng_regular';
10
+ // }
11
11
 
12
12
 
13
- export { getTwoProngType }
13
+ // export { getTwoProngType }
package/src/sat/cull.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { Circle } from '../geometry/circle.js';
1
+ import type { CpNode } from '../cp-node/cp-node.js';
2
+ import type { DualSet } from '../utils/dual-set.js';
2
3
  import { getLeaves } from './get-leaves.js';
3
- import { CpNode } from '../cp-node/cp-node.js';
4
4
  import { CpNodeFs } from '../cp-node/cp-node-fs.js';
5
5
  import { isTerminating } from '../cp-node/fs/is-terminating.js';
6
- import { DualSet, DualSetFs } from '../utils/dual-set.js';
6
+ import { DualSetFs } from '../utils/dual-set.js';
7
7
 
8
8
  const { isOnSameCircle } = CpNodeFs;
9
9
 
10
10
 
11
11
  /**
12
+ * Returns the set of non-trivial forward edges starting from the given `CpNode`.
12
13
  *
13
- * @param cpStart
14
+ * @param cpStart the start `CpNode`
14
15
  */
15
16
  function getNonTrivialForwardEdges(cpStart: CpNode) {
16
17
  let cpNode = cpStart;
@@ -32,12 +33,14 @@ function getNonTrivialForwardEdges(cpStart: CpNode) {
32
33
 
33
34
 
34
35
  /**
35
- * @internal
36
36
  * Returns the set of Vertices passing the following test: walk the MAT tree and
37
37
  * keep all Vertices not in the current cull set and any Vertices that have a
38
38
  * non-culled node further down the line toward the tree leaves.
39
- * @param culls The CpNodes (referred to by circles) that should be culled.
40
- * @param maxCpNode The start CpNode which must reprsesent the maximal vertex.
39
+ *
40
+ * @param culls the `CpNode`s (referred to by circles) that should be culled
41
+ * @param maxCpNode the start `CpNode` which must represent the maximal vertex
42
+ *
43
+ * @internal
41
44
  */
42
45
  function cull(
43
46
  culls: DualSet<number, number>,
@@ -12,43 +12,44 @@ import { getSatCulls } from './get-sat-culls.js';
12
12
 
13
13
 
14
14
  /**
15
- * Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
16
- * the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
15
+ * Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
16
+ * the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
17
17
  * preserves topology at any scale.
18
18
  *
19
19
  * Typically the MAT contains too many branches caused by minute details on the
20
20
  * boundary of the shape. The SAT is a simplification of the MAT that preserves
21
21
  * less detail the higher the applied scale factor. The severity at which noise
22
22
  * are removed depends on the local scale of the shape.
23
- * @param mat The Medial Axis Transform (`Mat`) on which to apply the SAT.
24
- * @param s The scale factor >= 1 (e.g. 1.3)
23
+ *
24
+ * @param mat the Medial Axis Transform (MAT) on which to apply the SAT
25
+ * @param s the scale factor >= 1 (e.g. 1.3)
25
26
  */
26
27
  function toScaleAxis(
27
- mat: Mat,
28
- s: number): Mat {
28
+ mat: Mat,
29
+ s: number): Mat {
29
30
 
30
- let timingStart = 0;
31
- if (typeof _debug_ !== 'undefined') {
32
- timingStart = performance.now();
33
- }
31
+ let timingStart = 0;
32
+ if (typeof _debug_ !== 'undefined') {
33
+ timingStart = performance.now();
34
+ }
34
35
 
35
- const cpNode = getLargestVertex(clone(mat.cpNode));
36
- const culls = getSatCulls(cpNode, s);
36
+ const cpNode = getLargestVertex(clone(mat.cpNode));
37
+ const culls = getSatCulls(cpNode, s);
37
38
 
38
- cull(culls, cpNode);
39
+ cull(culls, cpNode);
39
40
 
40
- const sat: Mat = {
41
+ const sat: Mat = {
41
42
  cpNode: cpNode,
42
43
  meta: {
43
44
  ...mat.meta,
44
- cpTrees: createNewCpTree(cpNode)
45
+ cpTrees: createNewCpTree(cpNode)
45
46
  }
46
47
  };
47
48
 
48
49
 
49
- addDebugInfo(timingStart);
50
+ addDebugInfo(timingStart);
50
51
 
51
- return sat;
52
+ return sat;
52
53
  }
53
54
 
54
55
 
@@ -1,13 +1,13 @@
1
- import { BezierPiece, fromTo } from "flo-bezier3";
1
+ // import { BezierPiece, fromTo } from "flo-bezier3";
2
2
 
3
3
 
4
- function bezierPieceToBezier(
5
- piece: BezierPiece) {
4
+ // function bezierPieceToBezier(
5
+ // piece: BezierPiece) {
6
6
 
7
- const { ps, ts } = piece;
7
+ // const { ps, ts } = piece;
8
8
 
9
- return fromTo(ps, ts[0], ts[1]);
10
- }
9
+ // return fromTo(ps, ts[0], ts[1]);
10
+ // }
11
11
 
12
12
 
13
- export { bezierPieceToBezier }
13
+ // export { bezierPieceToBezier }
@@ -1,3 +0,0 @@
1
- import { CpNode } from "../cp-node.js";
2
- declare function cpNodesToBoundaryBeziers(cpNodes: CpNode[]): number[][][];
3
- export { cpNodesToBoundaryBeziers };
@@ -1,6 +0,0 @@
1
- import { getBoundaryBeziersToNext } from "./get-boundary-beziers-to-next.js";
2
- function cpNodesToBoundaryBeziers(cpNodes) {
3
- return cpNodes.flatMap(getBoundaryBeziersToNext);
4
- }
5
- export { cpNodesToBoundaryBeziers };
6
- //# sourceMappingURL=cp-nodes-to-boundary-beziers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cp-nodes-to-boundary-beziers.js","sourceRoot":"","sources":["../../../src/cp-node/fs/cp-nodes-to-boundary-beziers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG7E,SAAS,wBAAwB,CAAC,OAAiB;IAC/C,OAAO,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAA;AACpD,CAAC;AAGD,OAAO,EAAE,wBAAwB,EAAE,CAAA"}
@@ -1,70 +0,0 @@
1
- // import { getObjClosestTo } from 'flo-vector2d';
2
- // import { Curve } from '../curve/curve.js';
3
- // import { PointOnShape } from '../point-on-shape/point-on-shape.js';
4
- // import { createPos } from '../point-on-shape/create-pos.js';
5
- // import { BezierPiece } from '../mat/bezier-piece.js';
6
- // import { cullBezierPieces1 } from './cull-bezier-pieces.js';
7
- // import { getPotentialClosestPointsOnCurveCertified } from './get-potential-closest-points-on-curve-certified.js';
8
- // import { squaredDistanceBetweenDd } from '../find-2-prong/squared-distance-between-dd.js';
9
-
10
-
11
- // /**
12
- // * @internal
13
- // * Returns the closest boundary point to the given point, limited to the given
14
- // * bezier pieces, including the beziers actually checked after culling.
15
- // * @param bezierPieces
16
- // * @param x
17
- // * @param touchedCurve
18
- // * @param t
19
- // * @param extreme
20
- // */
21
- // function getClosestBoundaryPointCertified(
22
- // angle: number,
23
- // bezierPieces: BezierPiece[],
24
- // x: number[],
25
- // touchedCurve: Curve,
26
- // t: number,
27
- // for1Prong: boolean) {
28
-
29
- // bezierPieces = cullBezierPieces1(bezierPieces, x);
30
-
31
- // let bestDistance = Number.POSITIVE_INFINITY;
32
- // let pos: PointOnShape;
33
- // for (let i=0; i<bezierPieces.length; i++) {
34
- // const bezierPiece = bezierPieces[i];
35
-
36
- // const ps = getPotentialClosestPointsOnCurveCertified(
37
- // bezierPiece.curve,
38
- // x,
39
- // bezierPiece.ts,
40
- // touchedCurve,
41
- // t,
42
- // for1Prong,
43
- // angle
44
- // );
45
-
46
- // const p = getObjClosestTo(x, ps, p => p.p)
47
-
48
- // if (p === undefined) { continue; }
49
-
50
- // const d = squaredDistanceBetweenDd(p.p, x);
51
-
52
- // let curve = bezierPiece.curve;
53
- // let t_= p.t;
54
-
55
- // if (d < bestDistance) {
56
- // if (t_ === 0) {
57
- // t_ = 1;
58
- // curve = bezierPiece.curve.prev;
59
- // }
60
-
61
- // pos = createPos(curve, t_, false);
62
- // bestDistance = d;
63
- // }
64
- // }
65
-
66
- // return pos!;
67
- // }
68
-
69
-
70
- // export { getClosestBoundaryPointCertified };
@@ -1,10 +0,0 @@
1
- import { CpNode } from "../cp-node.js";
2
- import { getBoundaryBeziersToNext } from "./get-boundary-beziers-to-next.js";
3
-
4
-
5
- function cpNodesToBoundaryBeziers(cpNodes: CpNode[]) {
6
- return cpNodes.flatMap(getBoundaryBeziersToNext)
7
- }
8
-
9
-
10
- export { cpNodesToBoundaryBeziers }