@euphrasiologist/lwphylo 1.2.22 → 1.2.24

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/dist/index.cjs CHANGED
@@ -175,23 +175,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
175
175
  }
176
176
 
177
177
  // src/radial/describeArcSweep.js
178
- const TAU$1 = Math.PI * 2;
179
- const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
180
-
181
- function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
178
+ function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
182
179
  console.log("describeArcSweep input:", {
183
180
  cx, cy, r,
184
181
  a0Deg: (a0 * 180 / Math.PI).toFixed(2),
185
182
  a1Deg: (a1 * 180 / Math.PI).toFixed(2),
186
- sweep
183
+ sweep,
184
+ largeArcFlag
187
185
  });
188
186
 
189
- const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
190
- if (!(r > 0) || delta < 1e-9) return "";
191
- const largeArcFlag = delta > Math.PI ? 1 : 0;
187
+ if (!(r > 0)) return "";
192
188
 
193
- const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
194
- const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
189
+ const x0 = cx + r * Math.cos(a0);
190
+ const y0 = cy - r * Math.sin(a0);
191
+ const x1 = cx + r * Math.cos(a1);
192
+ const y1 = cy - r * Math.sin(a1);
195
193
 
196
194
  return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
197
195
  }
@@ -593,22 +591,16 @@ function getChildArcsFan(pd) {
593
591
  const TAU = Math.PI * 2;
594
592
  const norm = (t) => ((t % TAU) + TAU) % TAU;
595
593
 
596
- const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
597
- const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
598
-
599
- // Circular midpoint that travels CCW from a -> b by half the CCW span
600
594
  function midCCW(a, b) {
601
- const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
595
+ const d = (b - a + TAU) % TAU;
602
596
  return norm(a + d / 2);
603
597
  }
604
598
 
605
599
  const key = (x) => (typeof x === "string" ? +x : x);
606
-
607
600
  const byId = new Map(pd.map(d => [key(d.thisId), d]));
608
601
  const childrenByParent = new Map(
609
602
  pd.map(d => [
610
603
  key(d.thisId),
611
- // normalize children to numeric IDs; drop anything we can't resolve
612
604
  (d.children || [])
613
605
  .map(ch => (typeof ch === "object" ? ch.thisId : ch))
614
606
  .map(key)
@@ -623,7 +615,6 @@ function getChildArcsFan(pd) {
623
615
  const kids = childrenByParent.get(pid) || [];
624
616
  if (kids.length < 2) continue;
625
617
 
626
- // Sort children by angle (normalized) around the circle
627
618
  const A = kids
628
619
  .map(id => {
629
620
  const node = byId.get(id);
@@ -644,14 +635,12 @@ function getChildArcsFan(pd) {
644
635
  const cur = A[i];
645
636
  const next = A[(i + 1) % N];
646
637
 
647
- // “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
648
638
  const start = midCCW(prev.a, cur.a);
649
639
  const end = midCCW(cur.a, next.a);
650
640
 
651
- // Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
652
- const ccw = ccwDelta(start, end);
653
- const cw = cwDelta(start, end);
654
- const sweep = ccw <= cw ? 0 : 1;
641
+ const sweep = 1; // always clockwise
642
+ const delta = (end - start + TAU) % TAU;
643
+ const largeArc = delta > Math.PI ? 1 : 0;
655
644
 
656
645
  child_arcs.push({
657
646
  parentId: pid,
@@ -659,7 +648,8 @@ function getChildArcsFan(pd) {
659
648
  radius,
660
649
  start,
661
650
  end,
662
- sweep
651
+ sweep,
652
+ largeArc
663
653
  });
664
654
  }
665
655
  }
@@ -1476,7 +1466,8 @@ function drawPhylogeny(
1476
1466
  radiusPx(d.radius),
1477
1467
  d.start,
1478
1468
  d.end,
1479
- d.sweep
1469
+ d.sweep,
1470
+ d.largeArc,
1480
1471
  )
1481
1472
  )
1482
1473
  .attr("fill", "none")
@@ -1665,7 +1656,7 @@ function drawPhylogeny(
1665
1656
  const R = radiusPx(rec.radius);
1666
1657
  return rec.sweep == null
1667
1658
  ? describeArc(centerX, centerY, R, rec.start, rec.end)
1668
- : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1659
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
1669
1660
  }
1670
1661
 
1671
1662
  if (a) {