#include <string.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgpath.hxx>
#ifdef __BORLANDC__
# define exception c_exception
// calculate the angle between ecliptic and equatorial coordinate system
// in Radians
- ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
+ ecl = ((SGD_DEGREES_TO_RADIANS * 23.4393) - (SGD_DEGREES_TO_RADIANS * 3.563E-7) * actTime);
eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric anomaly
xv = a * (cos(eccAnom) - e);
yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
D = Lm - Ls;
F = Lm - N;
- lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
+ lonEcl += SGD_DEGREES_TO_RADIANS * (-1.274 * sin (M - 2*D)
+0.658 * sin (2*D)
-0.186 * sin(ourSun->getM())
-0.059 * sin(2*M - 2*D)
-0.015 * sin(2*F - 2*D)
+0.011 * sin(M - 4*D)
);
- latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
+ latEcl += SGD_DEGREES_TO_RADIANS * (-0.173 * sin(F-2*D)
-0.055 * sin(M - F - 2*D)
-0.046 * sin(M + F - 2*D)
+0.033 * sin(F + 2*D)
r += (-0.58 * cos(M - 2*D)
-0.46 * cos(2*D)
);
- // FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
+ // SG_LOG(SG_GENERAL, SG_INFO, "Running moon update");
xg = r * cos(lonEcl) * cos(latEcl);
yg = r * sin(lonEcl) * cos(latEcl);
zg = r * sin(latEcl);
geoRa = atan2(ye, xe);
geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
- /* FG_LOG( FG_GENERAL, FG_INFO,
- "(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa)
- << "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */
+ /* SG_LOG( SG_GENERAL, SG_INFO,
+ "(geocentric) geoRa = (" << (SGD_RADIANS_TO_DEGREES * geoRa)
+ << "), geoDec= (" << (SGD_RADIANS_TO_DEGREES * geoDec) << ")" ); */
// Given the moon's geocentric ra and dec, calculate its
// First calculate the moon's parrallax, that is, the apparent size of the
// (equatorial) radius of the earth, as seen from the moon
mpar = asin ( 1 / r);
- // FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar );
- // FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() );
+ // SG_LOG( SG_GENERAL, SG_INFO, "r = " << r << " mpar = " << mpar );
+ // SG_LOG( SG_GENERAL, SG_INFO, "lat = " << f->get_Latitude() );
gclat = lat - 0.003358 *
- sin (2 * DEG_TO_RAD * lat );
- // FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
+ sin (2 * SGD_DEGREES_TO_RADIANS * lat );
+ // SG_LOG( SG_GENERAL, SG_INFO, "gclat = " << gclat );
- rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat);
- // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
+ rho = 0.99883 + 0.00167 * cos(2 * SGD_DEGREES_TO_RADIANS * lat);
+ // SG_LOG( SG_GENERAL, SG_INFO, "rho = " << rho );
if (geoRa < 0)
geoRa += (2*SGD_PI);
HA = lst - (3.8197186 * geoRa);
- /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
+ /* SG_LOG( SG_GENERAL, SG_INFO, "t->getLst() = " << t->getLst()
<< " HA = " << HA ); */
g = atan (tan(gclat) / cos ((HA / 3.8197186)));
- // FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
+ // SG_LOG( SG_GENERAL, SG_INFO, "g = " << g );
rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
- declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
-
- /* FG_LOG( FG_GENERAL, FG_INFO,
- "Ra = (" << (RAD_TO_DEG *rightAscension)
- << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
+ if (fabs(lat) > 0) {
+ declination
+ = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
+ } else {
+ declination = geoDec;
+ // cerr << "Geocentric vs. Topocentric position" << endl;
+ // cerr << "RA (difference) : "
+ // << SGD_RADIANS_TO_DEGREES * (geoRa - rightAscension) << endl;
+ // cerr << "Dec (difference) : "
+ // << SGD_RADIANS_TO_DEGREES * (geoDec - declination) << endl;
+ }
+
+ /* SG_LOG( SG_GENERAL, SG_INFO,
+ "Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension)
+ << "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */
}