flo-mat 3.0.0 → 3.0.1

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 CHANGED
@@ -28918,15 +28918,11 @@ function find2Prong(angle, loops, extreme, squaredDiagonalLength, cpTrees, y, is
28918
28918
  return undefined;
28919
28919
  }
28920
28920
  }
28921
- // const zs_ = zs;
28922
- // console.log(zs.length)
28923
- // const zPos = createPos(z.curve, z.t, false);
28924
28921
  const circle = { center: x, radius: distanceBetween(x, z.p) };
28925
28922
  if (typeof _debug_ !== 'undefined') {
28926
28923
  addDebugInfo(bezierPieces, false, x, y, z, circle, δ, xs, isHoleClosing);
28927
28924
  }
28928
- // return { circle, zs: zs_ };
28929
- return { circle, zs: zs };
28925
+ return { circle, zs: [z] };
28930
28926
  }
28931
28927
  function find_2_prong_addDebugInfo2(isHoleClosing) {
28932
28928
  if (typeof _debug_ !== 'undefined') {
@@ -30257,11 +30253,11 @@ function createNewCpTree(cpNode) {
30257
30253
  function getLeaves(cpNode) {
30258
30254
  const leaves = [];
30259
30255
  const cps = getAllOnLoop(cpNode);
30260
- cps.forEach(function (cp) {
30256
+ for (const cp of cps) {
30261
30257
  if (isTerminating(cp)) {
30262
30258
  leaves.push(cp);
30263
30259
  }
30264
- });
30260
+ }
30265
30261
  return leaves;
30266
30262
  }
30267
30263
 
@@ -31007,76 +31003,6 @@ function cull(culls, maxCpNode) {
31007
31003
  }
31008
31004
  }
31009
31005
  }
31010
- /*
31011
- function cull(
31012
- culls: Set<Circle>,
31013
- maxCpNode: CpNode) {
31014
-
31015
- let leaves = getLeaves(maxCpNode);
31016
-
31017
- function getNonTrivialBranches(cpStart: CpNode) {
31018
- let cp = cpStart.next;
31019
-
31020
- let cps: CpNode[] = [];
31021
- do {
31022
- if (cp.next !== cp.nextOnCircle) {
31023
- cps.push(cp);
31024
- }
31025
- cp = cp.nextOnCircle;
31026
- } while (cp !== cpStart)
31027
-
31028
- return cps;
31029
- }
31030
-
31031
- while (leaves.length) {
31032
- let leaf = leaves.pop();
31033
-
31034
- // Preserve topology.
31035
- if (leaf.isHoleClosing || leaf.isIntersection) { continue; }
31036
-
31037
- if (!culls.has(leaf.cp.circle)) {
31038
- continue;
31039
- }
31040
-
31041
- let cpNode = leaf.next; // Turn around
31042
-
31043
- while (true) {
31044
- cpNode = cpNode.next;
31045
- let cut = false;
31046
- let cp1 = cpNode.prevOnCircle;
31047
-
31048
- if (!culls.has(cpNode.cp.circle)) {
31049
- // Cut the branch once a non-cull has been reached.
31050
- cut = true;
31051
- } else {
31052
- //let cp2 = cp1.prevOnCircle;
31053
- let cp2 = cpNode.nextOnCircle;
31054
-
31055
- //if (maxCpNode === cpNode || maxCpNode === cp1 || maxCpNode === cp2) {
31056
- if (CpNode.isOnSameCircle(cpNode, maxCpNode)) {
31057
- cut = true; // We are at the max disk - cut whole edge
31058
- } else if (cpNode.next === cp2) {
31059
- // Continue but starting from cp2
31060
- cpNode = cp2;
31061
- } else if (cp2.next === cp1) {
31062
- // Do nothing - ignore the branch starting from cp2 since it
31063
- // is terminating.
31064
- } else if (cp2.next !== cp1) {
31065
- // At this stage (cpNode.next !== cp2 && cp2.next !== cp1)
31066
- // so it is a bifurcation point - cut the edge.
31067
- cut = true;
31068
- }
31069
- }
31070
-
31071
- if (cut) {
31072
- cp1.next = cpNode;
31073
- cpNode.prev = cp1;
31074
- break;
31075
- }
31076
- }
31077
- }
31078
- }
31079
- */
31080
31006
 
31081
31007
 
31082
31008
  ;// CONCATENATED MODULE: ./src/sat/add-debug-info.ts
@@ -31105,13 +31031,6 @@ function add_debug_info_addDebugInfo(sat, timingStart) {
31105
31031
 
31106
31032
 
31107
31033
 
31108
- function linearScale(s) {
31109
- return function (r) {
31110
- return s * r;
31111
- };
31112
- }
31113
- /** @internal */
31114
- //let len = length([0,1]);
31115
31034
  /**
31116
31035
  * Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
31117
31036
  * the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
@@ -31124,7 +31043,7 @@ function linearScale(s) {
31124
31043
  * @param mat The Medial Axis Transform ([[Mat]]) on which to apply the SAT.
31125
31044
  * @param s The scale factor >= 1 (e.g. 1.3)
31126
31045
  */
31127
- function toScaleAxis(mat, s, f = linearScale) {
31046
+ function toScaleAxis(mat, s) {
31128
31047
  let timingStart = 0;
31129
31048
  if (typeof _debug_ !== 'undefined') {
31130
31049
  timingStart = performance.now();
@@ -31135,7 +31054,7 @@ function toScaleAxis(mat, s, f = linearScale) {
31135
31054
  const cpNodes = [];
31136
31055
  traverseVertices(clone(mat.cpNode), cpNode => { cpNodes.push(cpNode); });
31137
31056
  const cpNode = getLargestVertex(cpNodes);
31138
- const f_ = f(s);
31057
+ // console.log(cpNodes.map(c => c.cp.circle.radius).length)
31139
31058
  if (typeof _debug_ !== 'undefined') {
31140
31059
  _debug_.generated.elems.maxVertex.push(cpNode);
31141
31060
  }
@@ -31147,11 +31066,11 @@ function toScaleAxis(mat, s, f = linearScale) {
31147
31066
  const rMap = new Map();
31148
31067
  traverseEdges(cpNode, function (cpNode) {
31149
31068
  /** The occulating radius stored with this vertex. */
31150
- const R = rMap.get(cpNode) || f_(cpNode.cp.circle.radius);
31069
+ const R = rMap.get(cpNode) || (s * cpNode.cp.circle.radius);
31151
31070
  const cpNode_ = cpNode.next;
31152
31071
  const l = length_length([0, 1], getCurveToNext(cpNode));
31153
31072
  const r = cpNode_.cp.circle.radius;
31154
- const r_ = f_(r);
31073
+ const r_ = s * r;
31155
31074
  if (R - l > r_) {
31156
31075
  for (const cpNode of getCpNodesOnCircle(cpNode_)) {
31157
31076
  rMap.set(cpNode, R - l); // Update osculating radii