00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 #include <math.h>
00032 #include "../Include/Ephemeris.h"
00033 #include "../Include/Utility.h"
00034
00035
00036
00037 static SOrbitalElements first =
00038 {
00039 125.1228,
00040 5.1454,
00041 318.0634,
00042 60.266600,
00043 0.054900,
00044 115.3654
00045 };
00046
00047 static SOrbitalElements second =
00048 {
00049 -0.0529538083,
00050 0.0,
00051 0.1643573223,
00052 0.0,
00053 0.0,
00054 13.0649929509
00055 };
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 CMoon::CMoon(double mjd) :
00066 CCelestialBody (first.N, first.i, first.w, first.a, first.e, first.M,
00067 second.N, second.i, second.w, second.a, second.e, second.M,
00068 mjd)
00069 {
00070 }
00071
00072 CMoon::CMoon() :
00073 CCelestialBody (first.N, first.i, first.w, first.a, first.e, first.M,
00074 second.N, second.i, second.w, second.a, second.e, second.M)
00075 {
00076 }
00077
00078 CMoon::~CMoon()
00079 {
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089 void CMoon::UpdatePosition (double mjd, double lst, double lat, CSol *ourSun)
00090 {
00091
00092 double
00093 eccAnom, ecl, actTime,
00094 xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
00095 Ls, Lm, D, F, mpar, gclat, rho, HA, g,
00096 geoRa, geoDec;
00097
00098 UpdateOrbElements(mjd);
00099 actTime = CalcActTime(mjd);
00100
00101
00102
00103 ecl = ((SGD_DEGREES_TO_RADIANS * 23.4393) - (SGD_DEGREES_TO_RADIANS * 3.563E-7) * actTime);
00104 eccAnom = CalcEccAnom(M, e);
00105 xv = a * (cos(eccAnom) - e);
00106 yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
00107 v = atan2(yv, xv);
00108 r = sqrt (xv*xv + yv*yv);
00109
00110
00111 xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i));
00112 yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i));
00113 zh = r * (sin(v+w) * sin(i));
00114
00115
00116 lonEcl = atan2 (yh, xh);
00117 latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
00118
00119
00120
00121
00122 Ls = ourSun->getM() + ourSun->getw();
00123 Lm = M + w + N;
00124 D = Lm - Ls;
00125 F = Lm - N;
00126
00127 lonEcl += SGD_DEGREES_TO_RADIANS * (-1.274 * sin (M - 2*D)
00128 +0.658 * sin (2*D)
00129 -0.186 * sin(ourSun->getM())
00130 -0.059 * sin(2*M - 2*D)
00131 -0.057 * sin(M - 2*D + ourSun->getM())
00132 +0.053 * sin(M + 2*D)
00133 +0.046 * sin(2*D - ourSun->getM())
00134 +0.041 * sin(M - ourSun->getM())
00135 -0.035 * sin(D)
00136 -0.031 * sin(M + ourSun->getM())
00137 -0.015 * sin(2*F - 2*D)
00138 +0.011 * sin(M - 4*D)
00139 );
00140 latEcl += SGD_DEGREES_TO_RADIANS * (-0.173 * sin(F-2*D)
00141 -0.055 * sin(M - F - 2*D)
00142 -0.046 * sin(M + F - 2*D)
00143 +0.033 * sin(F + 2*D)
00144 +0.017 * sin(2*M + F)
00145 );
00146 r += (-0.58 * cos(M - 2*D)
00147 -0.46 * cos(2*D)
00148 );
00149
00150 xg = r * cos(lonEcl) * cos(latEcl);
00151 yg = r * sin(lonEcl) * cos(latEcl);
00152 zg = r * sin(latEcl);
00153
00154 xe = xg;
00155 ye = yg * cos(ecl) -zg * sin(ecl);
00156 ze = yg * sin(ecl) +zg * cos(ecl);
00157
00158 geoRa = atan2(ye, xe);
00159 geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
00160
00161
00162
00163
00164
00165
00166
00167 mpar = asin ( 1 / r);
00168
00169 gclat = lat - 0.003358 *
00170 sin (2 * SGD_DEGREES_TO_RADIANS * lat );
00171
00172 rho = 0.99883 + 0.00167 * cos(2 * SGD_DEGREES_TO_RADIANS * lat);
00173
00174 if (geoRa < 0)
00175 geoRa += (2*SGD_PI);
00176
00177 HA = lst - (3.8197186 * geoRa);
00178
00179 g = atan (tan(gclat) / cos ((HA / 3.8197186)));
00180
00181 rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
00182 if (fabs(lat) > 0) {
00183 declination
00184 = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
00185 } else {
00186 declination = geoDec;
00187 }
00188
00189
00190 age = LUNATION_DAYS * WrapTwoPi (GetLon() - ourSun->GetLon()) / (SGD_PI * 2);
00191 }
00192
00193
00194 float CMoon::GetAge (void)
00195 {
00196 return age;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222