Celestial Programming : Vertical Sundial

The equations for a vertical sundial are quite similar to those for a horizontal sundial. And the results might look like the dial is just rotated, but the angles are different.

Computation of the angles for the hour lines is fairly simple, I give two methods below. They both produce the same results, but the first method allows the use of the ATAN2 function to ensure θ\theta is in the correct quadrant. The second method is just shorter.

Hour Lines

x=sinHy=cosHcosϕtanθ=xyAlternate:tanθ=tanHcosϕ \begin{align*} x &=\sin H \\ y &=\frac{\cos H}{\cos \phi} \\ \tan \theta &= \frac{x}{y} \\ \\ Alternate: \\ \tan \theta &= \tan H \cos \phi \end{align*}
θ\theta = Line's angle for given hour
HH = Hour angle of the Sun
ϕ\phi = Latitude






120.0°
111.9°
224.4°
338.1°
453.7°
571.1°
690.0°
7108.9°
8126.3°
9141.9°
10155.6°
11168.1°

//Greg Miller (gmiller@gregmiller.net) https://www.celestialprogramming.com/ 2024
//Released as public domain

function getAngles(lat){
    const angles=new Array();
    for(let i=0;i<12;i++){
        const H=i*15*rad; //convert hour from hours to radians
        
        const x=Math.sin(H);
        const y=Math.cos(H)/Math.cos(lat);

        const θ = Math.atan2(x,y);

        angles[i]=θ;
    }
    return angles;
}