From 12dc71a3c0bca193b2cfe95469ecbc81ac7734c4 Mon Sep 17 00:00:00 2001 From: fredb Date: Tue, 30 Dec 2008 23:13:44 +0000 Subject: [PATCH 1/4] Csaba/Alexis : fix a NAN problem when wind is unspecified in a metar --- src/Environment/fgmetar.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Environment/fgmetar.cxx b/src/Environment/fgmetar.cxx index a543832e7..b2b331fbf 100644 --- a/src/Environment/fgmetar.cxx +++ b/src/Environment/fgmetar.cxx @@ -99,6 +99,8 @@ FGMetar::FGMetar(const string& icao, const string& proxy, const string& port, co _wind_range_from = _wind_range_to = _wind_dir; } + if (_wind_speed == SGMetarNaN) + _wind_speed = 0.0; if (_gust_speed == SGMetarNaN) _gust_speed = 0.0; From fd043ed56eddf536dc74923b445e78f0d81b10d3 Mon Sep 17 00:00:00 2001 From: fredb Date: Thu, 1 Jan 2009 10:18:13 +0000 Subject: [PATCH 2/4] Temporary hack to avoid NaN problems when _mp is negative (?). Discovered by Csaba --- src/FDM/YASim/PistonEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FDM/YASim/PistonEngine.cpp b/src/FDM/YASim/PistonEngine.cpp index 11b04fe7a..b032342d4 100644 --- a/src/FDM/YASim/PistonEngine.cpp +++ b/src/FDM/YASim/PistonEngine.cpp @@ -169,7 +169,7 @@ void PistonEngine::calc(float pressure, float temp, float speed) // pressure change can be assumed to be adiabatic. Calculate a // temperature change, and use that to get the density. // Note: need to model intercoolers here... - float T = temp * Math::pow(_mp/pressure, 2.0/7.0); + float T = temp * Math::pow((_mp*_mp)/(pressure*pressure), 1.0/7.0); float rho = _mp / (287.1f * T); // The actual fuel flow is determined only by engine RPM and the From 1a05695ff5bf34bdc407fa2647f07d4aca336204 Mon Sep 17 00:00:00 2001 From: jmt Date: Fri, 2 Jan 2009 12:34:28 +0000 Subject: [PATCH 3/4] NaN fix by Csaba/Jester - prefer atan2(x,y) to atan(a/y). --- src/AIModel/AICarrier.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 1a9a1d2b7..979e9710b 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -514,7 +514,7 @@ void FGAICarrier::UpdateWind( double dt) { + (rel_wind_speed_from_north_kts * rel_wind_speed_from_north_kts)); //calculate the relative wind direction - rel_wind_from_deg = atan(rel_wind_speed_from_east_kts/rel_wind_speed_from_north_kts) + rel_wind_from_deg = atan2(rel_wind_speed_from_east_kts, rel_wind_speed_from_north_kts) * SG_RADIANS_TO_DEGREES; // rationalise the output From 2b0ffae3398461271ef249624765fd6a5d44f7d4 Mon Sep 17 00:00:00 2001 From: timoore Date: Sat, 3 Jan 2009 00:15:58 +0000 Subject: [PATCH 4/4] Protect against divide-by-zero in setCameraParameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by Csaba Halász --- src/Main/CameraGroup.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index 2ff1bb169..c8e23c229 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -219,9 +219,11 @@ void CameraGroup::update(const osg::Vec3d& position, void CameraGroup::setCameraParameters(float vfov, float aspectRatio) { - _viewer->getCamera()->setProjectionMatrixAsPerspective(vfov, - 1.0f / aspectRatio, - _zNear, _zFar); + if (vfov != 0.0f && aspectRatio != 0.0f) + _viewer->getCamera() + ->setProjectionMatrixAsPerspective(vfov, + 1.0f / aspectRatio, + _zNear, _zFar); } }