2002-02-19 14:21:19 +00:00
|
|
|
// environment.hxx -- routines to model the natural environment.
|
|
|
|
//
|
|
|
|
// Written by David Megginson, started February 2002.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002 David Megginson - david@megginson.com
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-02-19 14:21:19 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _ENVIRONMENT_HXX
|
|
|
|
#define _ENVIRONMENT_HXX
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2008-07-25 18:38:29 +00:00
|
|
|
#include <cmath>
|
2002-02-19 14:21:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model the natural environment.
|
|
|
|
*
|
|
|
|
* This class models the natural environment at a specific place and
|
|
|
|
* time. A separate instance is necessary for each location or time.
|
|
|
|
*
|
|
|
|
* This class should eventually move to SimGear.
|
|
|
|
*/
|
2002-02-22 22:51:34 +00:00
|
|
|
class FGEnvironment
|
2002-02-19 14:21:19 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
FGEnvironment();
|
2002-05-11 23:23:42 +00:00
|
|
|
FGEnvironment (const FGEnvironment &environment);
|
2002-02-19 14:21:19 +00:00
|
|
|
virtual ~FGEnvironment();
|
2003-06-08 14:47:03 +00:00
|
|
|
|
|
|
|
virtual void copy (const FGEnvironment &environment);
|
|
|
|
|
|
|
|
virtual void read (const SGPropertyNode * node);
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual double get_visibility_m () const;
|
2002-05-15 03:00:41 +00:00
|
|
|
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual double get_temperature_sea_level_degc () const;
|
2002-05-11 23:23:42 +00:00
|
|
|
virtual double get_temperature_degc () const;
|
2005-05-20 19:42:53 +00:00
|
|
|
virtual double get_temperature_degf () const;
|
2002-06-06 00:21:23 +00:00
|
|
|
virtual double get_dewpoint_sea_level_degc () const;
|
|
|
|
virtual double get_dewpoint_degc () const;
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual double get_pressure_sea_level_inhg () const;
|
2002-05-11 23:23:42 +00:00
|
|
|
virtual double get_pressure_inhg () const;
|
2002-05-15 03:00:41 +00:00
|
|
|
virtual double get_density_slugft3 () const;
|
|
|
|
|
2006-07-27 05:16:06 +00:00
|
|
|
virtual double get_relative_humidity () const;
|
|
|
|
virtual double get_density_tropo_avg_kgm3 () const;
|
|
|
|
virtual double get_altitude_half_to_sun_m () const;
|
|
|
|
virtual double get_altitude_tropo_top_m () const;
|
|
|
|
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual double get_wind_from_heading_deg () const;
|
|
|
|
virtual double get_wind_speed_kt () const;
|
|
|
|
virtual double get_wind_from_north_fps () const;
|
|
|
|
virtual double get_wind_from_east_fps () const;
|
|
|
|
virtual double get_wind_from_down_fps () const;
|
2009-04-20 14:20:05 +00:00
|
|
|
virtual double get_thermal_lift_fps () const;
|
|
|
|
virtual double get_ridge_lift_fps () const;
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2003-07-13 20:13:18 +00:00
|
|
|
virtual double get_turbulence_magnitude_norm () const;
|
|
|
|
virtual double get_turbulence_rate_hz () const;
|
2003-06-08 14:47:03 +00:00
|
|
|
|
2002-02-19 14:21:19 +00:00
|
|
|
virtual void set_visibility_m (double v);
|
2002-05-15 03:00:41 +00:00
|
|
|
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual void set_temperature_sea_level_degc (double t);
|
2002-05-11 23:23:42 +00:00
|
|
|
virtual void set_temperature_degc (double t);
|
2002-06-06 00:21:23 +00:00
|
|
|
virtual void set_dewpoint_sea_level_degc (double d);
|
|
|
|
virtual void set_dewpoint_degc (double d);
|
2002-02-22 23:37:45 +00:00
|
|
|
virtual void set_pressure_sea_level_inhg (double p);
|
2002-05-11 23:23:42 +00:00
|
|
|
virtual void set_pressure_inhg (double p);
|
2002-05-15 03:00:41 +00:00
|
|
|
|
2002-02-19 14:21:19 +00:00
|
|
|
virtual void set_wind_from_heading_deg (double h);
|
|
|
|
virtual void set_wind_speed_kt (double s);
|
|
|
|
virtual void set_wind_from_north_fps (double n);
|
|
|
|
virtual void set_wind_from_east_fps (double e);
|
|
|
|
virtual void set_wind_from_down_fps (double d);
|
2009-04-20 14:20:05 +00:00
|
|
|
virtual void set_thermal_lift_fps (double th);
|
|
|
|
virtual void set_ridge_lift_fps (double ri);
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2003-07-13 20:13:18 +00:00
|
|
|
virtual void set_turbulence_magnitude_norm (double t);
|
|
|
|
virtual void set_turbulence_rate_hz (double t);
|
2002-05-11 23:23:42 +00:00
|
|
|
|
|
|
|
virtual double get_elevation_ft () const;
|
|
|
|
virtual void set_elevation_ft (double elevation_ft);
|
2006-07-27 05:16:06 +00:00
|
|
|
virtual void set_altitude_half_to_sun_m (double alt);
|
|
|
|
virtual void set_altitude_tropo_top_m (double alt);
|
2002-05-11 23:23:42 +00:00
|
|
|
|
2009-05-31 10:18:45 +00:00
|
|
|
virtual bool set_live_update(bool live_update);
|
|
|
|
|
|
|
|
void _recalc_ne ();
|
|
|
|
void _recalc_alt_temperature ();
|
|
|
|
void _recalc_alt_dewpoint ();
|
|
|
|
void _recalc_alt_pressure ();
|
|
|
|
void _recalc_density ();
|
|
|
|
void _recalc_relative_humidity ();
|
2002-02-19 14:21:19 +00:00
|
|
|
private:
|
2009-01-14 08:19:41 +00:00
|
|
|
void _init();
|
2002-02-19 14:21:19 +00:00
|
|
|
void _recalc_hdgspd ();
|
2009-04-20 14:20:05 +00:00
|
|
|
void _recalc_updraft ();
|
2002-05-15 03:00:41 +00:00
|
|
|
|
|
|
|
void _recalc_sl_temperature ();
|
2002-06-06 00:21:23 +00:00
|
|
|
void _recalc_sl_dewpoint ();
|
2002-05-15 03:00:41 +00:00
|
|
|
void _recalc_sl_pressure ();
|
|
|
|
|
2006-07-27 05:16:06 +00:00
|
|
|
void _recalc_density_tropo_avg_kgm3 ();
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2006-07-27 05:16:06 +00:00
|
|
|
double elevation_ft;
|
2002-02-19 14:21:19 +00:00
|
|
|
double visibility_m;
|
2002-05-15 03:00:41 +00:00
|
|
|
|
2006-07-27 05:16:06 +00:00
|
|
|
// Atmosphere
|
2002-02-22 23:37:45 +00:00
|
|
|
double temperature_sea_level_degc;
|
2002-05-11 23:23:42 +00:00
|
|
|
double temperature_degc;
|
2002-06-06 00:21:23 +00:00
|
|
|
double dewpoint_sea_level_degc;
|
|
|
|
double dewpoint_degc;
|
2002-02-22 23:37:45 +00:00
|
|
|
double pressure_sea_level_inhg;
|
2002-05-11 23:23:42 +00:00
|
|
|
double pressure_inhg;
|
2002-05-15 03:00:41 +00:00
|
|
|
double density_slugft3;
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2006-07-27 05:16:06 +00:00
|
|
|
double density_tropo_avg_kgm3;
|
|
|
|
double relative_humidity;
|
|
|
|
double altitude_half_to_sun_m;
|
|
|
|
double altitude_tropo_top_m;
|
|
|
|
|
2003-07-13 20:13:18 +00:00
|
|
|
double turbulence_magnitude_norm;
|
|
|
|
double turbulence_rate_hz;
|
2003-06-08 14:47:03 +00:00
|
|
|
|
2002-02-19 14:21:19 +00:00
|
|
|
double wind_from_heading_deg;
|
|
|
|
double wind_speed_kt;
|
|
|
|
|
|
|
|
double wind_from_north_fps;
|
|
|
|
double wind_from_east_fps;
|
|
|
|
double wind_from_down_fps;
|
2009-04-20 14:20:05 +00:00
|
|
|
double thermal_lift_fps;
|
|
|
|
double ridge_lift_fps;
|
2002-02-19 14:21:19 +00:00
|
|
|
|
2009-05-31 10:18:45 +00:00
|
|
|
bool live_update;
|
|
|
|
|
2002-02-19 14:21:19 +00:00
|
|
|
};
|
|
|
|
|
2003-06-08 14:47:03 +00:00
|
|
|
void interpolate (const FGEnvironment * env1, const FGEnvironment * env2,
|
|
|
|
double fraction, FGEnvironment * result);
|
|
|
|
|
2002-02-19 14:21:19 +00:00
|
|
|
#endif // _ENVIRONMENT_HXX
|