File indexing completed on 2024-04-21 03:48:43

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2014 Gerhard Holtkamp
0004 //
0005 
0006 #if !defined(__solarsystem_h)
0007 #define __solarsystem_h
0008 
0009 #include "attlib.h"
0010 #include "astrolib_export.h"
0011 
0012 class ASTROLIB_EXPORT SolarSystem     // Calculate Positions of Solar System Bodies
0013 {
0014   public:
0015     SolarSystem();
0016     ~SolarSystem();
0017 
0018     void setTimezone(double d);  // set timezone for I/O
0019     void setDeltaTAI_UTC(double d);  // set IERS Parameter TAI - UTC
0020     void setAutoTAI_UTC();  // IERS Parameter TAI - UTC to auto
0021     void setCurrentMJD(int year, int month, int day, int hour, int min, double sec); // set current time
0022     void setCurrentMJD();  // sets current MJD to R/T 
0023     double getMJD(int year, int month, int day, int hour, int min, double sec); // get MJD from date 
0024     void getDatefromMJD(double mjd, int &year, int &month, int &day,
0025                         int &hour, int &min, double &sec); // convert MJD into date and time
0026     void setEpoch (double yr);  // set epoch of coordinates
0027     void setNutation (bool nut);  // specify whether nutation is to be included.
0028     void setCentralBody (char* pname); // select which planet is central body
0029     void includeUser (bool uact);  // activate user defined object
0030 
0031     void getSun (double& ra, double& decl);  // RA and Dec for the Sun 
0032     void getMoon (double& ra, double& decl);  // RA and Dec for the Moon 
0033     void getMercury (double& ra, double& decl);  // RA and Dec for Mercury 
0034     void getVenus (double& ra, double& decl);  // RA and Dec for Venus 
0035     void getEarth (double& ra, double& decl);  // RA and Dec for Earth (with regard to the Sun) 
0036     void getMars (double& ra, double& decl);  // RA and Dec for Mars 
0037     void getJupiter (double& ra, double& decl);  // RA and Dec for Jupiter 
0038     void getSaturn (double& ra, double& decl);  // RA and Dec for Saturn 
0039     void getUranus (double& ra, double& decl);  // RA and Dec for Uranus 
0040     void getNeptune (double& ra, double& decl);  // RA and Dec for Neptune
0041     void getIo (double& ra, double& decl);  // RA and Dec for Io 
0042     void getEuropa (double& ra, double& decl);  // RA and Dec for Europa 
0043     void getGanymede (double& ra, double& decl);  // RA and Dec for Ganymede 
0044     void getCallisto (double& ra, double& decl);  // RA and Dec for Callisto 
0045     void getRhea (double& ra, double& decl);  // RA and Dec for Rhea 
0046     void getTitan (double& ra, double& decl);  // RA and Dec for Titan 
0047     void getMimas (double& ra, double& decl);  // RA and Dec for Mimas 
0048     void getEnceladus (double& ra, double& decl);  // RA and Dec for Enceladus 
0049     void getDione (double& ra, double& decl);  // RA and Dec for Dione 
0050     void getUser (double& ra, double& decl);  // RA and Dec for user defined object 
0051 
0052     void getPhysSun (double &pdiam, double &pmag);  // Physical elements Sun 
0053     void getPhysMercury(double &pdiam, double &pmag, double &pphase);  // Physical elements Mercury 
0054     void getPhysVenus(double &pdiam, double &pmag, double &pphase);  // Physical elements Venus 
0055     void getPhysEarth(double &pdiam, double &pmag, double &pphase);  // Physical elements Earth 
0056     void getPhysMars(double &pdiam, double &pmag, double &pphase);  // Physical elements Mars 
0057     void getPhysJupiter(double &pdiam, double &pmag, double &pphase);  // Physical elements Jupiter 
0058     void getPhysSaturn(double &pdiam, double &pmag, double &pphase);  // Physical elements Saturn 
0059     void getPhysUranus(double &pdiam, double &pmag, double &pphase);  // Physical elements Uranus 
0060     void getPhysNeptune(double &pdiam, double &pmag, double &pphase);  // Physical elements Neptune 
0061     double getDiamMoon (); // Apparent diameter for the Moon 
0062     void getLunarLibration (double &lblon, double &lblat, double &termt);  // librations of the Moon and terminator position
0063     void getLunarPhase (double &phase, double &ildisk, double &amag);  // phase and mag of Moon
0064 
0065     void getPhysIo(double &pdiam, double &pmag, double &pphase);  // Physical elements Io 
0066     void getPhysEuropa(double &pdiam, double &pmag, double &pphase);  // Physical elements Europa 
0067     void getPhysGanymede(double &pdiam, double &pmag, double &pphase);  // Physical elements Ganymede 
0068     void getPhysCallisto(double &pdiam, double &pmag, double &pphase);  // Physical elements Callisto 
0069     void getPhysRhea(double &pdiam, double &pmag, double &pphase);  // Physical elements Rhea 
0070     void getPhysTitan(double &pdiam, double &pmag, double &pphase);  // Physical elements Titan 
0071     void getPhysMimas(double &pdiam, double &pmag, double &pphase);  // Physical elements Mimas 
0072     void getPhysEnceladus(double &pdiam, double &pmag, double &pphase);  // Physical elements Enceladus 
0073     void getPhysDione(double &pdiam, double &pmag, double &pphase);  // Physical elements Dione 
0074     void getPhysUser(double &pdiam, double &pmag, double &pphase);  // Physical elements user defined object
0075 
0076     Vec3 getPlanetocentric (double ra, double decl);  // planetocentric position
0077     void getPlanetographic (double ra, double decl, double &lng, double &lat);
0078     void getSkyRotAngles (double &raz1, double &rax, double &raz2);
0079 
0080     void putOrbitElements (double t0, double pdist, double ecc, double ran, double aper, double inc, double eclep);
0081     void putEllipticElements (double t0, double a, double m0, double ecc, double ran, double aper, double inc, double eclep);
0082     void getOrbitPosition (double& ra, double& decl);
0083     double getDistance();  // distance in AU of Kepler object
0084     double getCometMag(double g, double k);  // apparent magnitude of comet
0085     double getAsteroidMag(double h, double g);   // apparent magnitude of asteroid
0086     void putOrbitUser (double t0, double pdist, double ecc, double ran, double aper, double inc, double eclep);
0087     void putEllipticUser (double t0, double a, double m0, double ecc, double ran, double aper, double inc, double eclep);
0088     void putConstUser(double j2, double r0, double flat, double axl0, double axl1, double axb0, double axb1, double w, double wd, double gm);  // store physical user constants
0089     
0090     double DmsDegF (double h); // conversion from Format DDD.MMSS into d.fff
0091     double DegFDms (double h); // conversion from Format d.fff into DDD.MMSS
0092 
0093 
0094   private:  
0095     void ssinit();  // initialize SolarSystem
0096     double atan23 (double y, double x);  // atan without singularity for x,y=0
0097     void DefTime ();  // Get System Time and Date
0098     void getRaDec (const Vec3& r1, double& ra, double& decl); // convert r1 into RA and DEC
0099     void updateSolar();  // update all positions of planets according to current MJD.
0100    
0101     void MoonDetails();
0102     void MoonLibr (double jd, Vec3 rm, Vec3 sn, double &lblon, double &lblat, double &termt);
0103     Vec3 SnPos (double &ep2, double &els);
0104     Vec3 MnPos (double &ep2, double &els);
0105     Vec3 PosUser(double dt);  // position of User defined object
0106     Mat3 getSelenographic();
0107     void getConstSun();  // Sun constants
0108     void getConstMoon();  // Moon planetary constants
0109     void getConstMercury();  // Mercury planetary constants
0110     void getConstVenus();  // Venus planetary constants
0111     void getConstEarth();  // Earth planetary constants
0112     void getConstMars();  // Mars planetary constants
0113     void getConstJupiter(); // Jupiter planetary constants
0114     void getConstSaturn(); // Saturn planetary constants
0115     void getConstUranus(); // Uranus planetary constants
0116     void getConstNeptune(); // Neptune planetary constants
0117     void getConstIo(); // Io planetary constants
0118     void getConstEuropa(); // Europa planetary constants
0119     void getConstGanymede(); // Ganymede planetary constants
0120     void getConstCallisto(); // Callisto planetary constants
0121     void getConstRhea(); // Rhea planetary constants
0122     void getConstTitan(); // Titan planetary constants
0123     void getConstMimas(); // Mimas planetary constants
0124     void getConstEnceladus(); // Enceladus planetary constants
0125     void getConstDione(); // Dione planetary constants
0126     void getConstUser(); // User planetary constants
0127 
0128     void getPlanMat();  // get Matrix to convert from J2000.0 into planetary coordinates
0129 
0130    // data fields
0131 
0132       bool ss_update_called;  // true if updateSolar() has already been called
0133       bool ss_moon_called;    // true if special Moon calculation called
0134       bool ss_planmat_called; // true if matrix for planetary coordinates called
0135       bool ss_kepler_stored;  // true if Kepler elements for comet or asteroid stored
0136       bool ss_kepler_called;  // true if comet or asteroid position calculated
0137       bool ss_user_stored;    // true if orbit elements for user defined object stored
0138       bool ss_user_active;    // true if user defined object activated
0139 
0140       int ss_day;           // date
0141       int ss_month;
0142       int ss_year;
0143       int ss_hour;
0144       int ss_minute;
0145       int ss_second;
0146       double ss_time;       // currently used MJD
0147       double ss_tzone;      // timezone in hours
0148       double ss_del_tdut;   // TDT - UT in sec
0149       int ss_del_auto;      // 1 = automatic del_tdut,  0 = manual
0150       bool ss_RT;   // true if calculations in Real Time, false if time manually set to MJD.
0151       bool ss_nutation;  // true if position corrected for nutation
0152       double ss_epoch;  // epoch of coordinates in MJD
0153       int ss_central_body;  // body defining the coordinate origin (0=sun,1=moon,2=mercury etc.; -1=user)
0154 
0155      Vec3 ss_rm, ss_rs;  // position of Moon and Sun in ecliptic of date (A.U.)
0156      Vec3 ss_pmer, ss_pven, ss_pearth, ss_pmars, ss_pjup, ss_psat, ss_pura, ss_pnept; // positions of planets
0157      Vec3 ss_pio, ss_peuropa, ss_pganymede, ss_pcallisto;  // positions of Jupiter moons
0158      Vec3 ss_prhea, ss_ptitan, ss_pmimas, ss_penceladus, ss_pdione; // positions of Saturn moons
0159      Vec3 ss_user;  // position of user defined object
0160 
0161      double ss_moon_mag;  // apparent magnitude of the Moon
0162      double ss_moon_lblon;  // longitude of lunar libration
0163      double ss_moon_lblat;  // latitude of lunar libration
0164      double ss_moon_term;   // position of lunar terminator
0165      double ss_moon_ildisk; // fraction of Moon's illuminated disk
0166      double ss_moon_phase;  // phase of Moon
0167 
0168      double ss_GM;  // gravitational constant (m^3/s^2)
0169      double ss_J2;  // J2 gravitational term
0170      double ss_R0; // equatorial radius (km)
0171      double ss_flat;  // flattening factor
0172      double ss_axl0;  // l-direction of rotation axis
0173      double ss_axl1;  // delta of axl0
0174      double ss_axb0;  // b-direction of rotation axis
0175      double ss_axb1;  // delta of axb0
0176      double ss_W;    // location of prime meridian
0177      double ss_Wd;   // daily variation of W.
0178 
0179      // data for user defined object:
0180      double ss_user_GM;  // gravitational constant (m^3/s^2)
0181      double ss_user_J2;  // J2 gravitational term
0182      double ss_user_R0; // equatorial radius (km)
0183      double ss_user_flat;  // flattening factor
0184      double ss_user_axl0;  // l-direction of rotation axis
0185      double ss_user_axl1;  // delta of axl0
0186      double ss_user_axb0;  // b-direction of rotation axis
0187      double ss_user_axb1;  // delta of axb0
0188      double ss_user_W;    // location of prime meridian
0189      double ss_user_Wd;   // daily variation of W.
0190      double ss_user_t0;  // time of perihelion passage or epoch of elliptical elements (MJD
0191      double ss_user_m0;  // Mean Anomaly in degrees
0192      double ss_user_a;   // semi-major axis in AU
0193      double ss_user_ecc; // eccentricity
0194      double ss_user_ran; // right ascension of ascending node in degrees
0195      double ss_user_aper; // argument of perihelion
0196      double ss_user_inc;  // inclination in degrees
0197      double ss_user_eclep; // epoch of ecliptic and equator for these elements
0198 
0199      Mat3 ss_planmat; // matrix to convert from J2000.0 into planetary coordinates
0200      double ss_lat;  // planetary latitude (decimal degrees)
0201      double ss_lng;  // planetary longitude (decimal degrees)
0202      double ss_height; // height above reference ellipsoid (km) 
0203 
0204      double ss_t0;  // time of perihelion passage or epoch of elliptical elements (MJD)
0205      double ss_m0;  // Mean Anomaly in degrees
0206      double ss_a;   // semi-major axis in AU
0207      double ss_ecc; // eccentricity
0208      double ss_ran; // right ascension of ascending node in degrees
0209      double ss_aper; // argument of perihelion
0210      double ss_inc;  // inclination in degrees
0211      double ss_eclep; // epoch of ecliptic and equator for these elements
0212      Vec3 ss_comet;  // position vector of comet or asteroid in AU
0213 
0214 };
0215 
0216 #endif         // __solarsystem_h sentry.
0217