]> git.mxchange.org Git - flightgear.git/blob - src/Environment/environment.hxx
Merge branch 'next' of gitorious.org:fg/flightgear into next
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _ENVIRONMENT_HXX
25 #define _ENVIRONMENT_HXX
26
27 #include <simgear/compiler.h>
28
29 #include <cmath>
30
31 /**
32  * Model the natural environment.
33  *
34  * This class models the natural environment at a specific place and
35  * time.  A separate instance is necessary for each location or time.
36  *
37  * This class should eventually move to SimGear.
38  */
39 class FGEnvironment
40 {
41
42 public:
43
44   FGEnvironment();
45   FGEnvironment (const FGEnvironment &environment);
46   virtual ~FGEnvironment();
47
48   virtual void copy (const FGEnvironment &environment);
49
50   virtual void read (const SGPropertyNode * node);
51   
52   virtual double get_visibility_m () const;
53
54   virtual double get_temperature_sea_level_degc () const;
55   virtual double get_temperature_degc () const;
56   virtual double get_temperature_degf () const;
57   virtual double get_dewpoint_sea_level_degc () const;
58   virtual double get_dewpoint_degc () const;
59   virtual double get_pressure_sea_level_inhg () const;
60   virtual double get_pressure_inhg () const;
61   virtual double get_density_slugft3 () const;
62
63   virtual double get_relative_humidity () const;
64   virtual double get_density_tropo_avg_kgm3 () const;
65   virtual double get_altitude_half_to_sun_m () const;
66   virtual double get_altitude_tropo_top_m () const;
67
68   virtual double get_wind_from_heading_deg () const;
69   virtual double get_wind_speed_kt () const;
70   virtual double get_wind_from_north_fps () const;
71   virtual double get_wind_from_east_fps () const;
72   virtual double get_wind_from_down_fps () const;
73   virtual double get_thermal_lift_fps () const;
74   virtual double get_ridge_lift_fps () const;  
75   virtual double get_local_weather_lift_fps () const;
76
77   virtual double get_turbulence_magnitude_norm () const;
78   virtual double get_turbulence_rate_hz () const;
79
80   virtual void set_visibility_m (double v);
81
82   virtual void set_temperature_sea_level_degc (double t);
83   virtual void set_temperature_degc (double t);
84   virtual void set_dewpoint_sea_level_degc (double d);
85   virtual void set_dewpoint_degc (double d);
86   virtual void set_pressure_sea_level_inhg (double p);
87   virtual void set_pressure_inhg (double p);
88
89   virtual void set_wind_from_heading_deg (double h);
90   virtual void set_wind_speed_kt (double s);
91   virtual void set_wind_from_north_fps (double n);
92   virtual void set_wind_from_east_fps (double e);
93   virtual void set_wind_from_down_fps (double d);
94   virtual void set_thermal_lift_fps (double th);
95   virtual void set_ridge_lift_fps (double ri);
96   virtual void set_local_weather_lift_fps (double lwl);
97
98   virtual void set_turbulence_magnitude_norm (double t);
99   virtual void set_turbulence_rate_hz (double t);
100
101   virtual double get_elevation_ft () const;
102   virtual void set_elevation_ft (double elevation_ft);
103   virtual void set_altitude_half_to_sun_m (double alt);
104   virtual void set_altitude_tropo_top_m (double alt);
105
106   virtual bool set_live_update(bool live_update);
107
108   void _recalc_ne ();
109   void _recalc_alt_dewpoint ();
110   void _recalc_density ();
111   void _recalc_relative_humidity ();
112   void _recalc_alt_pt ();
113 private:
114   void _init();
115   void _recalc_hdgspd ();
116   void _recalc_updraft ();
117
118   void _recalc_sl_temperature ();
119   void _recalc_sl_dewpoint ();
120   void _recalc_sl_pressure ();
121
122   void _recalc_density_tropo_avg_kgm3 ();
123
124   double elevation_ft;
125   double visibility_m;
126
127   // Atmosphere
128   double temperature_sea_level_degc;
129   double temperature_degc;
130   double dewpoint_sea_level_degc;
131   double dewpoint_degc;
132   double pressure_sea_level_inhg;
133   double pressure_inhg;
134   double density_slugft3;
135
136   double density_tropo_avg_kgm3;
137   double relative_humidity;
138   double altitude_half_to_sun_m;
139   double altitude_tropo_top_m;
140
141   double turbulence_magnitude_norm;
142   double turbulence_rate_hz;
143
144   double wind_from_heading_deg;
145   double wind_speed_kt;
146
147   double wind_from_north_fps;
148   double wind_from_east_fps;
149   double wind_from_down_fps;
150   double thermal_lift_fps;
151   double ridge_lift_fps;
152   double local_weather_lift_fps;
153
154   bool     live_update;
155
156 };
157
158 void interpolate (const FGEnvironment * env1, const FGEnvironment * env2,
159                   double fraction, FGEnvironment * result);
160
161 #endif // _ENVIRONMENT_HXX