From b57472841154b93ab97b307b4fbca62414682d64 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne <edward@nmr-relax.com> Date: Sun, 13 Dec 2015 16:21:02 +0100 Subject: [PATCH] Ephemeris: Exposure of the moon's absolute attributes in the property tree. This includes the moon's absolute position, age and phase. For this, the new simgear MoonPos::get*() functions are tied to the property tree at "/ephemeris/moon/" using a new tieMoonPos() function. In addition the moon illumination factor is exposed by tying the simgear MoonPos::getIlluminanceFactor() function to the /environment/moonlight property. 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, The illuminance of the moon outside the atmosphere, I, is from equation 20 from: Krisciunas K. and Schaefer B.E. (1991). A model of the brightness of moonlight, Publ. Astron. Soc. Pacif. 103(667), 1033-1039 (DOI: http://dx.doi.org/10.1086/132921). For more background, see http://forum.flightgear.org/viewtopic.php?f=47&t=28201&start=60#p270516 . --- src/Environment/ephemeris.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Environment/ephemeris.cxx b/src/Environment/ephemeris.cxx index 630ae1156..0c3bfabbe 100644 --- a/src/Environment/ephemeris.cxx +++ b/src/Environment/ephemeris.cxx @@ -33,6 +33,11 @@ static void tieStar(const char* prop, Star* s, double (Star::*getter)() const) fgGetNode(prop, true)->tie(SGRawValueMethods<Star, double>(*s, getter, NULL)); } +static void tieMoonPos(const char* prop, MoonPos* s, double (MoonPos::*getter)() const) +{ + fgGetNode(prop, true)->tie(SGRawValueMethods<MoonPos, double>(*s, getter, NULL)); +} + Ephemeris::Ephemeris() : _impl(NULL), _latProp(NULL) @@ -60,6 +65,15 @@ void Ephemeris::init() tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye); tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat); + tieMoonPos("/ephemeris/moon/xg", _impl->get_moon(), &MoonPos::getxg); + tieMoonPos("/ephemeris/moon/yg", _impl->get_moon(), &MoonPos::getyg); + tieMoonPos("/ephemeris/moon/ze", _impl->get_moon(), &MoonPos::getze); + tieMoonPos("/ephemeris/moon/ye", _impl->get_moon(), &MoonPos::getye); + tieMoonPos("/ephemeris/moon/lat-deg", _impl->get_moon(), &MoonPos::getLat); + tieMoonPos("/ephemeris/moon/age", _impl->get_moon(), &MoonPos::getAge); + tieMoonPos("/ephemeris/moon/phase", _impl->get_moon(), &MoonPos::getPhase); + tieMoonPos("/environment/moonlight", _impl->get_moon(), &MoonPos::getIlluminanceFactor); + _latProp = fgGetNode("/position/latitude-deg", true); update(0.0);