Horizontal sundial calculations: Difference between revisions

(Horizontal sundial calculations in various BASIC dialents (BASIC256, True BASIC and Yabasic))
Line 1,188:
 
=={{header|FutureBasic}}==
<lang futurebasic>window 1
include "ConsoleWindow"
 
localdef fn rad2deg( theta as double ) as double = theta * 180 / pi
enddef fn deg2rad( theta as double ) as double = theta * 180pi / pi180
 
local fn deg2rad( theta as double ) as double
end fn = theta * pi / 180
 
local fn SolarHourAngle( latitude as double, longitude as double, meridian as double )
dim as long hour
dim as double hra, hla, timet
dim as Str15CFStringRef ap
 
print "Latitude = "; latitude; chr$(13); "Longitude = "; longitude; chr$(13); "Meridian = "; meridian
print : print "sine of latitude: "; sin(latitude * pi / 180 ); chr$(13); " diff longitude: "; longitude - meridian
print : print "Time", "Sun hour angle", "Dial hour line angle"
for hour = 6 to 18
hra = ( 15 * hour ) - longitude + meridian - 180
hla = fn rad2deg( atn( sin( fn deg2rad( latitude ) ) * tan( fn deg2rad( hra ) )))
if abs( hra ) > 90 then hla = hla + 180 * sgn( hra * latitude )
if hour > 12 then timet = hour - 12 : ap = @" a.m." else timet = hour : ap = @" p.m."
print using "##"; timet; ap, using "####.##"; hra, using "####.###"; hla
next hour
end fn
 
fn SolarHourAngle( -4.95, -150.5, -150.0 )
 
</lang>
HandleEvents</lang>
 
Output:
416

edits