diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx index ff6fa569..e088e768 100644 --- a/simgear/ephemeris/moonpos.cxx +++ b/simgear/ephemeris/moonpos.cxx @@ -211,4 +211,8 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) /* SG_LOG( SG_GENERAL, SG_INFO, "Ra = (" << (SGD_RADIANS_TO_DEGREES *rightAscension) << "), Dec= (" << (SGD_RADIANS_TO_DEGREES *declination) << ")" ); */ + + // Moon age and phase calculation + age = lonEcl - ourSun->getlonEcl(); + phase = (1 - cos(age)) / 2; } diff --git a/simgear/ephemeris/moonpos.hxx b/simgear/ephemeris/moonpos.hxx index 3462146e..3feb375e 100644 --- a/simgear/ephemeris/moonpos.hxx +++ b/simgear/ephemeris/moonpos.hxx @@ -39,6 +39,8 @@ private: double xg, yg; // the moon's rectangular geocentric coordinates double ye, ze; // the moon's rectangular equatorial coordinates double distance; // the moon's distance to the earth + double age; // the moon's age from 0 to 2pi + double phase; // the moon's phase // void TexInit(); // This should move to the constructor eventually. // GLUquadricObj *moonObject; @@ -64,6 +66,8 @@ public: double getye() const; double getze() const; double getDistance() const; + double getAge() const; + double getPhase() const; }; inline double MoonPos::getM() const @@ -101,4 +105,14 @@ inline double MoonPos::getDistance() const return distance; } +inline double MoonPos::getAge() const +{ + return age; +} + +inline double MoonPos::getPhase() const +{ + return phase; +} + #endif // _MOONPOS_HXX_ diff --git a/simgear/ephemeris/star.hxx b/simgear/ephemeris/star.hxx index 838cbce7..955f88ea 100644 --- a/simgear/ephemeris/star.hxx +++ b/simgear/ephemeris/star.hxx @@ -33,6 +33,7 @@ class Star : public CelestialBody private: + double lonEcl; // the sun's true longitude double xs, ys; // the sun's rectangular geocentric coordinates double ye, ze; // the sun's rectangularequatorial rectangular geocentric coordinates double distance; // the sun's distance to the earth @@ -50,6 +51,7 @@ public: double getye() const; double getze() const; double getDistance() const; + double getlonEcl() const; }; @@ -88,6 +90,10 @@ inline double Star::getDistance() const return distance; } +inline double Star::getlonEcl() const +{ + return lonEcl; +} #endif // _STAR_HXX_