File indexing completed on 2025-01-05 03:58:39
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2014 Gerhard Holtkamp 0004 // 0005 0006 #if !defined(__astrolib_h) 0007 #define __astrolib_h 0008 0009 #include "attlib.h" 0010 #include "digikam_export.h" 0011 0012 /*********************************************************************** 0013 Definitions of Astrolib Functions 0014 0015 0016 License: GNU LGPL Version 2+ 0017 0018 Author: Gerhard HOLTKAMP 14-JAN-2012 0019 ***********************************************************************/ 0020 0021 DIGIKAM_EXPORT double ddd (int d, int m, double s); // deg, min, sec -> decimal degrees 0022 DIGIKAM_EXPORT void dms (double dd, int &d, int &m, double &s); // dec deg -> deg, min, sec 0023 DIGIKAM_EXPORT double mjd (int day, int month, int year, double hour); // modified Julian date 0024 DIGIKAM_EXPORT double julcent (double mjuld); // Julian centuries since 2000.0 0025 DIGIKAM_EXPORT void caldat (double mjd, int &day, int &month, int &year, double &hour); 0026 DIGIKAM_EXPORT double DefTdUt (int yr); // default value for TDT - UT in seconds 0027 DIGIKAM_EXPORT double lsidtim (double jd, double lambda, double ep2); // Sidereal Time 0028 0029 DIGIKAM_EXPORT double eps (double t); // obliquity of ecliptic 0030 DIGIKAM_EXPORT Vec3 eclequ (double t, Vec3& r1); // ecliptic -> equatorial 0031 DIGIKAM_EXPORT Vec3 equecl (double t, Vec3& r1); // equatorial -> ecliptic 0032 DIGIKAM_EXPORT Mat3 pmatecl (double t1, double t2); // ecl. precession 0033 DIGIKAM_EXPORT Mat3 pmatequ (double t1, double t2); // equ. precession 0034 DIGIKAM_EXPORT Mat3 nutmat (double t, double& ep2, bool hipr = false); // nutation (equatorial) 0035 DIGIKAM_EXPORT Mat3 nutecl (double t, double& ep2); // nutation matrix (ecliptic) 0036 DIGIKAM_EXPORT Mat3 PoleMx (double xp, double yp); // Polar motion matrix 0037 DIGIKAM_EXPORT Vec3 aberrat (double t, Vec3& ve); // aberration 0038 0039 DIGIKAM_EXPORT Vec3 GeoPos (double jd, double ep2, double lat, double lng, double ht); 0040 DIGIKAM_EXPORT Vec3 GeoPos (double jd, double ep2, double lat, double lng, double ht, 0041 double xp, double yp); 0042 DIGIKAM_EXPORT Vec3 EquHor (double jd, double ep2, double lat, double lng, Vec3 r); 0043 DIGIKAM_EXPORT Vec3 HorEqu (double jd, double ep2, double lat, double lng, Vec3 r); 0044 DIGIKAM_EXPORT void AppPos (double jd, double ep2, double lat, double lng, double ht, 0045 int solsys, const Vec3& r, double& azim, double& elev, double& dist); 0046 DIGIKAM_EXPORT void AppRADec (double jd, double ep2, double lat, double lng, 0047 double azim, double elev, double& ra, double& dec); 0048 DIGIKAM_EXPORT double Refract (double h, double p = 1015.0, double t = 15.0); // refraction 0049 0050 DIGIKAM_EXPORT double eccanom (double man, double ecc); // eccentric anomaly 0051 DIGIKAM_EXPORT double hypanom (double mh, double ecc); // hyperbolic anomaly 0052 DIGIKAM_EXPORT void ellip (double gm, double t0, double t, double a, double ecc, 0053 double m0, Vec3& r1, Vec3& v1); // elliptic state vector 0054 DIGIKAM_EXPORT void hyperb (double gm, double t0, double t, double a, double ecc, 0055 Vec3& r1, Vec3& v1); // hyperbolic state vector 0056 DIGIKAM_EXPORT void parab (double gm, double t0, double t, double q, double ecc, 0057 Vec3& r1, Vec3& v1); // elliptic state vector 0058 DIGIKAM_EXPORT void kepler (double gm, double t0, double t, double m0, double a, double ecc, 0059 double ran, double aper, double inc, Vec3& r1, Vec3& v1); 0060 DIGIKAM_EXPORT void oscelm (double gm, double t, Vec3& r1, Vec3& v1, 0061 double& t0, double& m0, double& a, double& ecc, 0062 double& ran, double& aper, double& inc); 0063 0064 DIGIKAM_EXPORT Vec3 QuickSun (double t); // low precision position of the Sun at time t 0065 0066 class DIGIKAM_EXPORT Sun200 // Calculating the Sun in epoch J2000.0 coordinates 0067 { 0068 public: 0069 Sun200(); 0070 Vec3 position (double t); // position of the Sun 0071 void state (double t, Vec3& rs, Vec3& vs); // State vector of the Sun 0072 0073 private: 0074 double c3[9], s3[9]; 0075 double c[9], s[9]; 0076 double m2, m3, m4, m5, m6; 0077 double d, a, uu, tt; 0078 double cl, sl, cb, sb; 0079 double u, v, dl, dr, db; 0080 void addthe (double c1, double s1, double c2, double s2, 0081 double& cc, double& ss); 0082 void term (int i1, int i, int it, double dlc, double dls, double drc, 0083 double drs, double dbc, double dbs); 0084 void pertven(); 0085 void pertmar(); 0086 void pertjup(); 0087 void pertsat(); 0088 void pertmoo(); 0089 }; 0090 0091 class DIGIKAM_EXPORT Moon200 // Calculating the position of the Moon in J2000.0 0092 { 0093 public: 0094 Moon200(); 0095 Vec3 position (double t); // position of the Moon 0096 0097 private: 0098 double dgam, dlam, n, gam1c, sinpi; 0099 double l0, l, ls, f, d, s; 0100 double dl0, dl, dls, df, dd, ds; 0101 double co[13][4]; 0102 double si[13][4]; 0103 void addthe (double c1, double s1, double c2, double s2, 0104 double& c, double& s); 0105 double sinus (double phi); 0106 void long_periodic (double t); 0107 void minit(double t); 0108 void term (int p, int q, int r, int s, double& x, double& y); 0109 void addsol(double coeffl, double coeffs, double coeffg, 0110 double coeffp, int p, int q, int r, int s); 0111 void solar1(); 0112 void solar2(); 0113 void solar3(); 0114 void addn (double coeffn, int p, int q, int r, int s, 0115 double& n, double&x, double& y); 0116 void solarn (double& n); 0117 void planetary (double t); 0118 }; 0119 0120 class DIGIKAM_EXPORT Eclipse // Eclipse Calculations 0121 { 0122 public: 0123 Eclipse(); 0124 int solar (double jd, double tdut, double& phi, double& lamda); 0125 void maxpos (double jd, double tdut, double& phi, double& lamda); 0126 void penumd (double jd, double tdut, Vec3& vrm, Vec3& ves, 0127 double& dpn, double& pang); 0128 void umbra (double jd, double tdut, Vec3& vrm, Vec3& ves, 0129 double& dpn, double& pang); 0130 double duration (double jd, double tdut, double& width); 0131 Vec3 GetRSun (); // get Earth - Sun vector in Earth radii 0132 Vec3 GetRMoon (); // get Earth - Moon vector in Earth radii 0133 double GetEp2 (); // get the ep2 value 0134 int lunar (double jd, double tdut); 0135 0136 private: 0137 Sun200 sun; 0138 Moon200 moon; 0139 Vec3 rs, rm; // position of the Sun and the Moon 0140 Vec3 eshadow; // unit vector in direction of shadow 0141 Vec3 rint; // intersection shadow axis - Earth surface 0142 double t; // time in Julian Centuries 0143 double ep2; // correction for Apparent Sideral Time 0144 double d_umbra; // diameter of umbra in Earth Radii 0145 double d_penumbra; // diameter of penumbra in Earth Radii 0146 void equ_sun_moon(double jd, double tdut); 0147 }; 0148 0149 #endif // __astrolib_h sentry. 0150 0151