THE METHOD

The Mathematics of the Sundial

Every formula the sundial uses, with its sources

The sundial answers one question for any moment: does direct sun reach the monument? It works it out in three steps: where the sun is in the sky, whether a building stands in the way, and where that moment falls on the dial. Angles are in degrees unless noted.

ITime

A clock time in San Francisco is converted to Universal Time using the IANA time zone America/Los_Angeles, which handles daylight saving time. That instant becomes a Julian day JDJD and Julian centuries TT since the year 2000:

JD=tUnix86 400 000 ms+2 440 587.5,T=JD−2 451 54536 525JD = \frac{t_{\text{Unix}}}{86\,400\,000\ \text{ms}} + 2\,440\,587.5, \qquad T = \frac{JD - 2\,451\,545}{36\,525}

IIWhere the sun is

The sun's position follows the NOAA solar position equations, which are derived from Jean Meeus's Astronomical Algorithms. First, the sun's geometric mean longitude L0L_0, mean anomaly MM and the eccentricity ee of Earth's orbit:

L0=280.46646+36 000.76983 T+0.0003032 T2(mod360)M=357.52911+35 999.05029 T−0.0001537 T2e=0.016708634−0.000042037 T−0.0000001267 T2\begin{aligned} L_0 &= 280.46646 + 36\,000.76983\,T + 0.0003032\,T^2 \pmod{360} \\ M &= 357.52911 + 35\,999.05029\,T - 0.0001537\,T^2 \\ e &= 0.016708634 - 0.000042037\,T - 0.0000001267\,T^2 \end{aligned}

The equation of the center CC gives the sun's true longitude, corrected to its apparent longitude λ\lambda for nutation:

C=(1.914602−0.004817 T−0.000014 T2)sin⁡M+(0.019993−0.000101 T)sin⁡2M+0.000289sin⁡3MΩ=125.04−1934.136 Tλ=L0+C−0.00569−0.00478sin⁡Ω\begin{aligned} C &= (1.914602 - 0.004817\,T - 0.000014\,T^2)\sin M \\ &\quad + (0.019993 - 0.000101\,T)\sin 2M + 0.000289\sin 3M \\ \Omega &= 125.04 - 1934.136\,T \\ \lambda &= L_0 + C - 0.00569 - 0.00478\sin\Omega \end{aligned}

The tilt of Earth's axis (obliquity) ε\varepsilon gives the sun's declination δ\delta:

ε0=23∘ 26′ (21.448−46.815 T−0.00059 T2+0.001813 T3)′′ε=ε0+0.00256cos⁡Ωδ=arcsin⁡ ⁣(sin⁡ε sin⁡λ)\begin{aligned} \varepsilon_0 &= 23^\circ\,26'\,\bigl(21.448 - 46.815\,T - 0.00059\,T^2 + 0.001813\,T^3\bigr)'' \\ \varepsilon &= \varepsilon_0 + 0.00256\cos\Omega \\ \delta &= \arcsin\!\left(\sin\varepsilon\,\sin\lambda\right) \end{aligned}

The equation of time EE, in minutes, is how far the sun runs ahead of or behind the clock over the year, with y=tan⁡2(ε/2)y = \tan^2(\varepsilon/2):

E=4⋅180π[ ysin⁡2L0−2esin⁡M+4eysin⁡Mcos⁡2L0−12y2sin⁡4L0−54e2sin⁡2M ]\begin{aligned} E = 4\cdot\tfrac{180}{\pi}\bigl[\, & y\sin 2L_0 - 2e\sin M + 4ey\sin M\cos 2L_0 \\ & - \tfrac12 y^2\sin 4L_0 - \tfrac54 e^2\sin 2M \,\bigr] \end{aligned}

True solar time tst_s (minutes) and the hour angle HH follow from the clock time in UTC minutes tUTCt_{\text{UTC}} and the monument's longitude ℓ=−122.3992∘\ell = -122.3992^\circ:

ts=(tUTC+E+4ℓ) mod 1440,H=ts4−180t_s = \left(t_{\text{UTC}} + E + 4\ell\right) \bmod 1440, \qquad H = \frac{t_s}{4} - 180

With the monument's latitude φ=37.7912∘\varphi = 37.7912^\circ, the sun's altitude hh above the horizon and its azimuth AA (degrees clockwise from north) are:

cos⁡Z=sin⁡φsin⁡δ+cos⁡φcos⁡δcos⁡H,h0=90∘−ZA=atan2⁡ ⁣(sin⁡H, cos⁡Hsin⁡φ−tan⁡δcos⁡φ)+180∘\begin{aligned} \cos Z &= \sin\varphi\sin\delta + \cos\varphi\cos\delta\cos H, \qquad h_0 = 90^\circ - Z \\ A &= \operatorname{atan2}\!\bigl(\sin H,\ \cos H\sin\varphi - \tan\delta\cos\varphi\bigr) + 180^\circ \end{aligned}

Finally, atmospheric refraction lifts the sun slightly near the horizon. In arcseconds, added to h0h_0:

R={58.1tan⁡h0−0.07tan⁡3h0+0.000086tan⁡5h0h0>5∘1735−518.2 h0+103.4 h02−12.79 h03+0.711 h04−0.575∘<h0≤5∘h=h0+R3600R = \begin{cases} \dfrac{58.1}{\tan h_0} - \dfrac{0.07}{\tan^3 h_0} + \dfrac{0.000086}{\tan^5 h_0} & h_0 > 5^\circ \\[1.2ex] 1735 - 518.2\,h_0 + 103.4\,h_0^2 - 12.79\,h_0^3 + 0.711\,h_0^4 & -0.575^\circ < h_0 \le 5^\circ \end{cases} \qquad h = h_0 + \frac{R}{3600}

The sun is up when h>0h > 0.

IIIThe towers

A building at latitude φb\varphi_b and longitude ℓb\ell_b is placed in meters east (xx) and north (yy) of the monument, which is accurate to well under a meter over the few hundred meters involved:

x=(ℓb−ℓ)⋅111 320 m⋅cos⁡φ,y=(φb−φ)⋅111 320 mx = (\ell_b - \ell)\cdot 111\,320\ \text{m}\cdot\cos\varphi, \qquad y = (\varphi_b - \varphi)\cdot 111\,320\ \text{m}

About 65 downtown towers within roughly 700 m are modeled as rectangular boxes, each with its published height HbH_b, its location, and an estimated footprint. Boxes south of Market Street, where xcos⁡50∘−ysin⁡50∘>0x\cos 50^\circ - y\sin 50^\circ > 0, are turned 45° to follow the South of Market street grid.

IVSun or shade

From a seated person's eye height e=1.2 me = 1.2\ \text{m} at the monument, a line is traced along the ground toward the sun, in the direction d=(sin⁡A, cos⁡A)\mathbf d = (\sin A,\ \cos A). For each box, the distance tbt_b at which the line first enters its footprint is found with the slab method. The line rises as it goes, so it is lowest where it enters, and the building blocks the sun exactly when its roof is above the line there:

shade  ⟺  ∃ b: Hb−e>tbtan⁡h\text{shade} \iff \exists\, b:\ H_b - e > t_b \tan h

This is checked every two minutes of the day, and consecutive sunny moments form the brass-lit windows. The building that ends each window is the nearest one that blocks the sun just after it.

VThe dial

The page draws a horizontal sundial set for φ\varphi. Its gnomon rises at angle φ\varphi and points north, and the shadow of its edge falls along the hour line at angle θ\theta from the noon line for hour angle HH:

tan⁡θ=sin⁡φ tan⁡H⟹θ=atan2⁡ ⁣(sin⁡φsin⁡H, cos⁡H)\tan\theta = \sin\varphi\,\tan H \quad\Longrightarrow\quad \theta = \operatorname{atan2}\!\bigl(\sin\varphi\sin H,\ \cos H\bigr)

Because the hour lines come from the real sun, they're labeled with clock times, and with daylight saving time the sun crosses the noon line at about 12:56 pm. The gnomon's shadow tip is the point where the sun's rays through the top of the gnomon, at height Ltan⁡φL\tan\varphi, meet the plate, using the sun vector s=(sin⁡Acos⁡h, cos⁡Acos⁡h, sin⁡h)\mathbf s = (\sin A\cos h,\ \cos A\cos h,\ \sin h).

VIClouds and fog

The times above assume a clear sky. An hour counts as possibly cloudy or foggy when the Open-Meteo hourly forecast gives total cloud cover of at least 60% or low cloud of at least 70%. Those hours get the patina arc outside the dial, and while the dial shows one of them, fog drifts over it.

VIIAccuracy

The NOAA equations place the sun to within about one arcminute (1/60 of a degree). The larger uncertainty is the buildings: footprints are estimates, towers under about 87 m aren't included, and trees and awnings aren't modeled. Two days of readings in the plaza (October 14 and 19, 2026) agreed with the model to within about 10 minutes when the sun arrived, within 6 minutes when the plaza was half in sun, and within about 15 minutes when the last sun left. A version built from the city's measured building outlines fit worse, putting the midday shadow about half an hour early, so the simpler box model stays.

VIIISources

  1. NOAA Global Monitoring Laboratory, Solar Calculation Details and NOAA Solar Calculator: the solar position and refraction formulas in sections I–II.
  2. Jean Meeus, Astronomical Algorithms, 2nd ed. (Willmann-Bell, 1998): the source of the NOAA equations.
  3. Albert E. Waugh, Sundials: Their Theory and Construction (Dover, 1973): the horizontal dial and its hour lines.
  4. Timothy L. Kay and James T. Kajiya, “Ray Tracing Complex Scenes,” SIGGRAPH '86: the slab method for a line entering a box.
  5. Building heights and locations: Wikipedia, List of tallest buildings in San Francisco.
  6. Monument location: Wikipedia, Mechanics Monument; confirmed against OpenStreetMap.
  7. Time zones: the IANA Time Zone Database, through the browser's Intl API.
  8. Cloud forecast: Open-Meteo, hourly cloud_cover and cloud_cover_low (CC BY 4.0).

← Back to the sundial