]> git.mxchange.org Git - flightgear.git/blob - src/Environment/ridge_lift.hxx
Implementation of ridge lift from Patrice Poly based on an algorithm of Ian Forster...
[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_0() const { return probe_elev_m[0]; };
54         inline double get_probe_elev_m_1() const { return probe_elev_m[1]; };
55         inline double get_probe_elev_m_2() const { return probe_elev_m[2]; };
56         inline double get_probe_elev_m_3() const { return probe_elev_m[3]; };
57         inline double get_probe_elev_m_4() const { return probe_elev_m[4]; };
58
59         inline double get_probe_lat_0() const { return probe_lat_deg[0]; };
60         inline double get_probe_lat_1() const { return probe_lat_deg[1]; };
61         inline double get_probe_lat_2() const { return probe_lat_deg[2]; };
62         inline double get_probe_lat_3() const { return probe_lat_deg[3]; };
63         inline double get_probe_lat_4() const { return probe_lat_deg[4]; };
64
65         inline double get_probe_lon_0() const { return probe_lon_deg[0]; };
66         inline double get_probe_lon_1() const { return probe_lon_deg[1]; };
67         inline double get_probe_lon_2() const { return probe_lon_deg[2]; };
68         inline double get_probe_lon_3() const { return probe_lon_deg[3]; };
69         inline double get_probe_lon_4() const { return probe_lon_deg[4]; };
70
71         inline double get_slope_0() const { return slope[0]; };
72         inline double get_slope_1() const { return slope[1]; };
73         inline double get_slope_2() const { return slope[2]; };
74         inline double get_slope_3() const { return slope[3]; };
75
76 private:
77         //void init();
78         void Run(double dt);
79
80         double dist_probe_m[5];
81         double BOUNDARY1_m;
82         double BOUNDARY2_m;
83         double PI; // pi
84         double deg2rad;
85         double rad2deg;
86
87         bool scanned;
88
89         double strength;
90         double timer;
91
92         double probe_lat_rad[5];
93         double probe_lon_rad[5];
94
95         double probe_lat_deg[5];
96         double probe_lon_deg[5];
97
98         double alt;     
99         double probe_elev_m[5];
100
101         double slope[4];
102         double earth_rad_ft;
103         double earth_rad_m;
104         double user_latitude_deg;
105         double user_longitude_deg;
106         //double user_altitude;
107         double user_altitude_agl_ft;
108         double user_altitude_agl_m;
109
110         double sign(double x);
111
112         SGPropertyNode_ptr _ridge_lift_fps_node;
113
114         SGPropertyNode_ptr _surface_wind_from_deg_node;
115         SGPropertyNode_ptr _surface_wind_speed_node;
116
117         SGPropertyNode_ptr _user_altitude_ft_node;
118         SGPropertyNode_ptr _user_altitude_agl_ft_node;
119         SGPropertyNode_ptr _earth_radius_node;
120         SGPropertyNode_ptr _user_longitude_node;
121         SGPropertyNode_ptr _user_latitude_node;
122
123 };
124
125 #endif  // _FG_RidgeLift_HXX