From 317e48ba4f590894c01de276739e47da81f99296 Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 16 Feb 2003 20:47:40 +0000 Subject: [PATCH] Jim Wilson: Here's a patch to fix the asi problem (it affects most aircraft panels). [ Avoids a sqrt( x < 0 ) ] --- src/Instrumentation/airspeed_indicator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Instrumentation/airspeed_indicator.cxx b/src/Instrumentation/airspeed_indicator.cxx index 46eb585c8..5ae754332 100644 --- a/src/Instrumentation/airspeed_indicator.cxx +++ b/src/Instrumentation/airspeed_indicator.cxx @@ -59,7 +59,9 @@ AirspeedIndicator::update (double dt) double p = _static_pressure_node->getDoubleValue(); double q = ( pt - p ) * INHGTOPSF; // dynamic pressure - // Now, reverse the equation + // Now, reverse the equation (normalize dynamic pressure to + // avoid "nan" results from sqrt) + if ( q < 0 ) { q = 0.0; } double v_fps = sqrt((2 * q) / SEA_LEVEL_DENSITY_SLUGFT3); // Publish the indicated airspeed