diff --git a/index.html b/index.html
index 2456bd8..a899f6b 100644
--- a/index.html
+++ b/index.html
@@ -149,8 +149,21 @@
.band.done { fill: var(--band-done); }
.band.now { fill: var(--band); }
.hour-line { stroke: var(--dial-line); stroke-width: 1; fill: none; }
- .day-curve { stroke: var(--dial-line); stroke-width: .8; fill: none; opacity: .75; }
- .today { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; fill: none; opacity: .8; }
+ .day-curve { stroke: var(--dial-line); stroke-width: 1.6; fill: none; transition: stroke .2s, stroke-width .2s; }
+ .today { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 4 3; fill: none; opacity: .85; transition: stroke-width .2s; }
+ .day-curve.active { stroke: var(--accent); stroke-width: 3; }
+ .today.active { stroke-width: 3; opacity: 1; }
+ .hit { stroke: transparent; stroke-width: 16; fill: none; pointer-events: stroke; cursor: pointer; -webkit-tap-highlight-color: transparent; }
+ .hit:focus { outline: none; }
+ .horizon-line { stroke: var(--dial-line); stroke-width: 1; opacity: .6; }
+ .rod-shadow { stroke: var(--shadow-hand); stroke-width: 3.5; stroke-linecap: round; fill: none; filter: url(#soft); }
+ .curve-info { min-height: 2.6em; margin: 2px 8px 0; text-align: center; font-size: 13px; line-height: 1.35; color: var(--muted); }
+ .curve-info b { color: var(--text); font-weight: 600; }
+ .drum-shade { pointer-events: none; }
+ .month-line { stroke: var(--dial-line); stroke-width: .6; opacity: .5; }
+ .month-label { font-family: Cinzel, serif; font-size: 7px; fill: var(--muted); text-anchor: middle; dominant-baseline: central; }
+ .drop { fill: var(--water); }
+ .ripple { fill: none; stroke: var(--water); stroke-width: 1; }
.numeral { font-family: Cinzel, serif; font-size: 12px; font-weight: 500; fill: var(--muted); text-anchor: middle; dominant-baseline: central; }
.numeral.now { fill: var(--accent); font-weight: 700; }
.shadow { fill: var(--shadow-hand); filter: url(#soft); }
@@ -160,9 +173,7 @@
.bronze-line { stroke: var(--bronze); fill: none; }
.water { fill: var(--water); opacity: .7; }
.vessel { fill: var(--bg); opacity: .55; }
- .stream { stroke: var(--water); stroke-width: 2; stroke-dasharray: 4 4; animation: flow .5s linear infinite; }
- @keyframes flow { to { stroke-dashoffset: -8; } }
- @media (prefers-reduced-motion: reduce) { .stream { animation: none; } }
+ .stream { stroke: var(--water); stroke-width: 2; stroke-dasharray: 4 4; }
.col-line { stroke: var(--dial-line); stroke-width: 1; }
.col-line.vigil { stroke-width: 2; }
.star { fill: var(--star); }
@@ -340,32 +351,59 @@
–
@@ -437,11 +477,14 @@
Romans split the daylight, from sunrise to sunset, into twelve equal
horae, and the night into twelve more,
grouped into four watches (
vigiliae). So an hour stretched in summer and shrank in winter.
- By day this page draws a
hemicyclium, the hollowed-stone sundial Vitruvius credits to Berosus,
- laid out for your latitude: the curves mark the winter solstice, equinox and summer solstice,
- and the dashed line is today's path of the shadow. By night, when a sundial is useless, it switches to
- the water clock of Ctesibius: water drips at a steady rate into a cylinder, and a float lifts a figure
- whose wand points to the hour.
+ By day this page draws a spherical sundial, a hollow stone globe cut open toward the equator,
+ laid out for your latitude. A bronze gnomon hangs from the top of the opening to the centre of the sphere,
+ and its tip's shadow marks the hour. The three curves are the winter solstice (
bruma), the
+ equinox (
aequinoctium) and the summer solstice (
solstitium); the dashed line is today's path.
+ By night, when a sundial is useless, it switches to the water clock of Ctesibius (Vitruvius IX.8):
+ water drips at a steady rate into a cylinder, and a float lifts a figure whose wand points to the hour
+ on a drum. Because nights lengthen and shorten through the year, the hour lines wind around the drum,
+ which is turned so today's date faces the pointer.
@@ -529,27 +572,90 @@
return Math.asin(Math.sin(obliquity) * Math.sin(M + C + rad * 102.9372 + Math.PI));
}
- // ---- hemicyclium ----
- // Front view of an equator-facing spherical dial. The gnomon tip sits at the centre of the
- // sphere, so its shadow lands diametrically opposite the sun: x = -east, y (down) = sin(altitude).
+ // ---- spherical sundial ----
+ // Front view of an equator-facing hollow sphere. The gnomon tip sits at the centre, so the shadow
+ // of the tip lands diametrically opposite the sun. Everything works in a "dial frame": latitude is
+ // taken as |lat| and, south of the equator, declination and east-west are mirrored so the dial faces north.
const svgNS = "http://www.w3.org/2000/svg";
- const CX = 200, CY = 52, R = 170, SOLSTICE = 23.44 * rad;
+ const CX = 200, CY = 166, R = 140, SOLSTICE = 23.44 * rad, REFRACTION = -0.833 * rad;
const el = (tag, attrs, parent) => {
const e = document.createElementNS(svgNS, tag);
for (const k in attrs) e.setAttribute(k, attrs[k]);
parent.appendChild(e);
return e;
};
- function dialPoint(lat, dec, f, halfDay) {
- const south = lat < 0, phi = Math.abs(lat) * rad, d = south ? -dec : dec;
- const H0 = halfDay ?? Math.acos(Math.max(-1, Math.min(1, -Math.tan(phi) * Math.tan(d))));
+ const clamp1 = v => Math.max(-1, Math.min(1, v));
+ const halfDayAngle = (phi, d) => Math.acos(clamp1(-Math.tan(phi) * Math.tan(d)));
+ // Sun's unit vector (east, north, up) for temporal-hour fraction f of the day.
+ function sunVec(lat, dec, f, halfDay) {
+ const phi = Math.abs(lat) * rad, d = lat < 0 ? -dec : dec;
+ const H0 = halfDay ?? halfDayAngle(phi, d);
const H = H0 * (2 * f - 1);
- const x = Math.cos(d) * Math.sin(H);
- const y = Math.max(0, Math.sin(phi) * Math.sin(d) + Math.cos(phi) * Math.cos(d) * Math.cos(H));
- return [CX + (south ? -x : x) * R, CY + y * R];
+ return {
+ e: -Math.cos(d) * Math.sin(H) * (lat < 0 ? -1 : 1),
+ n: Math.cos(phi) * Math.sin(d) - Math.sin(phi) * Math.cos(d) * Math.cos(H),
+ u: Math.sin(phi) * Math.sin(d) + Math.cos(phi) * Math.cos(d) * Math.cos(H)
+ };
+ }
+ const toScreen = (east, up) => [CX + east * R, CY - up * R];
+ function dialPoint(lat, dec, f, halfDay) {
+ const s = sunVec(lat, dec, f, halfDay);
+ return toScreen(-s.e, Math.min(0, -s.u));
+ }
+ // Shadow of the hanging rod (from the top of the opening down to the centre) on the inner sphere.
+ function rodShadow(s) {
+ return range(0, 1, 24).map(h => {
+ const b = h * s.u, t = b + Math.sqrt(Math.max(0, b * b - h * h + 1));
+ return toScreen(-t * s.e, h - t * s.u);
+ });
}
const toPath = pts => 'M' + pts.map(p => p[0].toFixed(1) + ',' + p[1].toFixed(1)).join('L');
const range = (a, b, n) => Array.from({ length: n + 1 }, (_, i) => a + (b - a) * i / n);
+ const romanHourMin = (lat, dec) => {
+ const phi = Math.abs(lat) * rad, d = lat < 0 ? -dec : dec;
+ const cosH = (Math.sin(REFRACTION) - Math.sin(phi) * Math.sin(d)) / (Math.cos(phi) * Math.cos(d));
+ return Math.round(Math.acos(clamp1(cosH)) / Math.PI * 1440 / 12);
+ };
+
+ // Curves the reader can point at: the three seasonal day curves plus today's.
+ const curveEls = {};
+ let activeCurve = null, pinnedCurve = null;
+ function curveText(key) {
+ const lat = place.lat, south = lat < 0;
+ const bits = {
+ bruma: ['Bruma', 'winter solstice', south ? '21 Jun' : '21 Dec', 'shortest day', -SOLSTICE],
+ aequinoctium: ['Aequinoctium', 'equinox', '20 Mar & 22 Sep', 'day equals night', 0],
+ solstitium: ['Solstitium', 'summer solstice', south ? '21 Dec' : '21 Jun', 'longest day', SOLSTICE],
+ }[key];
+ if (key === 'today') {
+ const dec = solarDec(new Date(Date.now() + offsetMin * 6e4));
+ return `
Today's path of the shadow · ${romanHourMin(lat, dec)}-minute hours`;
+ }
+ const dec = south ? -bits[4] : bits[4];
+ return `
${bits[0]} · ${bits[1]} (~${bits[2]}) · ${bits[3]}, ${romanHourMin(lat, dec)}-minute hours`;
+ }
+ function setActiveCurve(key) {
+ activeCurve = key;
+ for (const k in curveEls) curveEls[k].classList.toggle('active', k === key);
+ $('curveInfo').innerHTML = key ? curveText(key) : 'Point at or tap a curve to identify it';
+ }
+ function addHit(key, d) {
+ let hit = $('hit-' + key);
+ if (!hit) {
+ hit = el('path', { id: 'hit-' + key, class: 'hit', tabindex: 0, role: 'button', 'aria-label': key }, $('hits'));
+ hit.addEventListener('pointerenter', () => setActiveCurve(key));
+ hit.addEventListener('pointerleave', () => setActiveCurve(pinnedCurve));
+ hit.addEventListener('focus', () => setActiveCurve(key));
+ hit.addEventListener('blur', () => setActiveCurve(pinnedCurve));
+ hit.addEventListener('click', e => {
+ e.stopPropagation();
+ pinnedCurve = pinnedCurve === key ? null : key;
+ setActiveCurve(pinnedCurve ?? key);
+ });
+ }
+ hit.setAttribute('d', d);
+ }
+ document.addEventListener('click', () => { if (pinnedCurve) { pinnedCurve = null; setActiveCurve(null); } });
const bandEls = [], numEls = [];
let dialLat = null;
@@ -570,35 +676,66 @@
// numerals sit just outside the winter-solstice curve, nearest the rim
const [px, py] = dialPoint(lat, winter, (k + .5) / 12);
const vx = px - CX, vy = py - CY, len = Math.hypot(vx, vy) || 1;
- const t = el('text', { class: 'numeral', x: px + vx / len * 11, y: py + vy / len * 11 }, nums);
+ const t = el('text', { class: 'numeral', x: px + vx / len * 10, y: py + vy / len * 10 }, nums);
t.textContent = NUMERALS[k];
numEls.push(t);
}
for (let k = 0; k <= 12; k++) el('path', { class: 'hour-line', d: toPath(hourLine(k / 12)) }, lines);
- const curves = [[winter, 'Bruma (winter solstice)'], [0, 'Aequinoctium (equinox)'], [-winter, 'Solstitium (summer solstice)']];
- for (const [d, name] of curves) {
- const c = el('path', { class: 'day-curve', d: toPath(dayCurve(d, 0, 1, 48)) }, lines);
- el('title', {}, c).textContent = name;
+ for (const [key, d] of [['bruma', winter], ['aequinoctium', 0], ['solstitium', -winter]]) {
+ const path = toPath(dayCurve(d, 0, 1, 60));
+ curveEls[key] = el('path', { class: 'day-curve', d: path }, lines);
+ addHit(key, path);
}
+ curveEls.today = $('todayCurve');
+ setActiveCurve(pinnedCurve);
}
// ---- clepsydra ----
- // Water rises at a steady rate through the night; the float carries the figure up the column.
- const TRAVEL = 150, POINTER0 = 200;
- const colMarks = [], colNums = [], colBands = [];
- (function buildClepsydra() {
+ // Water rises at a steady rate, so the hour marks sit at heights proportional to elapsed time.
+ // Nights change length through the year, so each hour line winds around the drum; the drum is
+ // turned daily so today's date faces the pointer. The inflow is set so the longest night fills it.
+ const TRAVEL = 150, POINTER0 = 200, DRUM_X = 284, DRUM_R = 24, DRUM_SPAN = 75 * rad;
+ const MONTHS = ['IAN', 'FEB', 'MAR', 'APR', 'MAI', 'IVN', 'IVL', 'AVG', 'SEP', 'OCT', 'NOV', 'DEC'];
+ const nightFrac = (lat, date) => 1 - romanHourMin(lat, solarDec(date)) * 12 / 1440;
+ const colNums = [], colBands = [];
+ let drumKey = null, maxNight = 1;
+ function buildDrum(lat, today) {
+ const key = lat + '|' + today.toDateString();
+ if (drumKey === key) return;
+ drumKey = key;
const col = $('column');
+ col.replaceChildren();
+ colNums.length = colBands.length = 0;
+ const yearStart = new Date(today.getFullYear(), 0, 1);
+ maxNight = Math.max(...range(0, 365, 365).map(d => nightFrac(lat, new Date(yearStart.getTime() + d * dayMs))));
+ const thetas = range(-DRUM_SPAN, DRUM_SPAN, 30);
+ const dateAt = th => new Date(today.getTime() + th / (2 * Math.PI) * 365.2422 * dayMs);
+ const nights = thetas.map(th => nightFrac(lat, dateAt(th)));
+ const xAt = th => DRUM_X + DRUM_R * Math.sin(th);
+ const yAt = (k, night) => POINTER0 - k / 12 * night / maxNight * TRAVEL;
+ const line = k => thetas.map((th, i) => [xAt(th), yAt(k, nights[i])]);
for (let k = 0; k < 12; k++) {
- const y1 = POINTER0 - k * TRAVEL / 12, y0 = y1 - TRAVEL / 12;
- colBands.push(el('rect', { class: 'band', x: 260, y: y0, width: 48, height: TRAVEL / 12 }, col));
- const t = el('text', { class: 'numeral', x: 284, y: (y0 + y1) / 2 }, col);
+ colBands.push(el('path', { class: 'band', d: toPath([...line(k), ...line(k + 1).reverse()]) + 'Z' }, col));
+ }
+ for (let k = 0; k <= 12; k++) el('path', { class: 'col-line' + (k % 3 === 0 ? ' vigil' : ''), d: toPath(line(k)), fill: 'none' }, col);
+ // month boundaries (Kalends) as they wrap round the drum
+ for (let m = -3; m <= 4; m++) {
+ const kal = new Date(today.getFullYear(), today.getMonth() + m, 1);
+ const th = (kal - today) / dayMs / 365.2422 * 2 * Math.PI;
+ if (Math.abs(th) > DRUM_SPAN * .92) continue;
+ const top = yAt(12, nightFrac(lat, kal));
+ el('line', { class: 'month-line', x1: xAt(th), x2: xAt(th), y1: POINTER0, y2: top }, col);
+ }
+ el('text', { class: 'month-label', x: DRUM_X, y: POINTER0 + 10 }, col).textContent = MONTHS[today.getMonth()];
+ const front = nightFrac(lat, today);
+ for (let k = 0; k < 12; k++) {
+ const y1 = yAt(k, front), y0 = yAt(k + 1, front);
+ const t = el('text', { class: 'numeral', x: DRUM_X, y: (y0 + y1) / 2, 'font-size': Math.max(6, Math.min(11, (y1 - y0) * .85)) }, col);
t.textContent = NUMERALS[k];
colNums.push(t);
}
- for (let k = 0; k <= 12; k++) {
- const y = POINTER0 - k * TRAVEL / 12;
- el('line', { class: 'col-line' + (k % 3 === 0 ? ' vigil' : ''), x1: 260, x2: 308, y1: y, y2: y }, col);
- }
+ }
+ (function buildStars() {
const stars = $('stars');
let seed = 7;
const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
@@ -607,17 +744,56 @@
}
})();
+ // Drips from the orifice, ripples where they land, and flowing supply/overflow streams.
+ let waterY = 380;
+ const NOZZLE = [126, 206];
+ const drops = [], ripples = [];
+ let lastSpawn = 0, lastFrame = 0;
+ function animateWater(t) {
+ requestAnimationFrame(animateWater);
+ if ($('clepsydra').hasAttribute('hidden') || document.hidden) { lastFrame = t; return; }
+ const dt = Math.max(0, Math.min(50, t - (lastFrame || t))) / 1000;
+ lastFrame = t;
+ if (t - lastSpawn > 420) {
+ lastSpawn = t;
+ drops.push({ y: NOZZLE[1], v: 0, node: el('circle', { class: 'drop', cx: NOZZLE[0], cy: NOZZLE[1], r: 2.2 }, $('drops')) });
+ }
+ for (let i = drops.length - 1; i >= 0; i--) {
+ const d = drops[i];
+ d.v += 600 * dt;
+ d.y += d.v * dt;
+ if (d.y >= waterY) {
+ d.node.remove();
+ drops.splice(i, 1);
+ ripples.push({ age: 0, node: el('ellipse', { class: 'ripple', cx: NOZZLE[0], cy: waterY, rx: 1, ry: .5 }, $('drops')) });
+ } else d.node.setAttribute('cy', d.y);
+ }
+ for (let i = ripples.length - 1; i >= 0; i--) {
+ const r = ripples[i];
+ r.age += dt;
+ if (r.age > .5) { r.node.remove(); ripples.splice(i, 1); continue; }
+ r.node.setAttribute('rx', 1 + r.age * 22);
+ r.node.setAttribute('ry', .5 + r.age * 4);
+ r.node.setAttribute('cy', waterY);
+ r.node.setAttribute('opacity', 1 - r.age * 2);
+ }
+ document.querySelectorAll('#clepsydra .stream').forEach(s => s.setAttribute('stroke-dashoffset', (-t / 40) % 8));
+ }
+ requestAnimationFrame(animateWater);
+
function drawDay(now, per, frac, idx) {
$('sundial').toggleAttribute('hidden', false);
$('clepsydra').toggleAttribute('hidden', true);
buildDial(place.lat);
const dec = solarDec(now);
- $('todayCurve').setAttribute('d', toPath(range(0, 1, 48).map(f => dialPoint(place.lat, dec, f))));
- const halfDay = Math.PI * (per.end - per.start) / dayMs;
- const [tx, ty] = dialPoint(place.lat, dec, frac, halfDay);
- const dx = tx - CX, dy = ty - CY, len = Math.hypot(dx, dy) || 1;
- const nx = -dy / len, ny = dx / len;
- $('shadow').setAttribute('d', `M${CX + nx * 2.5},${CY + ny * 2.5} L${tx + nx * .8},${ty + ny * .8} L${tx - nx * .8},${ty - ny * .8} L${CX - nx * 2.5},${CY - ny * 2.5}Z`);
+ const today = toPath(range(0, 1, 60).map(f => dialPoint(place.lat, dec, f)));
+ $('todayCurve').setAttribute('d', today);
+ addHit('today', today);
+ if (activeCurve === 'today') $('curveInfo').innerHTML = curveText('today');
+ const sun = sunVec(place.lat, dec, frac, Math.PI * (per.end - per.start) / dayMs);
+ sun.u = Math.max(0, sun.u);
+ $('shadow').setAttribute('d', toPath(rodShadow(sun)));
+ const [tx, ty] = toScreen(-sun.e, -sun.u);
$('shadow').style.display = $('tip').style.display = '';
$('tip').setAttribute('cx', tx);
$('tip').setAttribute('cy', ty);
@@ -625,14 +801,16 @@
numEls.forEach((n, i) => n.setAttribute('class', 'numeral' + (i === idx ? ' now' : '')));
}
- function drawNight(frac, idx) {
+ function drawNight(now, frac, idx) {
$('sundial').toggleAttribute('hidden', true);
$('clepsydra').toggleAttribute('hidden', false);
- const rise = frac * TRAVEL;
+ $('curveInfo').innerHTML = 'The drum turns once a year; today faces the pointer';
+ buildDrum(place.lat, now);
+ const rise = Math.min(TRAVEL, frac * nightFrac(place.lat, now) / maxNight * TRAVEL);
+ waterY = 380 - rise;
$('float').setAttribute('transform', `translate(0 ${-rise})`);
- $('water').setAttribute('y', 380 - rise);
+ $('water').setAttribute('y', waterY);
$('water').setAttribute('height', 10 + rise);
- $('drip').setAttribute('y2', 380 - rise);
colBands.forEach((b, i) => b.setAttribute('class', 'band' + (i < idx ? ' done' : i === idx ? ' now' : '')));
colNums.forEach((n, i) => n.setAttribute('class', 'numeral' + (i === idx ? ' now' : '')));
}
@@ -696,7 +874,7 @@
document.body.classList.toggle('night', !per.isDay);
if (per.isDay) drawDay(now, per, frac, idx);
- else drawNight(frac, idx);
+ else drawNight(now, frac, idx);
$('bigNumeral').textContent = NUMERALS[idx];
const when = within < 1 / 3 ? 'Early in' : within < 2 / 3 ? 'Midway through' : 'Late in';
@@ -708,7 +886,7 @@
$('latin').textContent = `Hora ${ORDINALS[idx]} Noctis`;
$('phrase').textContent = `${when} the ${ENGLISH[idx]} hour of night · Vigilia ${VIGILIAE[v]}`;
}
- $('dialTitle').textContent = `Hemicyclium sundial showing ${$('latin').textContent}`;
+ $('dialTitle').textContent = `Spherical sundial showing ${$('latin').textContent}`;
const nextAt = new Date(per.start.getTime() + (idx + 1) * hourLen);
$('progLeft').innerHTML = `
${Math.round(within * 100)}% through hour ${NUMERALS[idx]}`;