]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGPhysicalProperty.h
Various SGI portability tweaks.
[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 *****************************************************************************/
38
39 /****************************************************************************/
40 /* SENTRY                                                                   */
41 /****************************************************************************/
42 #ifndef FGPhysicalProperty_H
43 #define FGPhysicalProperty_H
44
45 /****************************************************************************/
46 /* INCLUDES                                                                 */
47 /****************************************************************************/
48 #include <Include/compiler.h>
49 #include <vector>
50 FG_USING_STD(vector);
51 FG_USING_NAMESPACE(std);
52
53 #include <Math/point3d.hxx>
54 #include <Voronoi/point2d.h>
55 #include "FGWeatherDefs.h"
56 #include "FGPhysicalProperties.h"
57
58 /****************************************************************************/
59 /* used for output:                                                         */
60 /****************************************************************************/
61 class FGPhysicalProperty
62 {
63 private:
64 protected:
65 public:
66     Point3D Wind;                       //Wind vector
67     Point3D Turbulence;                 //Turbulence vector
68     WeatherPrecition Temperature;       //in deg. Kelvin (I *only* accept SI!)
69     WeatherPrecition AirPressure;       //in Pascal (I *only* accept SI!)
70     WeatherPrecition VaporPressure;     //in Pascal (I *only* accept SI!)
71
72     FGPhysicalProperty();   //consructor to fill it with FG standart weather
73     FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude);
74
75     //allow calculations for easier handling such as interpolating
76     FGPhysicalProperty& operator = ( const FGPhysicalProperty& p );      // assignment of a Point3D
77     FGPhysicalProperty& operator += ( const FGPhysicalProperty& p );     // incrementation by a Point3D
78     FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p );     // decrementation by a Point3D
79     FGPhysicalProperty& operator *= ( const double& d );                 // multiplication by a constant
80     FGPhysicalProperty& operator /= ( const double& d );                 // division by a constant
81
82     friend FGPhysicalProperty operator - (const FGPhysicalProperty& p);             // -p1
83     friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b);  // p1 == p2?
84 };
85
86 typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
87 typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
88 typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
89
90 class FGPhysicalProperty3D : public FGPhysicalProperty
91 {
92 private:
93 protected:
94 public:
95     Point3D p;      //position of the property (lat/lon/alt)
96 };
97
98 typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
99 typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
100 typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
101
102 inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
103 {
104     Wind = p.Wind; 
105     Turbulence = p.Turbulence; 
106     Temperature = p.Temperature; 
107     AirPressure = p.AirPressure; 
108     VaporPressure = p.VaporPressure; 
109     return *this;
110 }
111
112 inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
113 {
114     Wind += p.Wind; 
115     Turbulence += p.Turbulence; 
116     Temperature += p.Temperature; 
117     AirPressure += p.AirPressure; 
118     VaporPressure += p.VaporPressure; 
119     return *this;
120 }
121
122 inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
123 {
124     Wind -= p.Wind; 
125     Turbulence -= p.Turbulence; 
126     Temperature -= p.Temperature; 
127     AirPressure -= p.AirPressure; 
128     VaporPressure -= p.VaporPressure; 
129     return *this;
130 }
131
132 inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double& d )
133 {
134     Wind *= d; 
135     Turbulence *= d; 
136     Temperature *= d; 
137     AirPressure *= d; 
138     VaporPressure *= d; 
139     return *this;
140 }
141
142 inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double& d )
143 {
144     Wind /= d; 
145     Turbulence /= d; 
146     Temperature /= d; 
147     AirPressure /= d; 
148     VaporPressure /= d; 
149     return *this;
150 }
151
152 inline  FGPhysicalProperty operator - (const FGPhysicalProperty& p)
153 {
154     FGPhysicalProperty x;
155     x.Wind = -p.Wind; 
156     x.Turbulence = -p.Turbulence; 
157     x.Temperature = -p.Temperature; 
158     x.AirPressure = -p.AirPressure; 
159     x.VaporPressure = -p.VaporPressure; 
160     return x;
161 }
162
163 inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
164 {
165     return (
166     (a.Wind == b.Wind) &&
167     (a.Turbulence == b.Turbulence) && 
168     (a.Temperature == b.Temperature) && 
169     (a.AirPressure == b.AirPressure) && 
170     (a.VaporPressure == b.VaporPressure)); 
171 }
172
173 inline bool operator != (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
174 {
175     return !(a == b);
176 }
177
178 inline FGPhysicalProperty operator + (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
179 {
180     return FGPhysicalProperty(a) += b;
181 }
182
183 inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
184 {
185     return FGPhysicalProperty(a) -= b;
186 }
187
188 inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecition& b)
189 {
190     return FGPhysicalProperty(a) *= b;
191 }
192
193 inline FGPhysicalProperty operator * (const WeatherPrecition& b, const FGPhysicalProperty& a)
194 {
195     return FGPhysicalProperty(a) *= b;
196 }
197
198 inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecition& b)
199 {
200     return FGPhysicalProperty(a) *= (1.0/b);
201 }
202
203
204 /****************************************************************************/
205 #endif /*FGPhysicalProperty_H*/