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
*****************************************************************************/
/****************************************************************************/
# include <config.h>
#endif
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
-#include <iostream>
+#include STL_IOSTREAM
#include <vector>
#include <map>
-#include "sg.h"
+#include <plib/sg.h>
#include "FGWeatherDefs.h"
#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 */
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:
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
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();
return *this;
}
+// slightly modified version that also makes the Mac happy
+inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
+{
+ typedef map<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator wind_iterator;
+ typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
+
+ // types to replace make_pair
+ typedef map<FGPhysicalProperties::Altitude, FGWindItem>::value_type wind_type;
+ typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::value_type turb_type;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::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<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
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();
return *this;
}
-
+#endif
inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const
{
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
{