make
echo "YYYY/MM/DD" | ./morgan1
where YYYY
is the four digit year, MM
is the two digit month and DD
is two
digit day of the month. The arrow keys control the shifting of the date as
follows:
./try.sh
Use the same keys as described above to change the dates each time the program window is in focus.
To verify the output, try echoing the date of an evening with a clear sky. Use binoculars and/or telescope as needed. In some cases you may need to wait for a better time of the evening. In a few cases, such as the South Pole in the summer, you may need to move to a different observing site.
It displays the position of the 8 planets of the solar system around the Sun. The date given in the command line is in the format YYYY/MM/DD (year, month and day). The direction keys can be used to move in time :
It handles correctly all leap years and the switch between Julian calendar and Gregorian calendar (10 days missing between 1582/10/04 and 1582/10/15).
The scale is logarithmic to be able to display the 8 planets without having Mercury, Venus, Earth and Mars squeezed around the Sun.
The size is not proportional either.
It also displays the position of 2 famous comets during their last approach:
math.h
functions).main()
function with some for
loops.for
loop.With gcc 4.7.2 on Linux Ubuntu 12.10:
morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
With clang 3.1 on Linux Ubuntu 12.10 :
morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]
This is due to most of the parentheses and braces being removed when unnecessary.
To verify the display, you can look at one of these programs : * xephem : https://web.archive.org/web/20130310133219/http://www.clearskyinstitute.com/xephem/ * homeplanet : https://www.fourmilab.ch/homeplanet/ * https://www.theplanetstoday.com