New public pages: /holdnaptar (new and full moons, quarters, eclipses and the Moon's sign changes, month by month, with the Moon of today) and /retrograd (the retrograde periods of Mercury to Pluto with their shadows, and which planets are retrograde now), each with a page per year around the current one. The own chart gets a "Ma az égen" card: the Moon's sign, phase and natal house, the tightest transits to the chart in fixed sentences, and the retrograde planets. No AI, nothing stored. The events come from astro-engine (sampling and bisection, checked against swetest and the 2026 eclipses) through horoscope-api GET /v1/sky and /v1/sky/events; the backend serves them at /v1/public/sky… and keeps them in memory (the sky now for five minutes, a year's events for good). Links in the mobile menu, the footer, the sitemap and the free tools on the home page; the desktop header is unchanged (it is full at 1280 px). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
99 lines
3.3 KiB
TypeScript
99 lines
3.3 KiB
TypeScript
// Today's transits to a birth chart: the planets now against the chart's
|
||
// planets and angles. A plain calculation on data the page already has.
|
||
|
||
import type { ChartResult, SkyPlanet } from "./types";
|
||
|
||
export interface Transit {
|
||
transiting: string;
|
||
natal: string;
|
||
aspect: "conjunction" | "sextile" | "square" | "trine" | "opposition";
|
||
/** Degrees from exact. */
|
||
orb: number;
|
||
/** Getting closer (otherwise past exact and fading). */
|
||
applying: boolean;
|
||
}
|
||
|
||
const ASPECTS: [Transit["aspect"], number][] = [
|
||
["conjunction", 0],
|
||
["sextile", 60],
|
||
["square", 90],
|
||
["trine", 120],
|
||
["opposition", 180],
|
||
];
|
||
|
||
/** Orbs for a day's view: the faster the planet, the shorter it stays in one. */
|
||
const ORB: Record<string, number> = {
|
||
moon: 2,
|
||
sun: 2,
|
||
mercury: 2,
|
||
venus: 2,
|
||
mars: 2,
|
||
jupiter: 1.5,
|
||
saturn: 1.5,
|
||
uranus: 1,
|
||
neptune: 1,
|
||
pluto: 1,
|
||
};
|
||
|
||
const PLANETS = Object.keys(ORB);
|
||
|
||
/** Angular distance `[0, 180]`. */
|
||
function separation(a: number, b: number): number {
|
||
const d = Math.abs(a - b) % 360;
|
||
return d > 180 ? 360 - d : d;
|
||
}
|
||
|
||
/** The chart points measured to: the ten planets, and with a birth time the Ascendant and the MC (the Moon only then). */
|
||
function natalPoints(chart: ChartResult, timeKnown: boolean): [string, number][] {
|
||
const out: [string, number][] = chart.points
|
||
.filter((p) => PLANETS.includes(p.id) && (timeKnown || p.id !== "moon"))
|
||
.map((p) => [p.id, p.longitude]);
|
||
if (timeKnown && chart.angles) {
|
||
for (const id of ["ascendant", "midheaven"]) {
|
||
const a = chart.angles[id];
|
||
if (a && typeof a === "object") out.push([id, a.longitude]);
|
||
}
|
||
}
|
||
return out;
|
||
}
|
||
|
||
/** The tightest transits now, closest first (relative to the orb allowed). */
|
||
export function todaysTransits(sky: SkyPlanet[], chart: ChartResult, timeKnown: boolean, limit = 3): Transit[] {
|
||
const found: (Transit & { score: number })[] = [];
|
||
for (const t of sky) {
|
||
const maxOrb = ORB[t.id];
|
||
if (maxOrb === undefined) continue;
|
||
// Where it will be in about an hour: closer or farther from exact.
|
||
const later = t.position.longitude + t.speed / 24;
|
||
for (const [natal, lon] of natalPoints(chart, timeKnown)) {
|
||
for (const [aspect, angle] of ASPECTS) {
|
||
const orb = Math.abs(separation(t.position.longitude, lon) - angle);
|
||
if (orb > maxOrb) continue;
|
||
const applying = Math.abs(separation(later, lon) - angle) < orb;
|
||
found.push({ transiting: t.id, natal, aspect, orb, applying, score: orb / maxOrb });
|
||
}
|
||
}
|
||
}
|
||
// The Moon passes everything within hours: one of its aspects at most.
|
||
let moon = 0;
|
||
return found
|
||
.sort((a, b) => a.score - b.score)
|
||
.filter((t) => t.transiting !== "moon" || moon++ === 0)
|
||
.slice(0, limit)
|
||
.map(({ score: _, ...t }) => t);
|
||
}
|
||
|
||
/** The natal house a longitude falls in (1–12), or `null` without houses. */
|
||
export function natalHouse(chart: ChartResult, longitude: number): number | null {
|
||
const cusps = chart.houses?.cusps;
|
||
if (!cusps || cusps.length !== 12) return null;
|
||
const sorted = [...cusps].sort((a, b) => a.house - b.house).map((c) => c.longitude);
|
||
for (let i = 0; i < 12; i++) {
|
||
const start = sorted[i];
|
||
const end = sorted[(i + 1) % 12];
|
||
const span = (end - start + 360) % 360;
|
||
if ((longitude - start + 360) % 360 < span) return i + 1;
|
||
}
|
||
return null;
|
||
}
|