diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2022-04-06 14:56:18 -0400 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2022-04-06 14:56:18 -0400 |
commit | 4e89d70f999c8766a9cebe0700e1d6ea9d7bbfcf (patch) | |
tree | 2baca9564649801aef3be5dc4600284900d528d6 /movement/lib/astrolib/astrolib.h | |
parent | 2cba47996ed08c83b7c9b2ba521b68fb8a62f666 (diff) | |
parent | 1ec1f2e4207405d55c34c936e2c458cb4a7e8806 (diff) | |
download | Sensor-Watch-4e89d70f999c8766a9cebe0700e1d6ea9d7bbfcf.tar.gz Sensor-Watch-4e89d70f999c8766a9cebe0700e1d6ea9d7bbfcf.tar.bz2 Sensor-Watch-4e89d70f999c8766a9cebe0700e1d6ea9d7bbfcf.zip |
Merge branch 'main' of github.com:joeycastillo/Sensor-Watch into mars-clock
Diffstat (limited to 'movement/lib/astrolib/astrolib.h')
-rw-r--r-- | movement/lib/astrolib/astrolib.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/movement/lib/astrolib/astrolib.h b/movement/lib/astrolib/astrolib.h new file mode 100644 index 00000000..2523ead3 --- /dev/null +++ b/movement/lib/astrolib/astrolib.h @@ -0,0 +1,87 @@ +/* + * Partial C port of Greg Miller's public domain astro library (gmiller@gregmiller.net) 2019 + * https://github.com/gmiller123456/astrogreg + * + * Ported by Joey Castillo for Sensor Watch + * https://github.com/joeycastillo/Sensor-Watch/ + * + * Public Domain + * + * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef ASTROLIB_H_ +#define ASTROLIB_H_ + +typedef enum { + ASTRO_BODY_SUN = 0, + ASTRO_BODY_MERCURY, + ASTRO_BODY_VENUS, + ASTRO_BODY_EARTH, + ASTRO_BODY_MARS, + ASTRO_BODY_JUPITER, + ASTRO_BODY_SATURN, + ASTRO_BODY_URANUS, + ASTRO_BODY_NEPTUNE, + ASTRO_BODY_EMB, + ASTRO_BODY_MOON +} astro_body_t; + +typedef struct { + double elements[3][3]; +} astro_matrix_t; + +typedef struct { + double x; + double y; + double z; +} astro_cartesian_coordinates_t; + +typedef struct { + double right_ascension; + double declination; + double distance; +} astro_equatorial_coordinates_t; + +typedef struct { + double altitude; + double azimuth; +} astro_horizontal_coordinates_t; + +typedef struct { + int16_t degrees; + uint8_t minutes; + uint8_t seconds; // you may want this to be a float, watch just can't display any more digits +} astro_angle_dms_t; + +typedef struct { + uint8_t hours; + uint8_t minutes; + uint8_t seconds; // you may want this to be a float, watch just can't display any more digits +} astro_angle_hms_t; + +// Convert a date to a julian date. Must be in UTC+0 time zone! +double astro_convert_date_to_julian_date(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second); + +// Converts a Julan Date to Julian Millenia since J2000, which is what VSOP87 expects as input. +double astro_convert_jd_to_julian_millenia_since_j2000(double jd); + +// Get right ascension / declination for a given body in the list above. +astro_equatorial_coordinates_t astro_get_ra_dec(double jd, astro_body_t bodyNum, double lat, double lon, bool calculate_precession); + +// Convert right ascension / declination to altitude/azimuth for a given location. +astro_horizontal_coordinates_t astro_ra_dec_to_alt_az(double jd, double lat, double lon, double ra, double dec); + +// these are self-explanatory +double astro_degrees_to_radians(double degrees); +double astro_radians_to_degrees(double radians); +astro_angle_dms_t astro_radians_to_dms(double radians); +astro_angle_hms_t astro_radians_to_hms(double radians); + +#endif // ASTROLIB_H_ |