Calculation of the illuminance factor for the moon.

This is a number ranging between 0 and 1 based on the log of the illuminance of
the moon outside the atmosphere.  It is calculated as

    factor = (log(I) - max_loglux) / (max_loglux - min_loglux) + 1.0,

where I is the illuminance of the moon outside the atmosphere and min_loglux and
max_loglux are hardcoded to -0.504030345621 and -4.39964634562 respectively.
Although the value should never be outside of [0, 1], for safety it is clipped
to be between these values.  For more background, see
http://forum.flightgear.org/viewtopic.php?f=47&t=28201&start=60#p270516 .
This commit is contained in:
Edward d'Auvergne
2016-01-07 09:56:44 +01:00
parent 0e09ee4bce
commit 50d7127c51
2 changed files with 13 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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_