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 is in the correct quadrant. The second method is just shorter.
12 | 0.0° |
1 | 11.9° |
2 | 24.4° |
3 | 38.1° |
4 | 53.7° |
5 | 71.1° |
6 | 90.0° |
7 | 108.9° |
8 | 126.3° |
9 | 141.9° |
10 | 155.6° |
11 | 168.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;
}