1 /*******************************************************************************
7 ------------- Copyright (C) 2000 Anthony K. Peden (apeden@earthlink.net) -------------
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
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
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
26 #ifndef _LARCSIMIC_HXX
27 #define _LARCSIMIC_HXX
29 /*******************************************************************************
31 *******************************************************************************/
35 #include "ls_constants.h"
38 /*******************************************************************************
40 *******************************************************************************/
42 #define KTS_TO_FPS 1.6889
43 #define M_TO_FT 3.2808399
44 #define DEFAULT_AGL_ALT 3.758099
45 #define DEFAULT_PITCH_ON_GROUND 0.0074002
47 enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned };
48 enum lsaltset { lssetasl, lssetagl };
57 void SetVcalibratedKtsIC(SCALAR tt);
58 void SetMachIC(SCALAR tt);
60 void SetVtrueFpsIC(SCALAR tt);
62 void SetVequivalentKtsIC(SCALAR tt);
64 void SetUVWFpsIC(SCALAR vu, SCALAR vv, SCALAR vw);
66 void SetVNEDFpsIC(SCALAR north, SCALAR east, SCALAR down);
68 void SetVNEDAirmassFpsIC(SCALAR north, SCALAR east, SCALAR down );
70 void SetAltitudeFtIC(SCALAR tt);
71 void SetAltitudeAGLFtIC(SCALAR tt);
73 //"vertical" flight path, recalculate theta
74 inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*SGD_DEGREES_TO_RADIANS); }
75 void SetFlightPathAngleRadIC(SCALAR tt);
78 void SetClimbRateFpmIC(SCALAR tt);
79 void SetClimbRateFpsIC(SCALAR tt);
81 //use currently stored gamma, recalcualte theta
82 inline void SetAlphaDegIC(SCALAR tt) { alpha=tt*SGD_DEGREES_TO_RADIANS; getTheta(); }
83 inline void SetAlphaRadIC(SCALAR tt) { alpha=tt; getTheta(); }
85 //use currently stored gamma, recalcualte alpha
86 inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*SGD_DEGREES_TO_RADIANS); }
87 void SetPitchAngleRadIC(SCALAR tt);
89 inline void SetBetaDegIC(SCALAR tt) { beta=tt*SGD_DEGREES_TO_RADIANS; getTheta();}
90 inline void SetBetaRadIC(SCALAR tt) { beta=tt; getTheta(); }
92 inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*SGD_DEGREES_TO_RADIANS; getTheta(); }
93 inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); }
95 inline void SetHeadingDegIC(SCALAR tt) { psi=tt*SGD_DEGREES_TO_RADIANS; }
96 inline void SetHeadingRadIC(SCALAR tt) { psi=tt; }
98 inline void SetLatitudeGDDegIC(SCALAR tt) { SetLatitudeGDRadIC(tt*SGD_DEGREES_TO_RADIANS); }
99 void SetLatitudeGDRadIC(SCALAR tt);
101 inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*SGD_DEGREES_TO_RADIANS; }
102 inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; }
104 void SetRunwayAltitudeFtIC(SCALAR tt);
106 inline SCALAR GetVcalibratedKtsIC(void) { return sqrt(density_ratio*vt*vt)*V_TO_KNOTS; }
107 inline SCALAR GetVequivalentKtsIC(void) { return sqrt(density_ratio)*vt*V_TO_KNOTS; }
108 inline SCALAR GetVtrueKtsIC(void) { return vt*V_TO_KNOTS; }
109 inline SCALAR GetVtrueFpsIC(void) { return vt; }
110 inline SCALAR GetMachIC(void) { return vt/soundspeed; }
112 inline SCALAR GetAltitudeFtIC(void) { return altitude; }
113 inline SCALAR GetAltitudeAGLFtIC(void) { return alt_agl; }
115 inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; }
117 inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*SGD_RADIANS_TO_DEGREES; }
118 inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; }
120 inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; }
121 inline SCALAR GetClimbRateFpsIC(void) { return hdot; }
123 inline SCALAR GetAlphaDegIC(void) { return alpha*SGD_RADIANS_TO_DEGREES; }
124 inline SCALAR GetAlphaRadIC(void) { return alpha; }
126 inline SCALAR GetPitchAngleDegIC(void) { return theta*SGD_RADIANS_TO_DEGREES; }
127 inline SCALAR GetPitchAngleRadIC(void) { return theta; }
130 inline SCALAR GetBetaDegIC(void) { return beta*SGD_RADIANS_TO_DEGREES; }
131 inline SCALAR GetBetaRadIC(void) { return beta*SGD_RADIANS_TO_DEGREES; }
133 inline SCALAR GetRollAngleDegIC(void) { return phi*SGD_RADIANS_TO_DEGREES; }
134 inline SCALAR GetRollAngleRadIC(void) { return phi; }
136 inline SCALAR GetHeadingDegIC(void) { return psi*SGD_RADIANS_TO_DEGREES; }
137 inline SCALAR GetHeadingRadIC(void) { return psi; }
139 inline SCALAR GetLatitudeGDDegIC(void) { return latitude_gd*SGD_RADIANS_TO_DEGREES; }
140 inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; }
142 inline SCALAR GetLongitudeDegIC(void) { return longitude*SGD_RADIANS_TO_DEGREES; }
143 inline SCALAR GetLongitudeRadIC(void) { return longitude; }
145 inline SCALAR GetUBodyFpsIC(void) { return vt*cos(alpha)*cos(beta); }
146 inline SCALAR GetVBodyFpsIC(void) { return vt*sin(beta); }
147 inline SCALAR GetWBodyFpsIC(void) { return vt*sin(alpha)*cos(beta); }
149 inline SCALAR GetVnorthFpsIC(void) { calcNEDfromVt();return vnorth; }
150 inline SCALAR GetVeastFpsIC(void) { calcNEDfromVt();return veast; }
151 inline SCALAR GetVdownFpsIC(void) { calcNEDfromVt();return vdown; }
153 inline SCALAR GetVnorthAirmassFpsIC(void) { return vnorthwind; }
154 inline SCALAR GetVeastAirmassFpsIC(void) { return veastwind; }
155 inline SCALAR GetVdownAirmassFpsIC(void) { return vdownwind; }
157 inline SCALAR GetThetaRadIC(void) { return theta; }
158 inline SCALAR GetPhiRadIC(void) { return phi; }
159 inline SCALAR GetPsiRadIC(void) { return psi; }
164 SCALAR vt,vtg,vw,vc,ve;
165 SCALAR alpha,beta,gamma,theta,phi,psi;
167 SCALAR altitude,runway_altitude,hdot,alt_agl,sea_level_radius;
168 SCALAR latitude_gd,latitude_gc,longitude;
170 SCALAR vnorth,veast,vdown;
171 SCALAR vnorthwind, veastwind, vdownwind;
172 SCALAR p,T,soundspeed,density_ratio,rho;
174 SCALAR xlo, xhi,xmin,xmax;
176 typedef SCALAR (LaRCsimIC::*fp)(SCALAR x);
179 lsspeedset lastSpeedSet;
183 void calcVtfromNED(void);
184 void calcNEDfromVt(void);
185 void calcSpeeds(void);
190 SCALAR GammaEqOfTheta(SCALAR tt);
191 SCALAR GammaEqOfAlpha(SCALAR tt);
192 void get_atmosphere(void);
195 bool findInterval(SCALAR x,SCALAR guess);
196 bool solve(SCALAR *y, SCALAR x);