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

29 lines
1.2 KiB
Text

TextWindow.Write("Enter latitude => ")
lat = TextWindow.ReadNumber()
TextWindow.Write("Enter longitude => ")
lng = TextWindow.ReadNumber()
TextWindow.Write("Enter legal meridian => ")
ref = TextWindow.ReadNumber()
sLat = Math.Sin(Math.GetRadians(lat))
TextWindow.WriteLine("")
TextWindow.Write(" sine of latitude: ")
TextWindow.WriteLine(Math.Round(sLat * 10000) / 10000)
TextWindow.Write(" diff longitude: ")
TextWindow.WriteLine(lng - ref)
TextWindow.WriteLine("")
TextWindow.WriteLine("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 = math.GetDegrees(Math.ArcTan(sLat * Math.Tan(Math.GetRadians(hourAngle))))
TextWindow.Write("HR=")
TextWindow.CursorLeft = 3 + (3 - Text.GetLength(hour))
TextWindow.Write(hour)
TextWindow.Write("; HRA=")
TextWindow.CursorLeft = 12 + (6 - Text.GetLength(hourAngle))
TextWindow.Write(hourAngle)
TextWindow.Write("; HLA=")
TextWindow.CursorLeft = 24 + (4 - Text.GetLength(Math.Floor(hourLineAngle)))
TextWindow.Write(Math.Round(hourLineAngle * 1000) / 1000)
TextWindow.WriteLine("")
EndFor