]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGAirPressureItem.h
3b4d422f096bb6b5e9dabb04b31f7640ab3286be
[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 (fgfs@christianmayer.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 19.10.1999 Christian Mayer      change to use PLIB's sg instead of Point[2/3]D
39                                 and lots of wee code cleaning
40 *****************************************************************************/
41
42 /****************************************************************************/
43 /* SENTRY                                                                   */
44 /****************************************************************************/
45 #ifndef FGAirPressureItem_H
46 #define FGAirPressureItem_H
47
48 /****************************************************************************/
49 /* INCLUDES                                                                 */
50 /****************************************************************************/
51 #include <math.h>
52
53 #include "FGWeatherDefs.h"
54                 
55 /****************************************************************************/
56 /* DEFINES                                                                  */
57 /****************************************************************************/
58 class FGAirPressureItem;
59 FGAirPressureItem operator-(const FGAirPressureItem& arg);
60
61 /****************************************************************************/
62 /* CLASS DECLARATION                                                        */
63 /* NOTE: The value stored in 'value' is the air preasure that we'd have at  */
64 /*       an altitude of 0.0 The correct airpreasure at the stored altitude  */
65 /*       gets calulated when getValue() is called.                          */
66 /****************************************************************************/
67 class FGAirPressureItem
68 {
69 private:
70     WeatherPrecision value;
71
72 protected:
73 public:
74
75     FGAirPressureItem(const WeatherPrecision v) {value = v;}
76     FGAirPressureItem()                         {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
77
78     WeatherPrecision getValue(const WeatherPrecision& alt) const
79     { 
80         return (WeatherPrecision)((value / 101325.0) *
81             (
82             1.01325e5 + alt * (-1.19459535223623e1 + alt * (5.50461110007561e-4 + alt * (-1.13574703113648e-8 + alt * 8.61601726143988e-14)))
83             ));
84     };
85    
86     FGAirPressureItem& operator*=(const WeatherPrecision   arg);
87     FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
88     FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
89
90     friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
91 };
92
93 inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecision arg)
94 {
95   value *= arg;
96   return *this;
97 }
98
99 inline FGAirPressureItem& FGAirPressureItem::operator+= (const FGAirPressureItem& arg)
100 {
101   value += arg.value;
102   return *this;
103 }
104
105 inline FGAirPressureItem& FGAirPressureItem::operator-= (const FGAirPressureItem& arg)
106 {
107   value -= arg.value;
108   return *this;
109 }
110
111 inline FGAirPressureItem operator-(const FGAirPressureItem& arg)
112 {
113     return FGAirPressureItem(-arg.value);
114 }
115
116 /****************************************************************************/
117 #endif /*FGAirPressureItem_H*/
118
119
120
121
122
123