| 1 | #ifndef MARS_Nova | 
|---|
| 2 | #define MARS_Nova | 
|---|
| 3 |  | 
|---|
| 4 | #include <libnova/solar.h> | 
|---|
| 5 | #include <libnova/lunar.h> | 
|---|
| 6 | #include <libnova/rise_set.h> | 
|---|
| 7 | #include <libnova/transform.h> | 
|---|
| 8 | #include <libnova/angular_separation.h> | 
|---|
| 9 |  | 
|---|
| 10 | namespace Nova | 
|---|
| 11 | { | 
|---|
| 12 | typedef ln_lnlat_posn LnLatPosn; | 
|---|
| 13 | typedef ln_rst_time   RstTime; // Note that times are in JD not Mjd | 
|---|
| 14 | //typedef ln_hrz_posn   HrzPosn; | 
|---|
| 15 | //typedef ln_equ_posn   EquPosn; | 
|---|
| 16 |  | 
|---|
| 17 | struct ZdAzPosn; | 
|---|
| 18 | struct RaDecPosn; | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | // Warning: 0deg=South, 90deg=W | 
|---|
| 22 | struct HrzPosn : public ln_hrz_posn | 
|---|
| 23 | { | 
|---|
| 24 | HrzPosn() { } | 
|---|
| 25 | HrzPosn(const ZdAzPosn &); | 
|---|
| 26 | }; | 
|---|
| 27 |  | 
|---|
| 28 | struct ZdAzPosn | 
|---|
| 29 | { | 
|---|
| 30 | double zd; // [deg] | 
|---|
| 31 | double az; // [deg] | 
|---|
| 32 |  | 
|---|
| 33 | ZdAzPosn(double z=0, double a=0) : zd(z), az(a) { } | 
|---|
| 34 | ZdAzPosn(const HrzPosn &hrz) : zd(90-hrz.alt), az(hrz.az-180) { } | 
|---|
| 35 |  | 
|---|
| 36 | // This crahsed cint, but it could save up the dedicate structure HrzPosn :( | 
|---|
| 37 | //operator HrzPosn() const { const HrzPosn p = { az-180, 90-zd}; return p; } | 
|---|
| 38 | }; | 
|---|
| 39 |  | 
|---|
| 40 | HrzPosn::HrzPosn(const ZdAzPosn &za) { alt = 90-za.zd; az = za.az-180; } | 
|---|
| 41 |  | 
|---|
| 42 |  | 
|---|
| 43 | // Note that right ascension is stored in degree | 
|---|
| 44 | struct EquPosn : public ln_equ_posn | 
|---|
| 45 | { | 
|---|
| 46 | EquPosn() { } | 
|---|
| 47 | EquPosn(const RaDecPosn &); | 
|---|
| 48 | }; | 
|---|
| 49 |  | 
|---|
| 50 | struct RaDecPosn | 
|---|
| 51 | { | 
|---|
| 52 | double ra;  // [h] | 
|---|
| 53 | double dec; // [deg] | 
|---|
| 54 |  | 
|---|
| 55 | RaDecPosn(double r=0, double d=0) : ra(r), dec(d) { } | 
|---|
| 56 | RaDecPosn(const EquPosn &equ) : ra(equ.ra/15), dec(equ.dec) { } | 
|---|
| 57 |  | 
|---|
| 58 | // This crahsed cint, but it could save up the dedicate structure HrzPosn :( | 
|---|
| 59 | //operator HrzPosn() const { const HrzPosn p = { az-180, 90-zd}; return p; } | 
|---|
| 60 | }; | 
|---|
| 61 |  | 
|---|
| 62 | EquPosn::EquPosn(const RaDecPosn &rd) { ra = rd.ra*15; dec = rd.dec; } | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 |  | 
|---|
| 66 | const LnLatPosn &ORM() | 
|---|
| 67 | { | 
|---|
| 68 | //static LnLatPosn obs; | 
|---|
| 69 | //obs.lng = -(17.+53./60+26.525/3600); | 
|---|
| 70 | //obs.lat =   28.+45./60+42.462/3600; | 
|---|
| 71 | const static LnLatPosn obs = { -(17.+53./60+26.525/3600), 28.+45./60+42.462/3600 }; | 
|---|
| 72 | return obs; | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, double jd) | 
|---|
| 76 | { | 
|---|
| 77 | HrzPosn hrz; | 
|---|
| 78 | ln_get_hrz_from_equ(const_cast<EquPosn*>(&equ), const_cast<LnLatPosn*>(&obs), jd, &hrz); | 
|---|
| 79 | return hrz; | 
|---|
| 80 | } | 
|---|
| 81 | HrzPosn GetHrzFromEqu(const EquPosn &equ, double jd) | 
|---|
| 82 | { | 
|---|
| 83 | return GetHrzFromEqu(equ, ORM(), jd); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | EquPosn GetEquFromHrz(const HrzPosn &hrz, const LnLatPosn &obs, double jd) | 
|---|
| 87 | { | 
|---|
| 88 | EquPosn equ; | 
|---|
| 89 | ln_get_equ_from_hrz(const_cast<HrzPosn*>(&hrz), const_cast<LnLatPosn*>(&obs), jd, &equ); | 
|---|
| 90 | return equ; | 
|---|
| 91 | } | 
|---|
| 92 | EquPosn GetEquFromHrz(const HrzPosn &hrz, double jd) | 
|---|
| 93 | { | 
|---|
| 94 | return GetEquFromHrz(hrz, ORM(), jd); | 
|---|
| 95 | } | 
|---|
| 96 |  | 
|---|
| 97 | RstTime GetSolarRst(double jd, const LnLatPosn &obs, double hrz=LN_SOLAR_STANDART_HORIZON) | 
|---|
| 98 | { | 
|---|
| 99 | RstTime rst; | 
|---|
| 100 | ln_get_solar_rst_horizon(jd, const_cast<LnLatPosn*>(&obs), hrz, &rst); | 
|---|
| 101 | return rst; | 
|---|
| 102 | } | 
|---|
| 103 | RstTime GetSolarRst(double jd, double hrz=LN_SOLAR_STANDART_HORIZON) | 
|---|
| 104 | { | 
|---|
| 105 | return GetSolarRst(jd, ORM(), hrz); | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | RstTime GetLunarRst(double jd, const LnLatPosn &obs=ORM()) | 
|---|
| 109 | { | 
|---|
| 110 | RstTime rst; | 
|---|
| 111 | ln_get_lunar_rst(jd, const_cast<LnLatPosn*>(&obs), &rst); | 
|---|
| 112 | return rst; | 
|---|
| 113 | } | 
|---|
| 114 | EquPosn GetSolarEquCoords(double jd) | 
|---|
| 115 | { | 
|---|
| 116 | EquPosn equ; | 
|---|
| 117 | ln_get_solar_equ_coords(jd, &equ); | 
|---|
| 118 | return equ; | 
|---|
| 119 | } | 
|---|
| 120 |  | 
|---|
| 121 | double GetLunarDisk(double jd) | 
|---|
| 122 | { | 
|---|
| 123 | return ln_get_lunar_disk(jd); | 
|---|
| 124 | } | 
|---|
| 125 |  | 
|---|
| 126 | double GetLunarSdiam(double jd) | 
|---|
| 127 | { | 
|---|
| 128 | return ln_get_lunar_sdiam(jd); | 
|---|
| 129 | } | 
|---|
| 130 |  | 
|---|
| 131 | double GetLunarPhase(double jd) | 
|---|
| 132 | { | 
|---|
| 133 | return ln_get_lunar_phase(jd); | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | EquPosn GetLunarEquCoords(double jd, double precision=0) | 
|---|
| 137 | { | 
|---|
| 138 | EquPosn equ; | 
|---|
| 139 | ln_get_lunar_equ_coords_prec(jd, &equ, precision); | 
|---|
| 140 | return equ; | 
|---|
| 141 | } | 
|---|
| 142 |  | 
|---|
| 143 | double GetLunarEarthDist(double jd) | 
|---|
| 144 | { | 
|---|
| 145 | return ln_get_lunar_earth_dist(jd); | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 | double GetAngularSeparation(const EquPosn &p1, const EquPosn &p2) | 
|---|
| 149 | { | 
|---|
| 150 | return ln_get_angular_separation(const_cast<EquPosn*>(&p1), const_cast<EquPosn*>(&p2)); | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | double GetAngularSeparation(const HrzPosn &h1, const HrzPosn &h2) | 
|---|
| 154 | { | 
|---|
| 155 | EquPosn p1; p1.ra=h1.az; p1.dec=h1.alt; | 
|---|
| 156 | EquPosn p2; p2.ra=h2.az; p2.dec=h2.alt; | 
|---|
| 157 | return ln_get_angular_separation(&p1, &p2); | 
|---|
| 158 | } | 
|---|
| 159 |  | 
|---|
| 160 | struct SolarObjects | 
|---|
| 161 | { | 
|---|
| 162 | double  fJD; | 
|---|
| 163 |  | 
|---|
| 164 | EquPosn fSunEqu; | 
|---|
| 165 | HrzPosn fSunHrz; | 
|---|
| 166 |  | 
|---|
| 167 | EquPosn fMoonEqu; | 
|---|
| 168 | HrzPosn fMoonHrz; | 
|---|
| 169 | double  fMoonDisk; | 
|---|
| 170 |  | 
|---|
| 171 | double fEarthDist; | 
|---|
| 172 |  | 
|---|
| 173 | SolarObjects(const double &jd, const LnLatPosn &obs=Nova::ORM()) | 
|---|
| 174 | { | 
|---|
| 175 | fJD = jd; | 
|---|
| 176 |  | 
|---|
| 177 | // Sun properties | 
|---|
| 178 | fSunEqu    = GetSolarEquCoords(jd); | 
|---|
| 179 | fSunHrz    = GetHrzFromEqu(fSunEqu, obs, jd); | 
|---|
| 180 |  | 
|---|
| 181 | // Moon properties | 
|---|
| 182 | fMoonEqu   = GetLunarEquCoords(jd, 0.01); | 
|---|
| 183 | fMoonHrz   = GetHrzFromEqu(fMoonEqu, obs, jd); | 
|---|
| 184 |  | 
|---|
| 185 | fMoonDisk  = GetLunarDisk(jd); | 
|---|
| 186 | fEarthDist = GetLunarEarthDist(jd); | 
|---|
| 187 | } | 
|---|
| 188 | }; | 
|---|
| 189 |  | 
|---|
| 190 | } | 
|---|
| 191 |  | 
|---|
| 192 | #endif | 
|---|