From 46435edf1954002929425e5135bdc507aa563e59 Mon Sep 17 00:00:00 2001 From: Erik Hofman <erik@ehofman.com> Date: Tue, 27 Oct 2020 08:31:54 +0100 Subject: [PATCH] The fixed 60 degrees offset at EHAL turned out to be the lattitude offset (actually 53.45 degrees): The moon seems to be dragging the tide with an almost perfect 45 degrees 'bow-wave' along the equator. --- src/Time/tide.cxx | 14 ++++++++++++-- src/Time/tide.hxx | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Time/tide.cxx b/src/Time/tide.cxx index ce9df6420..b2214b43a 100644 --- a/src/Time/tide.cxx +++ b/src/Time/tide.cxx @@ -37,6 +37,8 @@ void FGTide::bind() SGPropertyNode *props = globals->get_props(); viewLon = props->getNode("sim/current-view/viewer-lon-deg", true); + viewLat = props->getNode("sim/current-view/viewer-lat-deg", true); + _tideAnimation = props->getNode("/environment/sea/surface/delta-T-tide", true); _tideLevelNorm = props->getNode("/sim/time/tide-level-norm", true); @@ -46,6 +48,8 @@ void FGTide::bind() void FGTide::unbind() { viewLon.reset(); + viewLat.reset(); + _tideLevelNorm.reset(); _tideAnimation.reset(); } @@ -56,8 +60,14 @@ void FGTide::update(double dt) FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting")); // Don't know where the 60 degrees offset comes from but it matches - // the tides perfectly (at EHAL). Something to figure out. - double viewer_lon = (viewLon->getDoubleValue() + 60.0)*SGD_PI/180.0; + // the tides perfectly at EHAL. Something to figure out. + // Eureka: It was the latitude (53.45 degrees north). + // It turns out that the moon is draging the tide with an almost + // perfect 45 degrees 'bow-wave' along the equator. Tests at SMBQ + // (0 degrees latitude) confirmed this finding. + double viewer_lon = (viewLon->getDoubleValue() + + fabs( viewLat->getDoubleValue() ) + ) * SGD_DEGREES_TO_RADIANS; double moon_lon = l->get_moon_lon() - viewer_lon; if (fabs(_prev_moon_lon - moon_lon) > (SGD_PI/360.0)) { diff --git a/src/Time/tide.hxx b/src/Time/tide.hxx index 1874e8549..b90cd0a2c 100644 --- a/src/Time/tide.hxx +++ b/src/Time/tide.hxx @@ -54,6 +54,7 @@ private: double _tide_level = 0; SGPropertyNode_ptr viewLon; + SGPropertyNode_ptr viewLat; SGPropertyNode_ptr _tideLevelNorm; SGPropertyNode_ptr _tideAnimation; };