]> git.mxchange.org Git - flightgear.git/blob - src/FDM/LaRCsimIC.hxx
I tested:
[flightgear.git] / src / FDM / LaRCsimIC.hxx
1 /*******************************************************************************
2  
3  Header:       LaRCsimIC.hxx
4  Author:       Tony Peden
5  Date started: 10/9/00
6  
7  ------------- Copyright (C) 2000 Anthony K. Peden (apeden@earthlink.net) -------------
8  
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13  
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18  
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 */ 
26 #ifndef _LARCSIMIC_HXX
27 #define _LARCSIMIC_HXX
28
29 /*******************************************************************************
30 INCLUDES
31 *******************************************************************************/
32
33 #include <FDM/LaRCsim/ls_constants.h>
34 #include <FDM/LaRCsim/ls_types.h>
35
36 /*******************************************************************************
37 CLASS DECLARATION
38 *******************************************************************************/
39
40 #define KTS_TO_FPS 1.6889
41 #define M_TO_FT 3.2808399
42 #define DEFAULT_AGL_ALT 3.758099
43 #define DEFAULT_PITCH_ON_GROUND 0.0074002
44
45 typedef enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned };
46 typedef enum lsaltset { lssetasl, lssetagl };
47
48
49 class LaRCsimIC {
50 public:
51
52   LaRCsimIC(void);
53   ~LaRCsimIC(void);
54
55   void SetVcalibratedKtsIC(SCALAR tt);
56   void SetMachIC(SCALAR tt);
57   
58   void SetVtrueFpsIC(SCALAR tt);
59   
60   void SetVequivalentKtsIC(SCALAR tt);
61
62   void SetUBodyFpsIC(SCALAR tt);
63   void SetVBodyFpsIC(SCALAR tt);
64   void SetWBodyFpsIC(SCALAR tt);
65   
66   void SetVnorthFpsIC(SCALAR tt);
67   void SetVeastFpsIC(SCALAR tt);
68   void SetVdownFpsIC(SCALAR tt);
69   
70   void SetVNorthAirmassFpsIC(SCALAR tt);
71   void SetVEastAirmassFpsIC(SCALAR tt);
72   void SetVDownAirmassFpsIC(SCALAR tt);
73   
74   void SetAltitudeFtIC(SCALAR tt);
75   void SetAltitudeAGLFtIC(SCALAR tt);
76   
77   //"vertical" flight path, recalculate theta
78   inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*DEG_TO_RAD); }
79   void SetFlightPathAngleRadIC(SCALAR tt);
80   
81   //set speed first
82   void SetClimbRateFpmIC(SCALAR tt);
83   void SetClimbRateFpsIC(SCALAR tt);
84   
85   //use currently stored gamma, recalcualte theta
86   inline void SetAlphaDegIC(SCALAR tt)      { alpha=tt*DEG_TO_RAD; getTheta(); }
87   inline void SetAlphaRadIC(SCALAR tt)      { alpha=tt; getTheta(); }
88   
89   //use currently stored gamma, recalcualte alpha
90   inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*DEG_TO_RAD); }
91          void SetPitchAngleRadIC(SCALAR tt);
92
93   inline void SetBetaDegIC(SCALAR tt)       { beta=tt*DEG_TO_RAD; getTheta();}
94   inline void SetBetaRadIC(SCALAR tt)       { beta=tt; getTheta(); }
95   
96   inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*DEG_TO_RAD; getTheta(); }
97   inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); }
98
99   inline void SetHeadingDegIC(SCALAR tt)   { psi=tt*DEG_TO_RAD; }
100   inline void SetHeadingRadIC(SCALAR tt)   { psi=tt; }
101
102   inline void SetLatitudeGDDegIC(SCALAR tt)  { SetLatitudeGDRadIC(tt*DEG_TO_RAD); }
103          void SetLatitudeGDRadIC(SCALAR tt);
104
105   inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*DEG_TO_RAD; }
106   inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; }
107   
108   void SetRunwayAltitudeFtIC(SCALAR tt);
109
110   inline SCALAR GetVcalibratedKtsIC(void) { return sqrt(density_ratio*vt*vt)*V_TO_KNOTS; }
111   inline SCALAR GetVequivalentKtsIC(void) { return sqrt(density_ratio)*vt*V_TO_KNOTS; }
112   inline SCALAR GetVtrueKtsIC(void) { return vt*V_TO_KNOTS; }
113   inline SCALAR GetVtrueFpsIC(void) { return vt; }
114   inline SCALAR GetMachIC(void) { return vt/soundspeed; }
115
116   inline SCALAR GetAltitudeFtIC(void)    { return altitude; }
117   inline SCALAR GetAltitudeAGLFtIC(void) { return alt_agl; }
118   
119   inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; }
120
121   inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*RAD_TO_DEG; }
122   inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; }
123
124   inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; }
125   inline SCALAR GetClimbRateFpsIC(void) { return hdot; }
126
127   inline SCALAR GetAlphaDegIC(void)      { return alpha*RAD_TO_DEG; }
128   inline SCALAR GetAlphaRadIC(void)      { return alpha; }
129
130   inline SCALAR GetPitchAngleDegIC(void) { return theta*RAD_TO_DEG; }
131   inline SCALAR GetPitchAngleRadIC(void) { return theta; }
132
133
134   inline SCALAR GetBetaDegIC(void)       { return beta*RAD_TO_DEG; }
135   inline SCALAR GetBetaRadIC(void)       { return beta*RAD_TO_DEG; }
136
137   inline SCALAR GetRollAngleDegIC(void) { return phi*RAD_TO_DEG; }
138   inline SCALAR GetRollAngleRadIC(void) { return phi; }
139
140   inline SCALAR GetHeadingDegIC(void)   { return psi*RAD_TO_DEG; }
141   inline SCALAR GetHeadingRadIC(void)   { return psi; }
142
143   inline SCALAR GetLatitudeGDDegIC(void)  { return latitude_gd*RAD_TO_DEG; }
144   inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; }
145
146   inline SCALAR GetLongitudeDegIC(void) { return longitude*RAD_TO_DEG; }
147   inline SCALAR GetLongitudeRadIC(void) { return longitude; }
148
149   inline SCALAR GetUBodyFpsIC(void) { return vt*cos(alpha)*cos(beta); }
150   inline SCALAR GetVBodyFpsIC(void) { return vt*sin(beta); }
151   inline SCALAR GetWBodyFpsIC(void) { return vt*sin(alpha)*cos(beta); }
152   
153   inline SCALAR GetVnorthFpsIC(void) { calcNEDfromVt();return vnorth; }
154   inline SCALAR GetVeastFpsIC(void)  { calcNEDfromVt();return veast; }
155   inline SCALAR GetVdownFpsIC(void)  { calcNEDfromVt();return vdown; }
156   
157   inline SCALAR GetVnorthAirmassFpsIC(void) { return vnorthwind; }
158   inline SCALAR GetVeastAirmassFpsIC(void)  { return veastwind; }
159   inline SCALAR GetVdownAirmassFpsIC(void)  { return vdownwind; }
160   
161   inline SCALAR GetThetaRadIC(void) { return theta; }
162   inline SCALAR GetPhiRadIC(void)   { return phi; }
163   inline SCALAR GetPsiRadIC(void)   { return psi; }
164
165
166
167 private:
168   SCALAR vt,vtg,vw,vc,ve;
169   SCALAR alpha,beta,gamma,theta,phi,psi;
170   SCALAR mach;
171   SCALAR altitude,runway_altitude,hdot,alt_agl,sea_level_radius;
172   SCALAR latitude_gd,latitude_gc,longitude;
173   SCALAR u,v,w;
174   SCALAR vnorth,veast,vdown;
175   SCALAR vnorthwind, veastwind, vdownwind;
176   SCALAR p,T,soundspeed,density_ratio,rho;
177   
178   SCALAR xlo, xhi,xmin,xmax;
179   
180   typedef SCALAR (LaRCsimIC::*fp)(SCALAR x);
181   fp sfunc;
182
183   lsspeedset lastSpeedSet;
184   lsaltset lastAltSet;
185   
186   
187   void calcVtfromNED(void);
188   void calcNEDfromVt(void);
189   void calcSpeeds(void);
190   
191   
192   bool getAlpha(void);
193   bool getTheta(void);
194   SCALAR GammaEqOfTheta(SCALAR tt);
195   SCALAR GammaEqOfAlpha(SCALAR tt);
196   void get_atmosphere(void);
197   
198   
199   bool findInterval(SCALAR x,SCALAR guess);
200   bool solve(SCALAR *y, SCALAR x);
201 };
202
203 #endif