diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx index 8952be5c..55070a56 100644 --- a/simgear/ephemeris/moonpos.cxx +++ b/simgear/ephemeris/moonpos.cxx @@ -85,6 +85,8 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) cosN, sinN, cosvw, sinvw, sinvw_cosi, cosecl, sinecl, rcoslatEcl, FlesstwoD, MlesstwoD, twoD, twoM, twolat, alpha; + double max_loglux = -0.504030345621; + double min_loglux = -4.39964634562; double conv = 1.0319696543787917; // The log foot-candle to log lux conversion factor. updateOrbElements(mjd); actTime = sgCalcActTime(mjd); @@ -227,4 +229,8 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) // Convert from foot-candles to lux. log_I += conv; + + // The moon's illuminance factor, bracketed between 0 and 1. + I_factor = (log_I - max_loglux) / (max_loglux - min_loglux) + 1.0; + I_factor = SGMiscd::clip(I_factor, 0, 1); } diff --git a/simgear/ephemeris/moonpos.hxx b/simgear/ephemeris/moonpos.hxx index 0f87b9d3..b601d425 100644 --- a/simgear/ephemeris/moonpos.hxx +++ b/simgear/ephemeris/moonpos.hxx @@ -42,6 +42,7 @@ private: double age; // the moon's age from 0 to 2pi double phase; // the moon's phase double log_I; // the moon's illuminance outside the atmosphere (logged) + double I_factor; // the illuminance factor for the moon, between 0 and 1. // void TexInit(); // This should move to the constructor eventually. // GLUquadricObj *moonObject; @@ -70,6 +71,7 @@ public: double getAge() const; double getPhase() const; double getLogIlluminance() const; + double getIlluminanceFactor() const; }; inline double MoonPos::getM() const @@ -122,4 +124,9 @@ inline double MoonPos::getLogIlluminance() const return log_I; } +inline double MoonPos::getIlluminanceFactor() const +{ + return I_factor; +} + #endif // _MOONPOS_HXX_