From: ThorstenB Date: Sun, 26 Jun 2011 17:05:28 +0000 (+0200) Subject: #178: improve normalization issue (avoid loops altogether) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b2c03e4efcf6b41bfe5660ab8c9098c843b891e7;p=flightgear.git #178: improve normalization issue (avoid loops altogether) thanks to Torsten --- diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index a4c478be0..0c4864912 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -115,7 +115,7 @@ HeadingIndicatorDG::update (double dt) // Next, calculate time-based precession double offset = _offset_node->getDoubleValue(); offset -= dt * (0.25 / 60.0); // 360deg/day - SG_NORMALIZE_RANGE(offset, -360.0, 360.0); + offset = SGMiscd::normalizePeriodic(-360.0,360.0,offset); _offset_node->setDoubleValue(offset); // No magvar - set the alignment manually @@ -153,11 +153,7 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; - // sanity check: bail out when the FDM runs wild, to avoid - // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. - if (fabs(heading)>1e10) - return; - SG_NORMALIZE_RANGE(heading, 0.0, 360.0); + heading = SGMiscd::normalizePeriodic(0.0,360.0,heading); _heading_out_node->setDoubleValue(heading);