mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-01-04 13:37:44 -05:00
Moved the following constant definitions from astronomy.c to astronomy.h, so external code can use them: DEG2RAD RAD2DEG KM_PER_AU My custom doxygen-to-markdown translator (hydrogen.js) now emits markdown for the above constants. Eliminated the obsolete constants MIN_YEAR and MAX_YEAR. Astronomy Engine is no longer limited to calculating planets within that range of years. Fixed a couple of minor documentation issues in the C code. Started work on a new function Astronomy_ObserverVector, but it is just a stub for now.
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/*
|
|
seasons.c - Don Cross - 2019-06-16
|
|
|
|
Example C program for Astronomy Engine:
|
|
https://github.com/cosinekitty/astronomy
|
|
|
|
This program demonstrates how to calculate the
|
|
equinoxes and solstices for a year.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "astro_demo_common.h"
|
|
|
|
void Print(const char *name, astro_time_t time)
|
|
{
|
|
printf("%-17s : ", name);
|
|
PrintTime(time);
|
|
printf("\n");
|
|
}
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
int year;
|
|
astro_seasons_t seasons;
|
|
|
|
if (argc != 2)
|
|
{
|
|
fprintf(stderr, "USAGE: seasons year\n");
|
|
return 1;
|
|
}
|
|
|
|
if (1 != sscanf(argv[1], "%d", &year))
|
|
{
|
|
fprintf(stderr, "ERROR: Invalid year '%s'.\n", argv[1]);
|
|
return 1;
|
|
}
|
|
|
|
seasons = Astronomy_Seasons(year);
|
|
if (seasons.status != ASTRO_SUCCESS)
|
|
{
|
|
fprintf(stderr, "ERROR: Astronomy_Seasons() returned %d\n", seasons.status);
|
|
return 1;
|
|
}
|
|
|
|
Print("March equinox", seasons.mar_equinox);
|
|
Print("June solstice", seasons.jun_solstice);
|
|
Print("September equinox", seasons.sep_equinox);
|
|
Print("December solstice", seasons.dec_solstice);
|
|
|
|
return 0;
|
|
}
|