Horizontal sundial calculations: Difference between revisions

(→‎{{header|AutoHotkey}}: AutoHotkey example added)
Line 653:
5.0 75.5 -18.451
6.0 90.5 84.225</pre>
 
=={{header|Icon}} and {{header|Unicon}}==
<lang Icon>procedure main()
PrintSundial(-4.95, -150.5, -150);
end
 
procedure PrintSundial(lat, lng, mer )
write("latitude: ", lat,
"\nlongitude: ", lng,
"\nlegal meridian: ", mer)
slat := sin(dtor(lat))
write("sine of latitude: ",slat,
"\ndiff longitude: ", lng-mer)
write("\nHour, sun hour angle, dial hour line angle from 6am to 6pm")
 
every h := -6 to 6 do {
hraRad := dtor(hra := 15 * h - (lng - mer))
hla :=rtod(atan(sin(hraRad)*slat, cos(hraRad)))
write("HR=",
right(if h <= 0 then 12+h else h,2),
if h < 0 then "am" else "pm",
" HRA=",hra,", HLA=",hla)
}
end</lang>
 
Output:<pre>latitude: -4.95
longitude: -150.5
legal meridian: -150
sine of latitude: -0.08628636579792337
diff longitude: -0.5
 
Hour, sun hour angle, dial hour line angle from 6am to 6pm
HR= 6am HRA=-89.5, HLA=84.22483260136025
HR= 7am HRA=-74.5, HLA=17.2829335027853
HR= 8am HRA=-59.5, HLA=8.333711921468083
HR= 9am HRA=-44.5, HLA=4.846708924373172
HR=10am HRA=-29.5, HLA=2.794873809318642
HR=11am HRA=-14.5, HLA=1.278352980919063
HR=12pm HRA=0.5, HLA=-0.04314426995813971
HR= 1pm HRA=15.5, HLA=-1.370787843187052
HR= 2pm HRA=30.5, HLA=-2.909643210076617
HR= 3pm HRA=45.5, HLA=-5.018023174356126
HR= 4pm HRA=60.5, HLA=-8.671396957302381
HR= 5pm HRA=75.5, HLA=-18.45099922256532
HR= 6pm HRA=90.5, HLA=-95.77516739863968</pre>
 
=={{header|J}}==
Anonymous user