This is a C++ program that calculates the position of a star in the sky for a given geographic location (latitude and longitude). It provides the altitude and azimuth of the star (horizontal coordinate system), which are essential for astronomical observations. The program uses Greenwich Mean Time (GMT) and various astronomical formulas to perform these calculations.
Note: This project was initially designed to run on Windows with the location near San Diego, CA.
To compile and run this program, you need a C++ compiler. If you don't have one installed, you can download and install GCC.
You can compile the program using the provided Makefile. Simply run the following command in your terminal:
make
After compilation, you can run the program with the following command:
./main.exe [latitude] [longitude] [rightAscension] [declination]
Where latitude and longitude are the coordinates of the observer and the rightAscension and declination are the equatorial coordinates of the star you want to locate.
If you run the program without any arguments, it will use the default values for latitude, longitude, right ascension, and declination that are in the source code. However, you can specify these values as command-line arguments to calculate the star's position for a specific location and star.
The program performs the following steps:
- Obtains Greenwich Mean Time (GMT) using the system time.
- Optionally, accepts latitude, longitude, right ascension, and declination from the command line.
- Calculates the Julian Date based on GMT.
- Calculates the Greenwich Apparent Sidereal Time (GAST) based on the Julian Date.
- Calculates the Local Hour Angle (LHA) of the star.
- Determines the altitude and azimuth of the star using the calculated values.
The program provides the following results:
- Latitude of the observer.
- Longitude of the observer.
- Right Ascension of the star.
- Declination of the star.
- GMT (Greenwich Mean Time).
- Local time adjusted for the observer's longitude.
- Julian Date (UT1).
- Julian Date (TT) approximation.
- Greenwich Apparent Sidereal Time (GAST).
- Local Hour Angle (LHA) in degrees.
- Altitude of the star in degrees.
- Azimuth of the star in degrees.
The project also includes a tester file which can run a unit test for either the moon or all the planets by web scraping the actual values. Make sure to edit the latitude and longitude values in the main function.
This project is licensed under the MIT License - see the LICENSE file for details.
Created in collaboration by Andrew Collins and Kanvar Soin.
This program is based on astronomical algorithms and formulas that can be found from the following sources:
- The Astronomical Almanac
- Navy - Astronomical Applications Department