1 /*****************************************************************************
3 Header: FGPhysicalProperty.h
4 Author: Christian Mayer
7 -------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
26 FUNCTIONAL DESCRIPTION
27 ------------------------------------------------------------------------------
28 Define the simulated physical property of the weather in one point
31 ------------------------------------------------------------------------------
32 28.05.1999 Christian Mayer Created
33 16.06.1999 Durk Talsma Portability for Linux
34 20.06.1999 Christian Mayer Changed struct to class
35 20.06.1999 Christian Mayer added lots of consts
36 30.06.1999 Christian Mayer STL portability
37 11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
39 19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
40 and lots of wee code cleaning
41 *****************************************************************************/
43 /****************************************************************************/
45 /****************************************************************************/
46 #ifndef FGPhysicalProperty_H
47 #define FGPhysicalProperty_H
49 /****************************************************************************/
51 /****************************************************************************/
57 #include <simgear/compiler.h>
67 #include "FGWeatherDefs.h"
68 #include "FGPhysicalProperties.h"
71 SG_USING_NAMESPACE(std);
73 /****************************************************************************/
74 /* used for output: */
75 /****************************************************************************/
76 class FGPhysicalProperty;
77 bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
79 class FGPhysicalProperty
84 sgVec3 Wind; //Wind vector
85 sgVec3 Turbulence; //Turbulence vector
86 WeatherPrecision Temperature; //in deg. Kelvin (I *only* accept SI!)
87 WeatherPrecision AirPressure; //in Pascal (I *only* accept SI!)
88 WeatherPrecision VaporPressure; //in Pascal (I *only* accept SI!)
90 FGPhysicalProperty(); //consructor to fill it with FG standart weather
91 FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecision altitude);
93 //allow calculations for easier handling such as interpolating
94 FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a FGPhysicalProperty
95 FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a FGPhysicalProperty
96 FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a FGPhysicalProperty
97 FGPhysicalProperty& operator *= ( const double d ); // multiplication by a constant
98 FGPhysicalProperty& operator /= ( const double d ); // division by a constant
100 friend FGPhysicalProperty operator - (const FGPhysicalProperty& p); // -p1
101 friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
104 class FGPhysicalProperty3D : public FGPhysicalProperty
109 sgVec3 p; //position of the property (lat/lon/alt)
112 typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
113 typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
114 typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
116 typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
117 typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
118 typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
120 inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
122 sgCopyVec3(Wind, p.Wind);
123 sgCopyVec3(Turbulence, p.Turbulence);
124 Temperature = p.Temperature;
125 AirPressure = p.AirPressure;
126 VaporPressure = p.VaporPressure;
130 inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
132 sgAddVec3(Wind, p.Wind);
133 sgAddVec3(Turbulence, p.Turbulence);
134 Temperature += p.Temperature;
135 AirPressure += p.AirPressure;
136 VaporPressure += p.VaporPressure;
140 inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
142 sgSubVec3(Wind, p.Wind);
143 sgSubVec3(Turbulence, p.Turbulence);
144 Temperature -= p.Temperature;
145 AirPressure -= p.AirPressure;
146 VaporPressure -= p.VaporPressure;
150 inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double d )
152 sgScaleVec3(Wind, d);
153 sgScaleVec3(Turbulence, d);
160 inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double d )
162 sgScaleVec3(Wind, 1.0 / d);
163 sgScaleVec3(Turbulence, 1.0 / d);
170 inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
172 FGPhysicalProperty x;
173 sgNegateVec3(x.Wind, p.Wind);
174 sgNegateVec3(x.Turbulence, p.Turbulence);
175 x.Temperature = -p.Temperature;
176 x.AirPressure = -p.AirPressure;
177 x.VaporPressure = -p.VaporPressure;
181 inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
184 sgEqualVec3(a.Wind, b.Wind) &&
185 sgEqualVec3(a.Turbulence, b.Turbulence) &&
186 (a.Temperature == b.Temperature) &&
187 (a.AirPressure == b.AirPressure) &&
188 (a.VaporPressure == b.VaporPressure));
191 inline bool operator != (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
196 inline FGPhysicalProperty operator + (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
198 return FGPhysicalProperty(a) += b;
201 inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
203 return FGPhysicalProperty(a) -= b;
206 inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecision b)
208 return FGPhysicalProperty(a) *= b;
211 inline FGPhysicalProperty operator * (const WeatherPrecision b, const FGPhysicalProperty& a)
213 return FGPhysicalProperty(a) *= b;
216 inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecision b)
218 return FGPhysicalProperty(a) *= (1.0/b);
221 /****************************************************************************/
222 #endif /*FGPhysicalProperty_H*/