summaryrefslogtreecommitdiffstats
path: root/movement/lib/astrolib/astrolib.h
diff options
context:
space:
mode:
authorjoeycastillo <joeycastillo@utexas.edu>2022-03-04 14:52:49 -0600
committerGitHub <noreply@github.com>2022-03-04 14:52:49 -0600
commitccdf08da876d2c66bbc54cc246443676c4f9bf2e (patch)
tree77473da9df40f9b1f7cec5f8bd03c1b52c26b8e7 /movement/lib/astrolib/astrolib.h
parentea988208e10dbcf62eff65522ec9f92231d880e9 (diff)
downloadSensor-Watch-ccdf08da876d2c66bbc54cc246443676c4f9bf2e.tar.gz
Sensor-Watch-ccdf08da876d2c66bbc54cc246443676c4f9bf2e.tar.bz2
Sensor-Watch-ccdf08da876d2c66bbc54cc246443676c4f9bf2e.zip
Movement: Astronomy and Orrery watch faces (#55)
Diffstat (limited to 'movement/lib/astrolib/astrolib.h')
-rw-r--r--movement/lib/astrolib/astrolib.h87
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_