@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.js CHANGED
@@ -154,23 +154,21 @@ function describeArc(cx, cy, radius, startAngle, endAngle) {
154
154
  }
155
155
 
156
156
  // src/radial/describeArcSweep.js
157
- const TAU$1 = Math.PI * 2;
158
- const norm$1 = (t) => ((t % TAU$1) + TAU$1) % TAU$1;
159
-
160
- function describeArcSweep(cx, cy, r, a0, a1, sweep /*0=CCW,1=CW*/) {
157
+ function describeArcSweep(cx, cy, r, a0, a1, sweep = 1, largeArcFlag = 0) {
161
158
  console.log("describeArcSweep input:", {
162
159
  cx, cy, r,
163
160
  a0Deg: (a0 * 180 / Math.PI).toFixed(2),
164
161
  a1Deg: (a1 * 180 / Math.PI).toFixed(2),
165
- sweep
162
+ sweep,
163
+ largeArcFlag
166
164
  });
167
165
 
168
- const delta = sweep === 0 ? norm$1(a1 - a0) : norm$1(a0 - a1);
169
- if (!(r > 0) || delta < 1e-9) return "";
170
- const largeArcFlag = delta > Math.PI ? 1 : 0;
166
+ if (!(r > 0)) return "";
171
167
 
172
- const x0 = cx + r * Math.cos(a0), y0 = cy - r * Math.sin(a0);
173
- const x1 = cx + r * Math.cos(a1), y1 = cy - r * Math.sin(a1);
168
+ const x0 = cx + r * Math.cos(a0);
169
+ const y0 = cy - r * Math.sin(a0);
170
+ const x1 = cx + r * Math.cos(a1);
171
+ const y1 = cy - r * Math.sin(a1);
174
172
 
175
173
  return `M ${x0} ${y0} A ${r} ${r} 0 ${largeArcFlag} ${sweep} ${x1} ${y1}`;
176
174
  }
@@ -572,22 +570,16 @@ function getChildArcsFan(pd) {
572
570
  const TAU = Math.PI * 2;
573
571
  const norm = (t) => ((t % TAU) + TAU) % TAU;
574
572
 
575
- const ccwDelta = (a0, a1) => (a1 - a0 + TAU) % TAU;
576
- const cwDelta = (a0, a1) => (a0 - a1 + TAU) % TAU;
577
-
578
- // Circular midpoint that travels CCW from a -> b by half the CCW span
579
573
  function midCCW(a, b) {
580
- const d = (b - a + TAU) % TAU; // CCW delta in [0, 2π)
574
+ const d = (b - a + TAU) % TAU;
581
575
  return norm(a + d / 2);
582
576
  }
583
577
 
584
578
  const key = (x) => (typeof x === "string" ? +x : x);
585
-
586
579
  const byId = new Map(pd.map(d => [key(d.thisId), d]));
587
580
  const childrenByParent = new Map(
588
581
  pd.map(d => [
589
582
  key(d.thisId),
590
- // normalize children to numeric IDs; drop anything we can't resolve
591
583
  (d.children || [])
592
584
  .map(ch => (typeof ch === "object" ? ch.thisId : ch))
593
585
  .map(key)
@@ -602,7 +594,6 @@ function getChildArcsFan(pd) {
602
594
  const kids = childrenByParent.get(pid) || [];
603
595
  if (kids.length < 2) continue;
604
596
 
605
- // Sort children by angle (normalized) around the circle
606
597
  const A = kids
607
598
  .map(id => {
608
599
  const node = byId.get(id);
@@ -623,14 +614,12 @@ function getChildArcsFan(pd) {
623
614
  const cur = A[i];
624
615
  const next = A[(i + 1) % N];
625
616
 
626
- // “fan” wedge around the child: midpoint(prev→cur) .. midpoint(cur→next), CCW
627
617
  const start = midCCW(prev.a, cur.a);
628
618
  const end = midCCW(cur.a, next.a);
629
619
 
630
- // Choose the **shorter** sweep (0 = CCW, 1 = CW in our math-angle convention)
631
- const ccw = ccwDelta(start, end);
632
- const cw = cwDelta(start, end);
633
- const sweep = ccw <= cw ? 0 : 1;
620
+ const sweep = 1; // always clockwise
621
+ const delta = (end - start + TAU) % TAU;
622
+ const largeArc = delta > Math.PI ? 1 : 0;
634
623
 
635
624
  child_arcs.push({
636
625
  parentId: pid,
@@ -638,7 +627,8 @@ function getChildArcsFan(pd) {
638
627
  radius,
639
628
  start,
640
629
  end,
641
- sweep
630
+ sweep,
631
+ largeArc
642
632
  });
643
633
  }
644
634
  }
@@ -1455,7 +1445,8 @@ function drawPhylogeny(
1455
1445
  radiusPx(d.radius),
1456
1446
  d.start,
1457
1447
  d.end,
1458
- d.sweep
1448
+ d.sweep,
1449
+ d.largeArc,
1459
1450
  )
1460
1451
  )
1461
1452
  .attr("fill", "none")
@@ -1644,7 +1635,7 @@ function drawPhylogeny(
1644
1635
  const R = radiusPx(rec.radius);
1645
1636
  return rec.sweep == null
1646
1637
  ? describeArc(centerX, centerY, R, rec.start, rec.end)
1647
- : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep);
1638
+ : describeArcSweep(centerX, centerY, R, rec.start, rec.end, rec.sweep, a.largeArc);
1648
1639
  }
1649
1640
 
1650
1641
  if (a) {