]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGAirPressureItem.h
9040b5705f4f6463cbc7b4a2a5f610c8c5e2fa23
[flightgear.git] / src / WeatherCM / FGAirPressureItem.h
1 /*****************************************************************************
2
3  Header:       FGAirPressureItem.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 Air pressure item that is stored in the micro weather class
29
30 HISTORY
31 ------------------------------------------------------------------------------
32 28.05.1999 Christian Mayer      Created
33 08.06.1999 Christian Mayer      Added international air preasure formula
34 16.06.1999 Durk Talsma          Portability for Linux
35 20.06.1999 Christian Mayer      added lots of consts
36 11.10.1999 Christian Mayer      changed set<> to map<> on Bernie Bright's 
37                                 suggestion
38 *****************************************************************************/
39
40 /****************************************************************************/
41 /* SENTRY                                                                   */
42 /****************************************************************************/
43 #ifndef FGAirPressureItem_H
44 #define FGAirPressureItem_H
45
46 /****************************************************************************/
47 /* INCLUDES                                                                 */
48 /****************************************************************************/
49 #include "FGWeatherDefs.h"
50 #include <math.h>
51                 
52 /****************************************************************************/
53 /* DEFINES                                                                  */
54 /****************************************************************************/
55 class FGAirPressureItem;
56 FGAirPressureItem operator-(const FGAirPressureItem& arg);
57
58 /****************************************************************************/
59 /* CLASS DECLARATION                                                        */
60 /* NOTE: The value stored in 'value' is the air preasure that we'd have at  */
61 /*       an altitude of 0.0 The correct airpreasure at the stored altitude  */
62 /*       gets calulated when getValue() is called.                          */
63 /****************************************************************************/
64 class FGAirPressureItem
65 {
66 private:
67     WeatherPrecition value;
68 protected:
69 public:
70
71     FGAirPressureItem(const WeatherPrecition& v)    {value = v;}
72     FGAirPressureItem()                             {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
73
74     //WeatherPrecition getValue(WeatherPrecition alt) { return value * pow(1.0 - 0.0065*alt/288.0, 5.255); };
75
76     WeatherPrecition getValue(const WeatherPrecition& alt) const
77     { 
78         return (WeatherPrecition)((value / 101325.0) *
79             (
80             1.01325e5 + alt * (-1.19459535223623e1 + alt * (5.50461110007561e-4 + alt * (-1.13574703113648e-8 + alt * 8.61601726143988e-14)))
81             ));
82     };
83    
84     FGAirPressureItem& operator*=(const WeatherPrecition& arg);
85     FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
86     FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
87
88     friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
89 };
90
91 inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecition& arg)
92 {
93   value *= arg;
94   return *this;
95 }
96
97 inline FGAirPressureItem& FGAirPressureItem::operator+= (const FGAirPressureItem& arg)
98 {
99   value += arg.value;
100   return *this;
101 }
102
103 inline FGAirPressureItem& FGAirPressureItem::operator-= (const FGAirPressureItem& arg)
104 {
105   value -= arg.value;
106   return *this;
107 }
108
109 inline FGAirPressureItem operator-(const FGAirPressureItem& arg)
110 {
111     return FGAirPressureItem(-arg.value);
112 }
113
114 /****************************************************************************/
115 #endif /*FGAirPressureItem_H*/
116
117
118
119
120
121