1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2012 Gerhard HOLTKAMP 4 // 5 6 #if !defined(__eclsolar_h) 7 #define __eclsolar_h 8 9 #include "attlib.h" 10 #include "astrolib_export.h" 11 12 const int GBL_ECLBUF = 12; // maximum number of eclipses allowed 13 const int MAXLUN = 15; 14 15 typedef double PMJD[MAXLUN]; // array of MJD's of the respective phase 16 17 class ASTROLIB_EXPORT EclSolar // Calculate Solar Eclipses 18 { 19 public: 20 EclSolar(); 21 ~EclSolar(); 22 23 int getYear() const; // the year currently used by EclSolar 24 void putYear(int yr); // set the year to be used by EclSolar 25 int getNumberEclYear(); // get the number of eclipses of the currently selected year 26 void setLunarEcl(bool lecl); // include lunar eclipses 27 void setStepWidth(double s); // set the step width (minutes) 28 void setTimezone(double d); // set timezone for I/O 29 void setDeltaTAI_UTC(double d); // set IERS Parameter TAI - UTC 30 void setAutoTAI_UTC(); // IERS Parameter TAI - UTC to auto 31 void setLocalPos(double lat, double lng, double hgt); // set local geographic coordinates 32 void getLocalDetails(char *otxt); // provide eclipse details for local position 33 void setCurrentMJD(int year, int month, int day, int hour, int min, double sec); // set current time 34 void getDatefromMJD(double mjd, int &year, int &month, int &day, 35 int &hour, int &min, double &sec) const; // convert MJD into date and time 36 int getLocalVisibility(double &mjd_start, double &mjd_stop); // local start and stop times for eclipse 37 int getLocalTotal(double &mjd_start, double &mjd_stop); // local start and stop times for totality/annularity 38 int getLocalMax(double &mjdmax, double &magmax, double &elmax); // get local (solar) eclipse maximum 39 int getPenumbra(double &mjd_start, double &mjd_stop); // start and stop times for penumbral eclipse of Moon 40 int getPartial(double &mjd_start, double &mjd_stop); // (global) start and stop times for partial phase 41 int getTotal(double &mjd_start, double &mjd_stop); // (global) start and stop times for totality/annularity 42 void getEclYearInfo(char* wbuf); // list of eclipses of the year 43 int getEclYearInfo(int k, int &yr, int &month, int &day, 44 int &hour, int &min, double &sec, double &tzone, double &magn); 45 int getEclTxt (int j, char* jtxt); // get text for j-th eclipse 46 void putEclSelect(int es); // select particular eclipse for details 47 void nextEcl(); // select the next eclipse for details 48 void previousEcl(); // select the previous eclipse for details 49 double getLastMJD() const; // get the MJD last used in calculations 50 void getMaxPos(double &lat, double &lng); // get position of maximum eclipse 51 int eclPltCentral(bool firstc, double &lat, double &lng); // calc central eclipse line 52 int GNSBound(bool firstc, bool north, double& lat, double& lng); // northern or southern boundary 53 int GRSBound(bool firstc, double& lat1, double& lng1, double& lat2, double& lng2); 54 // Rise / Set Boundary 55 int centralBound(bool firstc, double& lat1, double& lng1, double& lat2, double& lng2); 56 void getShadowCone(double mjd, bool umbra, int numpts, double* lat, double* lng); 57 void setPenumbraAngle(double pa, int mode); 58 59 private: 60 void esinit(); // initialize EclSolar 61 static double atan23 (double y, double x); // atan without singularity for x,y=0 62 void DefTime (); // Get System Time and Date 63 void calcMaxPos(double &lat, double &lng); // get position of maximum eclipse 64 static void GetMonth (int mm, char* mchr); 65 static double phmjd (double yearf, double phase, double tdut, 66 int& eph, double& ejd, double& emag); 67 void ckphase (double minmjd, double maxmjd, double yr, 68 double deltdut, int &mp, PMJD p, double phase); 69 static void dtmstr(double jdmoon, char *dts); 70 void moonph(); // calculate phases of the Moon 71 void eclStart(); // initialize detailed calcs for selected eclipse 72 static double getlocmag(double jd, double ep2, double phi, double lamda, 73 double height, const Vec3& rs, const Vec3& rm, int& totflg); 74 static int iscrs(double vrc0, double vrc1, double dpn, 75 double& vrx0, double& vrx1, double& vrx20, double& vrx21); 76 void InitBound(); // initialize boundary calcs 77 void InRSBound(); // initialize Sunrise/Sunset boundaries 78 static double DegFDms (double h); 79 int localStart(int j, double *spt, double *ept, int *spp, 80 int p, char *otxt); 81 static double navCourse (double lat1, double lng1, double lat2, double lng2); // navigation course from p1 to p2 82 static void navNewPos (double d, double an, double lat1, double lng1, double &lat2, double &lng2); 83 static double sunObscure(double l1, double l2, double m); // get the Obscuration of the Sun 84 85 // data fields 86 87 bool eb_start_called; // true if eclStart() has already been called for eclipse 88 bool eb_moonph_called; // true if moonph has already been called for year 89 bool eb_lunecl; // true if lunar eclipses are to be included 90 bool eb_lunactive; // true if current eclipse is a lunar eclipse 91 bool eb_local_called; // true if local circumstances calculated 92 93 int eb_day; // date 94 int eb_month; 95 int eb_year; 96 int eb_hour; 97 int eb_minute; 98 int eb_second; 99 double eb_time; 100 double eb_tzone; // timezone in hours 101 double eb_del_tdut; // TDT - UT in sec 102 int eb_del_auto; // 1 = automatic del_tdut, 0 = manual 103 double eb_geolat; // geographic coordinates (angles in degrees) 104 double eb_geolong; 105 double eb_geoheight; // in meters 106 int eb_lstcall; // 1 = last call moonph; 2 = caldisp; 0 = no call 107 int eb_locecl; // 1 = local eclipse call; 0 = normal (global) call 108 109 bool eb_finished; // true if the loop run on consecutive calls is finished 110 bool eb_finished2; 111 int eb_numecl; // number of eclipses of the year; 112 int eb_eclselect; // eclipse selected for detailed calculation 113 int eb_lastyear; // last year for which moon phases were calculated 114 double eb_lasttz; // last used timezone 115 double eb_lastdlt; // last delta-t used 116 double eb_cstep; // step width in minutes used for central eclipse output 117 double eb_eclmjd [GBL_ECLBUF]; // the MJD's of the middle of the eclipses 118 double eb_magnitude [GBL_ECLBUF]; // magnitude of respective eclipse 119 int eb_phase [GBL_ECLBUF]; // phase of the eclipse. 0 if no eclipse, 120 // 1 partial Sun, 2 non-central annular, 3 non-central total, 121 // 4 annular, 5 total, 6 annual/total Sun 122 // -1 partial penumbral Moon, -2 penumbral Moon, 123 // -3 partial Moon, -4 total Moon. 124 int eb_nphase; // number of phases for eclipse details 125 int eb_spp[4]; // kind of eclipse phase i 126 double eb_spt[4]; // start time in MJD for phase i 127 double eb_ept[4]; // end time in MJD for phase i 128 int eb_lccnt; // = 0 not visible, 1,2 = first rise/set; 3,4 second r/s 129 double eb_lcb1, eb_lcb2, eb_lce1, eb_lce2; // rise and set times (up to 2 possible) 130 double eb_jdmaxps; // MJD of maximum phase 131 double eb_maxps; // value of maximum phase 132 double eb_maxelv; // elevation at maximum phase 133 double eb_ltotb; // begin of totality/annularity at local position 134 double eb_ltote; // end of totality/annularity at local position 135 int eb_cphs; // phase of the central eclipse for center line plotting 136 double eb_clat; // current latitude of center line (in decimal degrees) 137 double eb_clng; // current longitude of center line (in decimal degrees) 138 double eb_cmxlat; // latitude of maximum eclipse (in decimal degrees) 139 double eb_cmxlng; // longitude of maximum eclipse (in decimal degrees) 140 double eb_jdstart; // (global) start jd of eclipse 141 double eb_jdstop; // (global) end jd of eclipse 142 double eb_lastjd; // last used MJD for eclipse calcs 143 double eb_dpb; // Base value for diameter of penumbra 144 double eb_dpd; // delta value for diameter of penumbra 145 double eb_penangle; // factor for multiplying the penumbra angle (1.0 for normal borders) 146 int eb_penamode; // mode for using eb_penangle 147 Vec3 eb_ubm; // Penumbra (or Umbra or Moon) base vector 148 Vec3 eb_ube; // Shadow base vector for upper boundary 149 Vec3 eb_udm; // Penumbra base delta vector 150 Vec3 eb_ude; // Shadow delta vector for upper boundary 151 Vec3 eb_lbe; // Shadod base vector for lower boundary 152 Vec3 eb_lde; // Shadow delta vector for lower boundary 153 154 }; 155 156 #endif // __eclsolar_h sentry. 157 158