Horizontal sundial calculations: Difference between revisions

(→‎{{header|Liberty BASIC}}: Code formatting; output)
Line 2,992:
o_ft:
db "HR= %3d; ",9," HRA=%7.3f; ",9," HLA= %7.3f", 10, 0</lang>
 
=={{header|XBasic}}==
{{trans|ALGOL-68}}
{{works with|Windows XBasic}}
<lang xbasic>
PROGRAM "sundial"
VERSION "0.0001"
 
IMPORT "xma"
 
DECLARE FUNCTION Entry()
 
FUNCTION Entry()
lat! = SINGLE(INLINE$("Enter latitude => "))
lng! = SINGLE(INLINE$("Enter longitude => "))
ref! = SINGLE(INLINE$("Enter legal meridian => "))
PRINT
slat! = SIN(lat! * $$PI / 180.0)
PRINT " sine of latitude: "; FORMAT$("#.##^^^^", slat!)
PRINT " diff longitude: "; FORMAT$("#.###", lng! - ref!)
PRINT
PRINT "Hour, sun hour angle, dial hour line angle from 6am to 6pm"
FOR hour@ = -6 TO 6
hourAngle! = 15 * hour@
hourAngle! = hourAngle! - (lng! - ref!) ' correct for longitude difference
hourLineAngle! = ATAN(slat! * TAN(hourAngle! * $$PI / 180.0)) * 180.0 / $$PI
PRINT "HR="; FORMAT$("###", hour@);
PRINT "; HRA="; FORMAT$("####.###", hourAngle!);
PRINT "; HLA="; FORMAT$("####.###", hourLineAngle!)
NEXT hour@
END FUNCTION
END PROGRAM
</lang>
{{out}}
<pre>
Enter latitude => -4.95
Enter longitude => -150.5
Enter legal meridian => -150
 
sine of latitude: -8.63E-02
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>
 
=={{header|XPL0}}==
Anonymous user