X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWeatherCM%2FFGPhysicalProperties.h;h=2e39d5b6b82d5d557eeba91d16fb5a41ab3915da;hb=8199ece7dcca6b45237fab8647205effa6e38bcf;hp=3d235f291313d4a3df4e702cf577aa4d91e98daa;hpb=275154500802cc9405b5905b3b055e5c4a17b33f;p=flightgear.git diff --git a/src/WeatherCM/FGPhysicalProperties.h b/src/WeatherCM/FGPhysicalProperties.h index 3d235f291..2e39d5b6b 100644 --- a/src/WeatherCM/FGPhysicalProperties.h +++ b/src/WeatherCM/FGPhysicalProperties.h @@ -38,6 +38,10 @@ HISTORY suggestion 19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D and lots of wee code cleaning +15.12.1999 Christian Mayer changed the air pressure calculation to a much + more realistic formula. But as I need for that + the temperature I moved the code to + FGPhysicalProperties *****************************************************************************/ /****************************************************************************/ @@ -49,13 +53,21 @@ HISTORY /****************************************************************************/ /* INCLUDES */ /****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include +#endif -#include +#include + +#ifdef HAVE_WINDOWS_H +# include +#endif + +#include STL_IOSTREAM #include #include -#include "sg.h" +#include #include "FGWeatherDefs.h" @@ -66,9 +78,9 @@ HISTORY #include "FGCloudItem.h" #include "FGSnowRain.h" -FG_USING_STD(vector); -FG_USING_STD(map); -FG_USING_NAMESPACE(std); +SG_USING_STD(vector); +SG_USING_STD(map); +SG_USING_NAMESPACE(std); /****************************************************************************/ /* FOREWARD DEFINITIONS */ @@ -89,9 +101,9 @@ public: map Clouds; //amount of covering and type - WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,... + WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,... SnowRainType snowRainType; - WeatherPrecision LightningProbability; + WeatherPrecision LightningProbability; //in lightnings per second FGPhysicalProperties(); //consructor to fill it with FG standart weather @@ -99,7 +111,7 @@ public: void WindAt (sgVec3 ret, const WeatherPrecision a) const; void TurbulenceAt (sgVec3 ret, const WeatherPrecision a) const; WeatherPrecision TemperatureAt (const WeatherPrecision a) const; - WeatherPrecision AirPressureAt (const WeatherPrecision a) const; + WeatherPrecision AirPressureAt (const WeatherPrecision x) const; //x is used here instead of a on purpose WeatherPrecision VaporPressureAt(const WeatherPrecision a) const; //for easier access to the cloud stuff: @@ -110,6 +122,32 @@ public: FGPhysicalProperties& operator *= ( const WeatherPrecision d ); FGPhysicalProperties& operator += ( const FGPhysicalProperties& p ); FGPhysicalProperties& operator -= ( const FGPhysicalProperties& p ); + + //for easy binding to the property system + WeatherPrecision getWind_x( int number ) const; + WeatherPrecision getWind_y( int number ) const; + WeatherPrecision getWind_z( int number ) const; + WeatherPrecision getWind_a( int number ) const; + void setWind_x( int number, WeatherPrecision x); + void setWind_y( int number, WeatherPrecision y); + void setWind_z( int number, WeatherPrecision z); + void setWind_a( int number, WeatherPrecision a); + WeatherPrecision getTurbulence_x( int number ) const; + WeatherPrecision getTurbulence_y( int number ) const; + WeatherPrecision getTurbulence_z( int number ) const; + WeatherPrecision getTurbulence_a( int number ) const; + void setTurbulence_x( int number, WeatherPrecision x); + void setTurbulence_y( int number, WeatherPrecision y); + void setTurbulence_z( int number, WeatherPrecision z); + void setTurbulence_a( int number, WeatherPrecision a); + WeatherPrecision getTemperature_x( int number ) const; + WeatherPrecision getTemperature_a( int number ) const; + void setTemperature_x( int number, WeatherPrecision x); + void setTemperature_a( int number, WeatherPrecision a); + WeatherPrecision getVaporPressure_x( int number ) const; + WeatherPrecision getVaporPressure_a( int number ) const; + void setVaporPressure_x( int number, WeatherPrecision x); + void setVaporPressure_a( int number, WeatherPrecision a); }; class FGPhysicalProperties2D : public FGPhysicalProperties @@ -139,48 +177,6 @@ typedef vector FGPhysicalProperties2DVecto typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt; typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt; -inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p ) -{ - typedef map::const_iterator wind_iterator; - typedef map::const_iterator turbulence_iterator; - typedef map::const_iterator scalar_iterator; - - out << "Position: (" << p.p[0] << ", " << p.p[1] << ", " << p.p[2] << ")\n"; - - out << "Stored Wind: "; - for (wind_iterator WindIt = p.Wind.begin(); - WindIt != p.Wind.end(); - WindIt++) - out << "(" << WindIt->first << ") at (" << WindIt->second.x() << ", " << WindIt->second.y() << ", " << WindIt->second.z() << ") m; "; - out << "\n"; - - out << "Stored Turbulence: "; - for (turbulence_iterator TurbulenceIt = p.Turbulence.begin(); - TurbulenceIt != p.Turbulence.end(); - TurbulenceIt++) - out << "(" << TurbulenceIt->first << ") at (" << TurbulenceIt->second.x() << ", " << TurbulenceIt->second.y() << ", " << TurbulenceIt->second.z() << ") m; "; - out << "\n"; - - out << "Stored Temperature: "; - for (scalar_iterator TemperatureIt = p.Temperature.begin(); - TemperatureIt != p.Temperature.end(); - TemperatureIt++) - out << TemperatureIt->first << " at " << TemperatureIt->second << "m; "; - out << "\n"; - - out << "Stored AirPressure: "; - out << p.AirPressure.getValue(0) << " at " << 0.0 << "m; "; - out << "\n"; - - out << "Stored VaporPressure: "; - for (scalar_iterator VaporPressureIt = p.VaporPressure.begin(); - VaporPressureIt != p.VaporPressure.end(); - VaporPressureIt++) - out << VaporPressureIt->first << " at " << VaporPressureIt->second << "m; "; - out << "\n"; - - return out << "\n"; -} inline FGPhysicalProperties& FGPhysicalProperties::operator = ( const FGPhysicalProperties& p ) @@ -248,7 +244,7 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysical if (!Temperature.insert(*TemperatureIt).second) Temperature[TemperatureIt->first] += TemperatureIt->second; - AirPressure += p.AirPressure.getValue(0.0); + AirPressure += p.AirPressure.getValue(); for (scalar_iterator VaporPressureIt = p.VaporPressure.begin(); VaporPressureIt != p.VaporPressure.end(); @@ -259,6 +255,49 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysical return *this; } +// slightly modified version that also makes the Mac happy +inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p) +{ + typedef map::const_iterator wind_iterator; + typedef map::const_iterator turbulence_iterator; + typedef map::const_iterator scalar_iterator; + + // types to replace make_pair + typedef map::value_type wind_type; + typedef map::value_type turb_type; + typedef map::value_type weather_type; + + for (wind_iterator WindIt = p.Wind.begin(); + WindIt != p.Wind.end(); + WindIt++) + if (!Wind.insert( wind_type(WindIt->first, -WindIt->second) ).second) + // when it's not inserted => it's already existing + Wind[WindIt->first] -= WindIt->second; //=> substract the value + + for (turbulence_iterator TurbulenceIt = p.Turbulence.begin(); + TurbulenceIt != p.Turbulence.end(); + TurbulenceIt++) + if (!Turbulence.insert( turb_type(TurbulenceIt->first, -TurbulenceIt->second) ).second) + Turbulence[TurbulenceIt->first] -= TurbulenceIt->second; + + for (scalar_iterator TemperatureIt = p.Temperature.begin(); + TemperatureIt != p.Temperature.end(); + TemperatureIt++) + if (!Temperature.insert( weather_type(TemperatureIt->first, -TemperatureIt->second) ).second) + Temperature[TemperatureIt->first] -= TemperatureIt->second; + + AirPressure -= p.AirPressure.getValue(); + + for (scalar_iterator VaporPressureIt = p.VaporPressure.begin(); + VaporPressureIt != p.VaporPressure.end(); + VaporPressureIt++) + if (!VaporPressure.insert( weather_type(VaporPressureIt->first, -VaporPressureIt->second) ).second) + VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second; + + return *this; +} + +#if 0 // old version inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p) { typedef map::const_iterator wind_iterator; @@ -283,7 +322,7 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysical if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second) Temperature[TemperatureIt->first] -= TemperatureIt->second; - AirPressure -= p.AirPressure.getValue(0.0); + AirPressure -= p.AirPressure.getValue(); for (scalar_iterator VaporPressureIt = p.VaporPressure.begin(); VaporPressureIt != p.VaporPressure.end(); @@ -294,7 +333,7 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysical return *this; } - +#endif inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const { @@ -336,10 +375,8 @@ inline WeatherPrecision FGPhysicalProperties::TemperatureAt(const WeatherPrecisi return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second; } -inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision a) const -{ - return AirPressure.getValue(a); -} +//inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision x) const +//moved to FGPhysicalProperties.cpp as it got too complex to inline inline WeatherPrecision FGPhysicalProperties::VaporPressureAt(const WeatherPrecision a) const {