]> git.mxchange.org Git - flightgear.git/blob - src/Environment/environment.hxx
66a221fc1e4340e42f50315d7dfc70a2029c39a3
[flightgear.git] / src / Environment / environment.hxx
1 // environment.hxx -- routines to model the natural environment.
2 //
3 // Written by David Megginson, started February 2002.
4 //
5 // Copyright (C) 2002  David Megginson - david@megginson.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _ENVIRONMENT_HXX
25 #define _ENVIRONMENT_HXX
26
27 #include <simgear/compiler.h>
28
29 #include <Main/fgfs.hxx>
30
31 #ifdef SG_HAVE_STD_INCLUDES
32 #  include <cmath>
33 #else
34 #  include <math.h>
35 #endif
36
37 class SGInterpTable;
38
39
40 /**
41  * Model the natural environment.
42  *
43  * This class models the natural environment at a specific place and
44  * time.  A separate instance is necessary for each location or time.
45  *
46  * This class should eventually move to SimGear.
47  */
48 class FGEnvironment
49 {
50
51 public:
52
53   FGEnvironment();
54   FGEnvironment (const FGEnvironment &environment);
55   virtual ~FGEnvironment();
56   
57   virtual double get_visibility_m () const;
58
59   virtual double get_temperature_sea_level_degc () const;
60   virtual double get_temperature_degc () const;
61   virtual double get_pressure_sea_level_inhg () const;
62   virtual double get_pressure_inhg () const;
63   virtual double get_density_sea_level_slugft3 () const;
64   virtual double get_density_slugft3 () const;
65
66   virtual double get_wind_from_heading_deg () const;
67   virtual double get_wind_speed_kt () const;
68   virtual double get_wind_from_north_fps () const;
69   virtual double get_wind_from_east_fps () const;
70   virtual double get_wind_from_down_fps () const;
71
72   virtual void set_visibility_m (double v);
73
74   virtual void set_temperature_sea_level_degc (double t);
75   virtual void set_temperature_degc (double t);
76   virtual void set_pressure_sea_level_inhg (double p);
77   virtual void set_pressure_inhg (double p);
78   virtual void set_density_sea_level_slugft3 (double d);
79   virtual void set_density_slugft3 (double d);
80
81   virtual void set_wind_from_heading_deg (double h);
82   virtual void set_wind_speed_kt (double s);
83   virtual void set_wind_from_north_fps (double n);
84   virtual void set_wind_from_east_fps (double e);
85   virtual void set_wind_from_down_fps (double d);
86
87 protected:
88
89   friend class FGEnvironmentMgr;
90
91   virtual double get_elevation_ft () const;
92   virtual void set_elevation_ft (double elevation_ft);
93
94 private:
95
96   void _setup_tables ();
97
98   void _recalc_hdgspd ();
99   void _recalc_ne ();
100
101   void _recalc_sl_temperature ();
102   void _recalc_alt_temperature ();
103   void _recalc_sl_pressure ();
104   void _recalc_alt_pressure ();
105   void _recalc_sl_density ();
106   void _recalc_alt_density ();
107
108   SGInterpTable * _temperature_degc_table;
109   SGInterpTable * _pressure_inhg_table;
110   SGInterpTable * _density_slugft3_table;
111
112   double elevation_ft;
113
114   double visibility_m;
115
116                                 // Atmosphere
117   double temperature_sea_level_degc;
118   double temperature_degc;
119   double pressure_sea_level_inhg;
120   double pressure_inhg;
121   double density_sea_level_slugft3;
122   double density_slugft3;
123
124   double wind_from_heading_deg;
125   double wind_speed_kt;
126
127   double wind_from_north_fps;
128   double wind_from_east_fps;
129   double wind_from_down_fps;
130
131 };
132
133 #endif // _ENVIRONMENT_HXX