From 28b847da097882cb2eb299a5095aee517d0b6388 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 30 Sep 2009 20:53:22 +0000 Subject: [PATCH] Smooth out the time-to-intercept radial computation so it's a bit more useful. --- src/Instrumentation/navradio.cxx | 4 +++- src/Instrumentation/navradio.hxx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 3e779bbcd..404bb7300 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -137,6 +137,7 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : last_x(0.0), last_loc_dist(0.0), last_xtrack_error(0.0), + xrate_ms(0.0), _localizerWidth(5.0), _name(node->getStringValue("name", "nav")), _num(node->getIntValue("number", 0)), @@ -686,7 +687,8 @@ void FGNavRadio::updateCDI(double dt) ////////////////////////////////////////////////////////// double t = 0.0; if ( inrange && cdi_serviceable ) { - double xrate_ms = (last_xtrack_error - _cdiCrossTrackErrorM) / dt; + double cur_rate = (last_xtrack_error - _cdiCrossTrackErrorM) / dt; + xrate_ms = 0.99 * xrate_ms + 0.01 * cur_rate; if ( fabs(xrate_ms) > 0.00001 ) { t = _cdiCrossTrackErrorM / xrate_ms; } else { diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 116a90ce7..d88f0d876 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -135,6 +135,7 @@ class FGNavRadio : public SGSubsystem double last_x; double last_loc_dist; double last_xtrack_error; + double xrate_ms; double _localizerWidth; // cached localizer width in degrees string _name;