]> git.mxchange.org Git - flightgear.git/blob - src/Environment/ridge_lift.hxx
- avoid duplicate computations
[flightgear.git] / src / Environment / ridge_lift.hxx
1 // simulates ridge lift
2 //
3 // Written by Patrice Poly
4 // Copyright (C) 2009 Patrice Poly - p.polypa@gmail.com
5 //
6 //
7 // Entirely based  on the paper : 
8 // http://carrier.csi.cam.ac.uk/forsterlewis/soaring/sim/fsx/dev/sim_probe/sim_probe_paper.html
9 // by Ian Forster-Lewis, University of Cambridge, 26th December 2007
10 //
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License as
14 // published by the Free Software Foundation; either version 2 of the
15 // License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 // General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
25 //
26
27
28 #ifndef _FG_RidgeLift_HXX
29 #define _FG_RidgeLift_HXX
30
31 #ifdef HAVE_CONFIG
32 #  include <config.h>
33 #endif
34
35
36 #include <string>
37 using std::string;
38
39
40 class FGRidgeLift : public SGSubsystem {
41 public:
42
43         FGRidgeLift();
44         ~FGRidgeLift();         
45         
46         virtual void bind();
47         virtual void unbind();
48         virtual void update(double dt);
49         virtual void init();
50
51         inline double getStrength() const { return strength; };
52
53         inline double get_probe_elev_m( int index ) const { return probe_elev_m[index]; };
54         inline double get_probe_lat_deg( int index ) const { return probe_lat_deg[index]; };
55         inline double get_probe_lon_deg( int index ) const { return probe_lon_deg[index]; };
56         inline double get_slope( int index ) const { return slope[index]; };
57
58 private:
59         //void init();
60
61         double dist_probe_m[5];
62
63         double strength;
64         double timer;
65
66         double probe_lat_rad[5];
67         double probe_lon_rad[5];
68
69         double probe_lat_deg[5];
70         double probe_lon_deg[5];
71
72         double alt;     
73         double probe_elev_m[5];
74
75         double slope[4];
76
77         double lift_factor;
78
79         inline double sign(double x) const {
80                 if( x == 0 ) return 0;
81                 return x > 0 ? 1.0 : -1.0;
82         }
83
84         SGPropertyNode_ptr _ridge_lift_fps_node;
85
86         SGPropertyNode_ptr _surface_wind_from_deg_node;
87         SGPropertyNode_ptr _surface_wind_speed_node;
88
89         SGPropertyNode_ptr _user_altitude_ft_node;
90         SGPropertyNode_ptr _user_altitude_agl_ft_node;
91         SGPropertyNode_ptr _earth_radius_node;
92         SGPropertyNode_ptr _user_longitude_node;
93         SGPropertyNode_ptr _user_latitude_node;
94
95 };
96
97 #endif  // _FG_RidgeLift_HXX