How to resolve the algorithm Horizontal sundial calculations step by step in the ALGOL 68 programming language
How to resolve the algorithm Horizontal sundial calculations step by step in the ALGOL 68 programming language
Table of Contents
Problem Statement
Create a program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an operator entered location.
For example, the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W of Jules Verne's Lincoln Island, aka Ernest Legouve Reef), with a legal meridian of 150°W. (Note: the "meridian" is approximately the same concept as the "longitude" - the distinction is that the meridian is used to determine when it is "noon" for official purposes. This will typically be slightly different from when the sun appears at its highest location, because of the structure of time zones. For most, but not all, time zones (hour wide zones with hour zero centred on Greenwich), the legal meridian will be an even multiple of 15 degrees.) Wikipedia: A sundial is a device that measures time by the position of the Sun. In common designs such as the horizontal sundial, the sun casts a shadow from its style (also called its Gnomon, a thin rod or a sharp, straight edge) onto a flat surface marked with lines indicating the hours of the day (also called the dial face or dial plate). As the sun moves across the sky, the shadow-edge progressively aligns with different hour-lines on the plate. Such designs rely on the style being aligned with the axis of the Earth's rotation. Hence, if such a sundial is to tell the correct time, the style must point towards true north (not the north or south magnetic pole) and the style's angle with horizontal must equal the sundial's geographical latitude.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Horizontal sundial calculations step by step in the ALGOL 68 programming language
Source code in the algol programming language
BEGIN
REAL lat, slat, lng, ref;
print ( "Enter latitude => " ); read (lat);
print ( "Enter longitude => " ); read (lng);
print ( "Enter legal meridian => " ); read (ref);
new line(stand out);
slat := sin(lat*2*pi/360) ;
print ( (" sine of latitude: ", float(slat,8,2,1), new line ) );
print ( (" diff longitude: ", fixed((lng - ref),0,3), new line, new line ) );
print ( ("Hour, sun hour angle, dial hour line angle from 6am to 6pm", new line ));
FOR h FROM -6 TO 6
DO
REAL hra , hla ; # define hour angle and hour line angle #
hra := 15 * h ; # hour angle is 15 times the hour #
hra := hra - (lng - ref); # but correct for longitude difference #
hla := arc tan ( slat * tan(hra*2*pi/360) ) * 360 / ( 2*pi) ;
# page 132 of a68gdoc.pdf documentationfile #
print ("HR="+whole(h,3)+"; HRA="+fixed(hra,8,3)+"; HLA="+fixed(hla,8,3));
new line(stand out)
OD
END
You may also check:How to resolve the algorithm Pseudo-random numbers/Xorshift star step by step in the Python programming language
You may also check:How to resolve the algorithm Even or odd step by step in the sed programming language
You may also check:How to resolve the algorithm Ormiston triples step by step in the Wren programming language
You may also check:How to resolve the algorithm Topic variable step by step in the Nim programming language
You may also check:How to resolve the algorithm Anagrams/Deranged anagrams step by step in the jq programming language