]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGPhysicalProperty.h
Upgraded to latest weather data base code from Christian Mayer's and make
[flightgear.git] / src / WeatherCM / FGPhysicalProperty.h
1 /*****************************************************************************
2
3  Header:       FGPhysicalProperty.h     
4  Author:       Christian Mayer
5  Date started: 28.05.99
6
7  ---------- Copyright (C) 1999  Christian Mayer (vader@t-online.de) ----------
8
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
12  version.
13
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
17  details.
18
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.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 FUNCTIONAL DESCRIPTION
27 ------------------------------------------------------------------------------
28 Define the simulated physical property of the weather in one point
29
30 HISTORY
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 
38                                 suggestion
39 *****************************************************************************/
40
41 /****************************************************************************/
42 /* SENTRY                                                                   */
43 /****************************************************************************/
44 #ifndef FGPhysicalProperty_H
45 #define FGPhysicalProperty_H
46
47 /****************************************************************************/
48 /* INCLUDES                                                                 */
49 /****************************************************************************/
50 #include <Include/compiler.h>
51 #include <vector>
52 FG_USING_STD(vector);
53 FG_USING_NAMESPACE(std);
54
55 #include <Math/point3d.hxx>
56 #include <Voronoi/point2d.h>
57 #include "FGWeatherDefs.h"
58 #include "FGPhysicalProperties.h"
59
60 /****************************************************************************/
61 /* used for output:                                                         */
62 /****************************************************************************/
63 class FGPhysicalProperty
64 {
65 private:
66 protected:
67 public:
68     Point3D Wind;                       //Wind vector
69     Point3D Turbulence;                 //Turbulence vector
70     WeatherPrecition Temperature;       //in deg. Kelvin (I *only* accept SI!)
71     WeatherPrecition AirPressure;       //in Pascal (I *only* accept SI!)
72     WeatherPrecition VaporPressure;     //in Pascal (I *only* accept SI!)
73
74     FGPhysicalProperty();   //consructor to fill it with FG standart weather
75     FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude);
76
77     //allow calculations for easier handling such as interpolating
78     FGPhysicalProperty& operator = ( const FGPhysicalProperty& p );      // assignment of a Point3D
79     FGPhysicalProperty& operator += ( const FGPhysicalProperty& p );     // incrementation by a Point3D
80     FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p );     // decrementation by a Point3D
81     FGPhysicalProperty& operator *= ( const double& d );                 // multiplication by a constant
82     FGPhysicalProperty& operator /= ( const double& d );                 // division by a constant
83
84     friend FGPhysicalProperty operator - (const FGPhysicalProperty& p);             // -p1
85     friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b);  // p1 == p2?
86 };
87
88 typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
89 typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
90 typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
91
92 class FGPhysicalProperty3D : public FGPhysicalProperty
93 {
94 private:
95 protected:
96 public:
97     Point3D p;      //position of the property (lat/lon/alt)
98 };
99
100 typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
101 typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
102 typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
103
104 inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
105 {
106     Wind = p.Wind; 
107     Turbulence = p.Turbulence; 
108     Temperature = p.Temperature; 
109     AirPressure = p.AirPressure; 
110     VaporPressure = p.VaporPressure; 
111     return *this;
112 }
113
114 inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
115 {
116     Wind += p.Wind; 
117     Turbulence += p.Turbulence; 
118     Temperature += p.Temperature; 
119     AirPressure += p.AirPressure; 
120     VaporPressure += p.VaporPressure; 
121     return *this;
122 }
123
124 inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
125 {
126     Wind -= p.Wind; 
127     Turbulence -= p.Turbulence; 
128     Temperature -= p.Temperature; 
129     AirPressure -= p.AirPressure; 
130     VaporPressure -= p.VaporPressure; 
131     return *this;
132 }
133
134 inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double& d )
135 {
136     Wind *= d; 
137     Turbulence *= d; 
138     Temperature *= d; 
139     AirPressure *= d; 
140     VaporPressure *= d; 
141     return *this;
142 }
143
144 inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double& d )
145 {
146     Wind /= d; 
147     Turbulence /= d; 
148     Temperature /= d; 
149     AirPressure /= d; 
150     VaporPressure /= d; 
151     return *this;
152 }
153
154 inline  FGPhysicalProperty operator - (const FGPhysicalProperty& p)
155 {
156     FGPhysicalProperty x;
157     x.Wind = -p.Wind; 
158     x.Turbulence = -p.Turbulence; 
159     x.Temperature = -p.Temperature; 
160     x.AirPressure = -p.AirPressure; 
161     x.VaporPressure = -p.VaporPressure; 
162     return x;
163 }
164
165 inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
166 {
167     return (
168     (a.Wind == b.Wind) &&
169     (a.Turbulence == b.Turbulence) && 
170     (a.Temperature == b.Temperature) && 
171     (a.AirPressure == b.AirPressure) && 
172     (a.VaporPressure == b.VaporPressure)); 
173 }
174
175 inline bool operator != (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
176 {
177     return !(a == b);
178 }
179
180 inline FGPhysicalProperty operator + (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
181 {
182     return FGPhysicalProperty(a) += b;
183 }
184
185 inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
186 {
187     return FGPhysicalProperty(a) -= b;
188 }
189
190 inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecition& b)
191 {
192     return FGPhysicalProperty(a) *= b;
193 }
194
195 inline FGPhysicalProperty operator * (const WeatherPrecition& b, const FGPhysicalProperty& a)
196 {
197     return FGPhysicalProperty(a) *= b;
198 }
199
200 inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecition& b)
201 {
202     return FGPhysicalProperty(a) *= (1.0/b);
203 }
204
205
206 /****************************************************************************/
207 #endif /*FGPhysicalProperty_H*/