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 /****************************************************************************/
52 #include <Include/compiler.h>
58 #include "FGWeatherDefs.h"
59 #include "FGPhysicalProperties.h"
62 FG_USING_NAMESPACE(std);
64 /****************************************************************************/
65 /* used for output: */
66 /****************************************************************************/
67 class FGPhysicalProperty;
68 bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
70 class FGPhysicalProperty
75 sgVec3 Wind; //Wind vector
76 sgVec3 Turbulence; //Turbulence vector
77 WeatherPrecision Temperature; //in deg. Kelvin (I *only* accept SI!)
78 WeatherPrecision AirPressure; //in Pascal (I *only* accept SI!)
79 WeatherPrecision VaporPressure; //in Pascal (I *only* accept SI!)
81 FGPhysicalProperty(); //consructor to fill it with FG standart weather
82 FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecision altitude);
84 //allow calculations for easier handling such as interpolating
85 FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a FGPhysicalProperty
86 FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a FGPhysicalProperty
87 FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a FGPhysicalProperty
88 FGPhysicalProperty& operator *= ( const double d ); // multiplication by a constant
89 FGPhysicalProperty& operator /= ( const double d ); // division by a constant
91 friend FGPhysicalProperty operator - (const FGPhysicalProperty& p); // -p1
92 friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
95 class FGPhysicalProperty3D : public FGPhysicalProperty
100 sgVec3 p; //position of the property (lat/lon/alt)
103 typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
104 typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
105 typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
107 typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
108 typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
109 typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
111 inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
113 sgCopyVec3(Wind, p.Wind);
114 sgCopyVec3(Turbulence, p.Turbulence);
115 Temperature = p.Temperature;
116 AirPressure = p.AirPressure;
117 VaporPressure = p.VaporPressure;
121 inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
123 sgAddVec3(Wind, p.Wind);
124 sgAddVec3(Turbulence, p.Turbulence);
125 Temperature += p.Temperature;
126 AirPressure += p.AirPressure;
127 VaporPressure += p.VaporPressure;
131 inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
133 sgSubVec3(Wind, p.Wind);
134 sgSubVec3(Turbulence, p.Turbulence);
135 Temperature -= p.Temperature;
136 AirPressure -= p.AirPressure;
137 VaporPressure -= p.VaporPressure;
141 inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double d )
143 sgScaleVec3(Wind, d);
144 sgScaleVec3(Turbulence, d);
151 inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double d )
153 sgScaleVec3(Wind, 1.0 / d);
154 sgScaleVec3(Turbulence, 1.0 / d);
161 inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
163 FGPhysicalProperty x;
164 sgNegateVec3(x.Wind, p.Wind);
165 sgNegateVec3(x.Turbulence, p.Turbulence);
166 x.Temperature = -p.Temperature;
167 x.AirPressure = -p.AirPressure;
168 x.VaporPressure = -p.VaporPressure;
172 inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
175 sgEqualVec3(a.Wind, b.Wind) &&
176 sgEqualVec3(a.Turbulence, b.Turbulence) &&
177 (a.Temperature == b.Temperature) &&
178 (a.AirPressure == b.AirPressure) &&
179 (a.VaporPressure == b.VaporPressure));
182 inline bool operator != (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
187 inline FGPhysicalProperty operator + (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
189 return FGPhysicalProperty(a) += b;
192 inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
194 return FGPhysicalProperty(a) -= b;
197 inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecision b)
199 return FGPhysicalProperty(a) *= b;
202 inline FGPhysicalProperty operator * (const WeatherPrecision b, const FGPhysicalProperty& a)
204 return FGPhysicalProperty(a) *= b;
207 inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecision b)
209 return FGPhysicalProperty(a) *= (1.0/b);
212 /****************************************************************************/
213 #endif /*FGPhysicalProperty_H*/