Horizontal sundial calculations: Difference between revisions

Content added Content deleted
(Added PicoLisp)
Line 70: Line 70:
HR= +6; HRA= +90.500; HLA= +84.225
HR= +6; HRA= +90.500; HLA= +84.225
</pre>
</pre>

=={{header|PicoLisp}}==
{{trans|ALGOL 68}}
<lang PicoLisp>(load "@lib/math.l")

(de prompt (Str . Arg)
(prin Str " => ")
(set (car Arg) (in NIL (read))) )

(use (Lat Lng Ref)
(prompt "Enter latitude " Lat)
(prompt "Enter longitude " Lng)
(prompt "Enter legal meridian" Ref)
(prinl)
(let Slat (sin (*/ Lat pi 180.0))
(prinl " sine of latitude: " (round Slat 3))
(prinl " diff longitude: " (round (- Lng Ref) 3))
(prinl)
(prinl "Hour, sun hour angle, dial hour line angle from 6am to 6pm")
(for H (range -6 6)
(let Hra (- (* 15.0 H) (- Lng Ref))
(let Hla (*/ (atan (*/ Slat (tan (*/ Hra pi 180.0)) 1.0)) 180.0 pi)
(prinl
"HR="
(align 3 H)
"; HRA="
(align 8 (round Hra 3))
"; HLA="
(align 8 (round Hla 3)) ) ) ) ) ) )</lang>
Output:
<pre>Enter latitude => -4.95
Enter longitude => -150.5
Enter legal meridian => -150. # Don't omit the '.' here

sine of latitude: -0.086
diff longitude: -0.500

Hour, sun hour angle, dial hour line angle from 6am to 6pm
HR= -6; HRA= -89.500; HLA= 84.225
HR= -5; HRA= -74.500; HLA= 17.283
HR= -4; HRA= -59.500; HLA= 8.334
HR= -3; HRA= -44.500; HLA= 4.847
HR= -2; HRA= -29.500; HLA= 2.795
HR= -1; HRA= -14.500; HLA= 1.278
HR= 0; HRA= 0.500; HLA= -0.043
HR= 1; HRA= 15.500; HLA= -1.371
HR= 2; HRA= 30.500; HLA= -2.910
HR= 3; HRA= 45.500; HLA= -5.018
HR= 4; HRA= 60.500; HLA= -8.671
HR= 5; HRA= 75.500; HLA= -18.451
HR= 6; HRA= 90.500; HLA= 84.225</pre>