import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro"; import type { ChartPoint, ChartResult, InterAspect, Position } from "@/lib/types"; import { ASPECT_POINTS, SIGN_ELEMENT, SIGN_ORDER, SIZE, WHEEL_ASPECTS, WHEEL_POINTS, arcPath, f, spread, xy, } from "./ChartWheel"; const C = SIZE / 2; const R_LABEL = 322; // ASC / MC labels of the first person const R_OUT = 300; // outer edge of the zodiac ring const R_ZOD = 262; // inner edge of the zodiac ring const R2_GLYPH = 238; // second person: glyphs const R2_DEG = 214; const R_MID = 198; // border of the two rings const R1_GLYPH = 176; // first person: glyphs const R1_DEG = 154; const R_HOUSE = 138; // house-number ring of the first person const R_INNER = 114; // aspect circle const ANGLE_LABELS: [string, string][] = [ ["ascendant", "ASC"], ["midheaven", "MC"], ["descendant", "DSC"], ["imum_coeli", "IC"], ]; function angleOf(chart: ChartResult, key: string): Position | null { const a = chart.angles?.[key]; return typeof a === "object" && a !== null ? a : null; } /** One person's planets on a ring: tick on the outer edge, glyph, degree. */ function Ring({ points, placed, edge, glyphR, degR, start, who, timeKnown, className, }: { points: ChartPoint[]; placed: number[]; edge: number; glyphR: number; degR: number; start: number; who: string; timeKnown: boolean; className: string; }) { return ( {points.map((p, i) => { const [t1x, t1y] = xy(p.longitude, edge, start); const [t2x, t2y] = xy(p.longitude, edge - 8, start); const [lx, ly] = xy(placed[i], glyphR + 13, start); const [gx, gy] = xy(placed[i], glyphR, start); const [dx, dy] = xy(placed[i], degR, start); const deg = Number.parseInt(p.degree_in_sign_dms, 10); return ( {`${who}: ${pointName(p.id)} ${dms(p.degree_in_sign_dms)} ${signName(p.sign)}${p.retrograde ? ", retrográd" : ""}${ timeKnown && p.house ? `, ${p.house}. ház` : "" }`} {POINTS[p.id]?.glyph ?? p.id} {deg}°{p.retrograde ? "℞" : ""} ); })} ); } /** * Two charts on one wheel: the first person's planets and houses inside, the * second person's planets in the outer ring, the aspects between them in the middle. */ export function SynastryWheel({ chart1, chart2, time1, time2, aspects, name1, name2, }: { chart1: ChartResult; chart2: ChartResult; time1: boolean; time2: boolean; aspects: InterAspect[]; name1: string; name2: string; }) { const asc = time1 ? angleOf(chart1, "ascendant") : null; const start = asc?.longitude ?? 0; const cusps = time1 ? (chart1.houses?.cusps ?? []) : []; const pick = (chart: ChartResult) => WHEEL_POINTS.map((id) => chart.points.find((p) => p.id === id)).filter((p) => p !== undefined); const points1 = pick(chart1); const points2 = pick(chart2); // The inner ring is shorter, so its glyphs need a wider angle. const placed1 = spread( points1.map((p) => p.longitude), 12, ); const placed2 = spread( points2.map((p) => p.longitude), 8, ); const endsOf = (points: ChartPoint[], placed: number[], chart: ChartResult, timeKnown: boolean) => { const ends = new Map(); points.forEach((p, i) => { if (ASPECT_POINTS.includes(p.id)) ends.set(p.id, placed[i]); }); if (timeKnown) { for (const key of ["ascendant", "midheaven"]) { const a = angleOf(chart, key); if (a) ends.set(key, a.longitude); } } return ends; }; const ends1 = endsOf(points1, placed1, chart1, time1); const ends2 = endsOf(points2, placed2, chart2, time2); const lines = aspects .filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends1.has(a.person1) && ends2.has(a.person2)) .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); return ( {name1} és {name2} képlete egy körön Belül {name1} bolygói{time1 ? " és házai" : ""}, kívül {name2} bolygói; középen a kettejük közti főfényszögek. {/* Zodiac ring */} {SIGN_ORDER.map((sign, i) => { const [gx, gy] = xy(i * 30 + 15, (R_OUT + R_ZOD) / 2, start); return ( {SIGNS[sign].hu} {SIGNS[sign].glyph} ); })} {Array.from({ length: 72 }, (_, k) => { const d = k * 5; const [x1, y1] = xy(d, R_ZOD, start); const [x2, y2] = xy(d, R_ZOD + (d % 10 === 0 ? 8 : 5), start); return ; })} {/* The first person's houses */} {cusps.length === 12 && ( {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_MID, 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 ( {c.house} ); })} {ANGLE_LABELS.map(([key, label]) => { const a = angleOf(chart1, key); if (!a) return null; const [x, y] = xy(a.longitude, R_LABEL, start); return ( {`${name1}: ${pointName(key)} ${dms(a.degree_in_sign_dms)} ${signName(a.sign)}`} {label} ); })} )} {/* Aspects between the two */} {lines.map((a) => { const [x1, y1] = xy(ends1.get(a.person1)!, R_INNER, start); const [x2, y2] = xy(ends2.get(a.person2)!, R_INNER, start); const s = a.strength; return ( {`${name1} ${pointName(a.person1)} ${ASPECTS[a.aspect]?.hu ?? a.aspect} ${name2} ${pointName(a.person2)} (orbis ${orbText(a.orb)})`} ); })} {[...ends1].map(([id, lon]) => { const [x, y] = xy(lon, R_INNER, start); return ; })} {[...ends2].map(([id, lon]) => { const [x, y] = xy(lon, R_INNER, start); return ; })} ); } /** Key to the two rings and the aspect lines. */ export function SynastryLegend({ name1, name2, time1 }: { name1: string; name2: string; time1: boolean }) { return (

{[ ["trine", "trigon"], ["sextile", "szextil"], ["square", "kvadrát"], ["opposition", "szembenállás"], ].map(([aspect, label]) => ( ))}

A vonalak a két fél bolygói közti főfényszögek; vastagabb vonal: szorosabb fényszög. Az összes a táblázatokban.

); }