RosettaCodeData/Task/Horizontal-sundial-calculations/XBasic/horizontal-sundial-calculations.basic
2023-07-01 13:44:08 -04:00

27 lines
898 B
Text

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