The Sun's year is a pure function too, checked against the almanac

sun.js gains analemma(date, days): where the Sun is overhead at the same UTC time on each coming day, the figure-8 the
globe will draw. tools/globe/check.mjs checks the pure functions against almanac values with Node's own test runner
(dev only, nothing installed): the 2026 June solstice's declination, the March equinox, perihelion's distance, Turin's
longest day, the season in October, and the analemma spanning the tropics and the equation of time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-06 23:51:35 +02:00
1 parent f1ac5eaad2
commit 18331531b8
2 files changed
+54

No files matched your search

+9
View File
@@ -65,6 +65,15 @@ export function seasonsOf(sun) {
}
}
// Where the Sun is overhead at this same UTC time on each of the coming days (the first is the date itself): traced on
// the globe, the analemma, its figure-8 the year's declination and the equation of time.
export function analemma(date, days = 366) {
const points = []
for (let day = 0; day < days; day++)
points.push(sunAt(new Date(date.getTime() + day * 86400000)))
return points
}
// The Sun's direction in the frame of three.js's SphereGeometry, the frame the globe's shader draws in: texture u is
// 0 at longitude −180°, and a point is (−cos 2πu · cos lat, sin lat, sin 2πu · cos lat).
export function directionOf(sun) {