2026-11-16 06:37:59 +00:00
|
|
|
|
import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
|
|
|
|
|
|
import type { ChartResult, Position } from "@/lib/types";
|
|
|
|
|
|
|
|
|
|
|
|
// Radii of the rings (viewBox is SIZE × SIZE, centre C).
|
|
|
|
|
|
const SIZE = 680;
|
|
|
|
|
|
const C = SIZE / 2;
|
|
|
|
|
|
const R_LABEL = 322; // ASC / MC labels
|
|
|
|
|
|
const R_OUT = 300; // outer edge of the zodiac ring
|
|
|
|
|
|
const R_ZOD = 254; // inner edge of the zodiac ring
|
|
|
|
|
|
const R_GLYPH = 222; // planet glyphs
|
|
|
|
|
|
const R_DEG = 188; // planet degrees
|
|
|
|
|
|
const R_HOUSE = 172; // outer edge of the house-number ring
|
|
|
|
|
|
const R_INNER = 146; // aspect circle
|
|
|
|
|
|
|
|
|
|
|
|
// Points drawn on the wheel; the asteroids and the south node are only in the tables.
|
|
|
|
|
|
const WHEEL_POINTS = [
|
|
|
|
|
|
"sun",
|
|
|
|
|
|
"moon",
|
|
|
|
|
|
"mercury",
|
|
|
|
|
|
"venus",
|
|
|
|
|
|
"mars",
|
|
|
|
|
|
"jupiter",
|
|
|
|
|
|
"saturn",
|
|
|
|
|
|
"uranus",
|
|
|
|
|
|
"neptune",
|
|
|
|
|
|
"pluto",
|
|
|
|
|
|
"north_node",
|
|
|
|
|
|
"lilith",
|
|
|
|
|
|
"chiron",
|
|
|
|
|
|
];
|
2026-11-17 06:17:02 +00:00
|
|
|
|
// Aspects drawn on the wheel, between these points; the rest (minor aspects,
|
|
|
|
|
|
// nodes, Lilith, Chiron) are only in the aspect table.
|
|
|
|
|
|
const WHEEL_ASPECTS = ["opposition", "square", "trine", "sextile"];
|
|
|
|
|
|
const ASPECT_POINTS = ["sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
2026-11-16 06:37:59 +00:00
|
|
|
|
const SIGN_ORDER = Object.keys(SIGNS);
|
|
|
|
|
|
const SIGN_ELEMENT = ["fire", "earth", "air", "water"];
|
|
|
|
|
|
const ANGLE_LABELS: [string, string][] = [
|
|
|
|
|
|
["ascendant", "ASC"],
|
|
|
|
|
|
["midheaven", "MC"],
|
|
|
|
|
|
["descendant", "DSC"],
|
|
|
|
|
|
["imum_coeli", "IC"],
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** Screen point of an ecliptic longitude: the ascendant (or 0° Aries) is on the left. */
|
|
|
|
|
|
function xy(lon: number, r: number, start: number): [number, number] {
|
|
|
|
|
|
const a = ((180 + lon - start) * Math.PI) / 180;
|
|
|
|
|
|
return [C + r * Math.cos(a), C - r * Math.sin(a)];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const f = (n: number) => n.toFixed(2);
|
|
|
|
|
|
|
|
|
|
|
|
/** Pushes glyphs apart so that neighbours are at least `min` degrees from each other. */
|
|
|
|
|
|
function spread(lons: number[], min: number): number[] {
|
|
|
|
|
|
const n = lons.length;
|
|
|
|
|
|
const order = lons.map((_, i) => i).sort((a, b) => lons[a] - lons[b]);
|
|
|
|
|
|
const pos = order.map((i) => lons[i]);
|
|
|
|
|
|
for (let iter = 0; iter < 200 && n > 1; iter++) {
|
|
|
|
|
|
let moved = false;
|
|
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
|
|
|
|
const j = (i + 1) % n;
|
|
|
|
|
|
const gap = pos[j] - pos[i] + (j === 0 ? 360 : 0);
|
|
|
|
|
|
if (gap < min - 0.01) {
|
|
|
|
|
|
const d = (min - gap) / 2;
|
|
|
|
|
|
pos[i] -= d;
|
|
|
|
|
|
pos[j] += d;
|
|
|
|
|
|
moved = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!moved) break;
|
|
|
|
|
|
}
|
|
|
|
|
|
const out = new Array<number>(n);
|
|
|
|
|
|
order.forEach((orig, k) => (out[orig] = pos[k]));
|
|
|
|
|
|
return out;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function arcPath(r1: number, r2: number, from: number, to: number, start: number): string {
|
|
|
|
|
|
const [x1, y1] = xy(from, r2, start);
|
|
|
|
|
|
const [x2, y2] = xy(to, r2, start);
|
|
|
|
|
|
const [x3, y3] = xy(to, r1, start);
|
|
|
|
|
|
const [x4, y4] = xy(from, r1, start);
|
|
|
|
|
|
// Increasing longitude runs counter-clockwise on screen (sweep flag 0).
|
|
|
|
|
|
return `M${f(x1)} ${f(y1)} A${r2} ${r2} 0 0 0 ${f(x2)} ${f(y2)} L${f(x3)} ${f(y3)} A${r1} ${r1} 0 0 1 ${f(x4)} ${f(y4)} Z`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** The natal chart as a wheel: zodiac, houses, planets and aspect lines. */
|
|
|
|
|
|
export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown: boolean }) {
|
|
|
|
|
|
const angle = (key: string): Position | null => {
|
|
|
|
|
|
const a = chart.angles?.[key];
|
|
|
|
|
|
return typeof a === "object" && a !== null ? a : null;
|
|
|
|
|
|
};
|
|
|
|
|
|
const asc = timeKnown ? angle("ascendant") : null;
|
|
|
|
|
|
const start = asc?.longitude ?? 0;
|
|
|
|
|
|
const cusps = timeKnown ? (chart.houses?.cusps ?? []) : [];
|
|
|
|
|
|
|
|
|
|
|
|
const points = WHEEL_POINTS.map((id) => chart.points.find((p) => p.id === id)).filter((p) => p !== undefined);
|
|
|
|
|
|
const placed = spread(
|
|
|
|
|
|
points.map((p) => p.longitude),
|
|
|
|
|
|
9,
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2026-11-17 06:17:02 +00:00
|
|
|
|
// Aspect line ends: the planets at their spread-out glyph angle (so lines of
|
|
|
|
|
|
// neighbouring planets do not run into one point) and, with a known time,
|
|
|
|
|
|
// the ascendant and the midheaven.
|
|
|
|
|
|
const ends = new Map<string, number>();
|
|
|
|
|
|
points.forEach((p, i) => {
|
|
|
|
|
|
if (ASPECT_POINTS.includes(p.id)) ends.set(p.id, placed[i]);
|
|
|
|
|
|
});
|
2026-11-16 06:37:59 +00:00
|
|
|
|
if (timeKnown) {
|
2026-11-17 06:17:02 +00:00
|
|
|
|
for (const key of ["ascendant", "midheaven"]) {
|
2026-11-16 06:37:59 +00:00
|
|
|
|
const a = angle(key);
|
|
|
|
|
|
if (a) ends.set(key, a.longitude);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-11-17 06:17:02 +00:00
|
|
|
|
// Only the major aspects; tight ones are drawn last (on top).
|
|
|
|
|
|
const aspects = (chart.aspects ?? [])
|
|
|
|
|
|
.filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends.has(a.point1) && ends.has(a.point2))
|
|
|
|
|
|
.map((a) => ({ ...a, strength: a.max_orb > 0 ? 1 - Math.min(a.orb / a.max_orb, 1) : 0.5 }))
|
|
|
|
|
|
.sort((x, y) => x.strength - y.strength);
|
|
|
|
|
|
// Hovering or focusing a point shows only its aspects.
|
|
|
|
|
|
const highlight = [...ends.keys()]
|
|
|
|
|
|
.map((id) => {
|
|
|
|
|
|
const on = `.chart-wheel:has(.p-${id}:hover, .p-${id}:focus-visible)`;
|
|
|
|
|
|
return `${on} .w-aspect:not(.a-${id}){stroke-opacity:0.06}${on} .w-aspect.a-${id}{stroke-opacity:1}`;
|
|
|
|
|
|
})
|
|
|
|
|
|
.join("\n");
|
2026-11-16 06:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
const description = points
|
|
|
|
|
|
.map((p) => `${pointName(p.id)} ${signName(p.sign)} ${dms(p.degree_in_sign_dms)}`)
|
|
|
|
|
|
.join(", ");
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<svg
|
|
|
|
|
|
className="chart-wheel"
|
|
|
|
|
|
viewBox={`0 0 ${SIZE} ${SIZE}`}
|
|
|
|
|
|
role="img"
|
|
|
|
|
|
aria-labelledby="wheel-title wheel-desc"
|
|
|
|
|
|
>
|
|
|
|
|
|
<title id="wheel-title">Születési képlet</title>
|
|
|
|
|
|
<desc id="wheel-desc">
|
|
|
|
|
|
{timeKnown && asc ? `Aszcendens ${signName(asc.sign)}. ` : "Születési idő nélkül, házak nélkül. "}
|
|
|
|
|
|
{description}
|
|
|
|
|
|
</desc>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Zodiac ring */}
|
|
|
|
|
|
<circle cx={C} cy={C} r={R_OUT} className="w-ring" />
|
|
|
|
|
|
{SIGN_ORDER.map((sign, i) => {
|
|
|
|
|
|
const [gx, gy] = xy(i * 30 + 15, (R_OUT + R_ZOD) / 2, start);
|
|
|
|
|
|
return (
|
|
|
|
|
|
<g key={sign}>
|
|
|
|
|
|
<path d={arcPath(R_ZOD, R_OUT, i * 30, i * 30 + 30, start)} className={`w-sign w-${SIGN_ELEMENT[i % 4]}`} />
|
|
|
|
|
|
<text x={f(gx)} y={f(gy)} className="w-sign-glyph" dominantBaseline="central" textAnchor="middle">
|
|
|
|
|
|
<title>{SIGNS[sign].hu}</title>
|
|
|
|
|
|
{SIGNS[sign].glyph}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
</g>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
{Array.from({ length: 360 }, (_, d) => {
|
|
|
|
|
|
const len = d % 10 === 0 ? 9 : d % 5 === 0 ? 6 : 3;
|
|
|
|
|
|
const [x1, y1] = xy(d, R_ZOD, start);
|
|
|
|
|
|
const [x2, y2] = xy(d, R_ZOD + len, start);
|
|
|
|
|
|
return <line key={d} x1={f(x1)} y1={f(y1)} x2={f(x2)} y2={f(y2)} className="w-tick" />;
|
|
|
|
|
|
})}
|
|
|
|
|
|
<circle cx={C} cy={C} r={R_ZOD} className="w-ring" />
|
|
|
|
|
|
|
|
|
|
|
|
{/* Houses */}
|
|
|
|
|
|
{cusps.length === 12 && (
|
|
|
|
|
|
<g>
|
|
|
|
|
|
<circle cx={C} cy={C} r={R_HOUSE} className="w-ring w-faint" />
|
|
|
|
|
|
{cusps.map((c, i) => {
|
|
|
|
|
|
const isAngle = i % 3 === 0;
|
|
|
|
|
|
const [x1, y1] = xy(c.longitude, R_INNER, start);
|
|
|
|
|
|
const [x2, y2] = xy(c.longitude, isAngle ? R_OUT : R_ZOD, start);
|
|
|
|
|
|
const next = cusps[(i + 1) % 12].longitude;
|
|
|
|
|
|
const mid = c.longitude + (((next - c.longitude + 360) % 360) / 2);
|
|
|
|
|
|
const [nx, ny] = xy(mid, (R_HOUSE + R_INNER) / 2, start);
|
|
|
|
|
|
return (
|
|
|
|
|
|
<g key={c.house}>
|
|
|
|
|
|
<line x1={f(x1)} y1={f(y1)} x2={f(x2)} y2={f(y2)} className={isAngle ? "w-axis" : "w-cusp"} />
|
|
|
|
|
|
<text x={f(nx)} y={f(ny)} className="w-house-num" dominantBaseline="central" textAnchor="middle">
|
|
|
|
|
|
{c.house}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
</g>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
{ANGLE_LABELS.map(([key, label]) => {
|
|
|
|
|
|
const a = angle(key);
|
|
|
|
|
|
if (!a) return null;
|
|
|
|
|
|
const [x, y] = xy(a.longitude, R_LABEL, start);
|
|
|
|
|
|
return (
|
2026-11-17 06:17:02 +00:00
|
|
|
|
<text
|
|
|
|
|
|
key={key}
|
|
|
|
|
|
x={f(x)}
|
|
|
|
|
|
y={f(y)}
|
|
|
|
|
|
className={`w-axis-label p-${key}`}
|
|
|
|
|
|
dominantBaseline="central"
|
|
|
|
|
|
textAnchor="middle"
|
|
|
|
|
|
>
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<title>
|
|
|
|
|
|
{pointName(key)}: {dms(a.degree_in_sign_dms)} {signName(a.sign)}
|
|
|
|
|
|
</title>
|
|
|
|
|
|
{label}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
</g>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Aspects */}
|
2026-11-17 06:17:02 +00:00
|
|
|
|
<style>{highlight}</style>
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<circle cx={C} cy={C} r={R_INNER} className="w-ring w-inner" />
|
|
|
|
|
|
{aspects.map((a) => {
|
|
|
|
|
|
const [x1, y1] = xy(ends.get(a.point1)!, R_INNER, start);
|
|
|
|
|
|
const [x2, y2] = xy(ends.get(a.point2)!, R_INNER, start);
|
2026-11-17 06:17:02 +00:00
|
|
|
|
const s = a.strength;
|
2026-11-16 06:37:59 +00:00
|
|
|
|
return (
|
|
|
|
|
|
<line
|
|
|
|
|
|
key={`${a.point1}-${a.point2}-${a.aspect}`}
|
|
|
|
|
|
x1={f(x1)}
|
|
|
|
|
|
y1={f(y1)}
|
|
|
|
|
|
x2={f(x2)}
|
|
|
|
|
|
y2={f(y2)}
|
2026-11-17 06:17:02 +00:00
|
|
|
|
className={`w-aspect w-asp-${a.aspect} a-${a.point1} a-${a.point2}`}
|
|
|
|
|
|
strokeOpacity={(0.2 + 0.8 * s * s).toFixed(2)}
|
|
|
|
|
|
strokeWidth={(0.6 + 1.9 * s).toFixed(2)}
|
2026-11-16 06:37:59 +00:00
|
|
|
|
>
|
|
|
|
|
|
<title>
|
|
|
|
|
|
{pointName(a.point1)} {ASPECTS[a.aspect]?.hu ?? a.aspect} {pointName(a.point2)} (orbis{" "}
|
|
|
|
|
|
{orbText(a.orb)})
|
|
|
|
|
|
</title>
|
|
|
|
|
|
</line>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Planets */}
|
|
|
|
|
|
{points.map((p, i) => {
|
|
|
|
|
|
const [t1x, t1y] = xy(p.longitude, R_ZOD, start);
|
|
|
|
|
|
const [t2x, t2y] = xy(p.longitude, R_ZOD - 8, start);
|
|
|
|
|
|
const [lx, ly] = xy(placed[i], R_GLYPH + 14, start);
|
|
|
|
|
|
const [gx, gy] = xy(placed[i], R_GLYPH, start);
|
|
|
|
|
|
const [dx, dy] = xy(placed[i], R_DEG, start);
|
2026-11-17 06:17:02 +00:00
|
|
|
|
const [ex, ey] = xy(placed[i], R_INNER, start);
|
2026-11-16 06:37:59 +00:00
|
|
|
|
const deg = Number.parseInt(p.degree_in_sign_dms, 10);
|
|
|
|
|
|
return (
|
2026-11-17 06:17:02 +00:00
|
|
|
|
<g key={p.id} className={`w-point p-${p.id}`} tabIndex={0}>
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<title>
|
|
|
|
|
|
{pointName(p.id)}: {dms(p.degree_in_sign_dms)} {signName(p.sign)}
|
|
|
|
|
|
{p.retrograde ? ", retrográd" : ""}
|
|
|
|
|
|
{timeKnown && p.house ? `, ${p.house}. ház` : ""}
|
|
|
|
|
|
</title>
|
|
|
|
|
|
<line x1={f(t1x)} y1={f(t1y)} x2={f(t2x)} y2={f(t2y)} className="w-point-tick" />
|
|
|
|
|
|
<line x1={f(t2x)} y1={f(t2y)} x2={f(lx)} y2={f(ly)} className="w-leader" />
|
|
|
|
|
|
<text x={f(gx)} y={f(gy)} className="w-point-glyph" dominantBaseline="central" textAnchor="middle">
|
|
|
|
|
|
{POINTS[p.id]?.glyph ?? p.id}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
<text x={f(dx)} y={f(dy)} className="w-point-deg" dominantBaseline="central" textAnchor="middle">
|
|
|
|
|
|
{deg}°{p.retrograde ? "℞" : ""}
|
|
|
|
|
|
</text>
|
2026-11-17 06:17:02 +00:00
|
|
|
|
{ends.has(p.id) && <circle cx={f(ex)} cy={f(ey)} r={2.2} className="w-end" />}
|
2026-11-16 06:37:59 +00:00
|
|
|
|
</g>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-11-17 06:17:02 +00:00
|
|
|
|
|
|
|
|
|
|
const LEGEND: [string, string][] = [
|
|
|
|
|
|
["trine", "trigon"],
|
|
|
|
|
|
["sextile", "szextil"],
|
|
|
|
|
|
["square", "kvadrát"],
|
|
|
|
|
|
["opposition", "szembenállás"],
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** Key to the aspect lines of the wheel. */
|
|
|
|
|
|
export function WheelLegend() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="hint wheel-legend">
|
|
|
|
|
|
<p className="wheel-legend-items">
|
|
|
|
|
|
{LEGEND.map(([aspect, label]) => (
|
|
|
|
|
|
<span key={aspect} className="legend-item">
|
|
|
|
|
|
<span className={`legend-line legend-${aspect}`} aria-hidden="true" /> {label}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p>Vastagabb vonal: szorosabb fényszög. Egy bolygóra mutatva csak az ő fényszögei látszanak.</p>
|
|
|
|
|
|
<p>A körön a bolygók, az ASC és az MC főfényszögei vannak; az összes fényszög a táblázatban.</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|