From 4efbc97a4b0d841b4b3848c8c9c6f40f6f97f19f Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 16 May 2002 07:49:22 +0000 Subject: [PATCH] Revert the recent changes to Atmosphere.cpp. They were actually in the wrong place. The Atmosphere::getStd*() calls are used by the solver, and thus really need to return values for a "standard" atmosphere. Otherwise, an aircraft started up in Moscow will behave differently than one initialized in Cairo. :) The place where environmental pressure and temperature get inspected at runtime is in YASim.cxx. The changes there, happily, end up being even smaller than the ones to Atmosphere. This ends up replacing code only, and removing some comments. --- src/FDM/YASim/Atmosphere.cpp | 17 +++-------------- src/FDM/YASim/YASim.cxx | 18 +++++------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/FDM/YASim/Atmosphere.cpp b/src/FDM/YASim/Atmosphere.cpp index bc8a754dd..18b54dd24 100644 --- a/src/FDM/YASim/Atmosphere.cpp +++ b/src/FDM/YASim/Atmosphere.cpp @@ -1,5 +1,3 @@ -#include
- #include "Math.hpp" #include "Atmosphere.hpp" namespace yasim { @@ -42,26 +40,17 @@ const float GAMMA = 1.4f; float Atmosphere::getStdTemperature(float alt) { - if (fgGetBool("/environment/params/control-fdm-atmosphere")) - return fgGetDouble("/environment/temperature-degC") + 273.15; - else - return getRecord(alt, 1); + return getRecord(alt, 1); } float Atmosphere::getStdPressure(float alt) { - if (fgGetBool("/environment/params/control-fdm-atmosphere")) - return fgGetDouble("/environment/pressure-inhg") * 3386.39; - else - return getRecord(alt, 2); + return getRecord(alt, 2); } float Atmosphere::getStdDensity(float alt) { - if (fgGetBool("/environment/params/control-fdm-atmosphere")) - return fgGetDouble("/environment/density-slugft3") * 515.378; - else - return getRecord(alt, 3); + return getRecord(alt, 3); } float Atmosphere::calcVEAS(float spd, float pressure, float temp) diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index 6a6ba7971..2c87d1baf 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -28,6 +28,7 @@ static const float MPS2KTS = 3600.0/1852.0; static const float CM2GALS = 264.172037284; // gallons/cubic meter static const float KG2LBS = 2.20462262185; static const float W2HP = 1.3416e-3; +static const float INHG2PA = 3386.389; void YASim::printDEBUG() { @@ -235,15 +236,9 @@ void YASim::copyToYASim(bool copyState) // from the scenery and set it for others to find. double ground = globals->get_scenery()->get_cur_elev(); _set_Runway_altitude(ground * FT2M); - // cout << "YASIM: ground = " << ground << endl; - // You'd this this would work, but it doesn't. These values are - // always zero. Use a "standard" pressure intstead. - // - // float pressure = get_Static_pressure(); - // float temp = get_Static_temperature(); - float pressure = Atmosphere::getStdPressure(alt); - float temp = Atmosphere::getStdTemperature(alt); + float pressure = fgGetDouble("/environment/pressure-inhg") * INHG2PA; + float temp = fgGetDouble("/environment/temperature-degC") + 273.15; // Convert and set: Model* model = _fdm->getAirplane()->getModel(); @@ -373,11 +368,8 @@ void YASim::copyFromYASim() _set_V_rel_wind(Math::mag3(v)*M2FT); // units? - // These don't work, use a dummy based on altitude - // float P = get_Static_pressure(); - // float T = get_Static_temperature(); - float P = Atmosphere::getStdPressure(alt); - float T = Atmosphere::getStdTemperature(alt); + float P = fgGetDouble("/environment/pressure-inhg") * INHG2PA; + float T = fgGetDouble("/environment/temperature-degC") + 273.15; _set_V_equiv_kts(Atmosphere::calcVEAS(v[0], P, T)*MPS2KTS); _set_V_calibrated_kts(Atmosphere::calcVCAS(v[0], P, T)*MPS2KTS); _set_Mach_number(Atmosphere::calcMach(v[0], T));