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 *******************************************************************************/
33 #include "ls_constants.h"
36 /*******************************************************************************
38 *******************************************************************************/
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 #define DEGREES_TO_RADIANS (M_PI / 180.0)
46 enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned };
47 enum lsaltset { lssetasl, lssetagl };
56 void SetVcalibratedKtsIC(SCALAR tt);
57 void SetMachIC(SCALAR tt);
59 void SetVtrueFpsIC(SCALAR tt);
61 void SetVequivalentKtsIC(SCALAR tt);
63 void SetUVWFpsIC(SCALAR vu, SCALAR vv, SCALAR vw);
65 void SetVNEDFpsIC(SCALAR north, SCALAR east, SCALAR down);
67 void SetVNEDAirmassFpsIC(SCALAR north, SCALAR east, SCALAR down );
69 void SetAltitudeFtIC(SCALAR tt);
70 void SetAltitudeAGLFtIC(SCALAR tt);
72 //"vertical" flight path, recalculate theta
73 inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*DEGREES_TO_RADIANS); }
74 void SetFlightPathAngleRadIC(SCALAR tt);
77 void SetClimbRateFpmIC(SCALAR tt);
78 void SetClimbRateFpsIC(SCALAR tt);
80 //use currently stored gamma, recalcualte theta
81 inline void SetAlphaDegIC(SCALAR tt) { alpha=tt*DEGREES_TO_RADIANS; getTheta(); }
82 inline void SetAlphaRadIC(SCALAR tt) { alpha=tt; getTheta(); }
84 //use currently stored gamma, recalcualte alpha
85 inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*DEGREES_TO_RADIANS); }
86 void SetPitchAngleRadIC(SCALAR tt);
88 inline void SetBetaDegIC(SCALAR tt) { beta=tt*DEGREES_TO_RADIANS; getTheta();}
89 inline void SetBetaRadIC(SCALAR tt) { beta=tt; getTheta(); }
91 inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*DEGREES_TO_RADIANS; getTheta(); }
92 inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); }
94 inline void SetHeadingDegIC(SCALAR tt) { psi=tt*DEGREES_TO_RADIANS; }
95 inline void SetHeadingRadIC(SCALAR tt) { psi=tt; }
97 inline void SetLatitudeGDDegIC(SCALAR tt) { SetLatitudeGDRadIC(tt*DEGREES_TO_RADIANS); }
98 void SetLatitudeGDRadIC(SCALAR tt);
100 inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*DEGREES_TO_RADIANS; }
101 inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; }
103 void SetRunwayAltitudeFtIC(SCALAR tt);
105 inline SCALAR GetVcalibratedKtsIC(void) { return sqrt(density_ratio*vt*vt)*V_TO_KNOTS; }
106 inline SCALAR GetVequivalentKtsIC(void) { return sqrt(density_ratio)*vt*V_TO_KNOTS; }
107 inline SCALAR GetVtrueKtsIC(void) { return vt*V_TO_KNOTS; }
108 inline SCALAR GetVtrueFpsIC(void) { return vt; }
109 inline SCALAR GetMachIC(void) { return vt/soundspeed; }
111 inline SCALAR GetAltitudeFtIC(void) { return altitude; }
112 inline SCALAR GetAltitudeAGLFtIC(void) { return alt_agl; }
114 inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; }
116 inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*DEGREES_TO_RADIANS; }
117 inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; }
119 inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; }
120 inline SCALAR GetClimbRateFpsIC(void) { return hdot; }
122 inline SCALAR GetAlphaDegIC(void) { return alpha*DEGREES_TO_RADIANS; }
123 inline SCALAR GetAlphaRadIC(void) { return alpha; }
125 inline SCALAR GetPitchAngleDegIC(void) { return theta*DEGREES_TO_RADIANS; }
126 inline SCALAR GetPitchAngleRadIC(void) { return theta; }
129 inline SCALAR GetBetaDegIC(void) { return beta*DEGREES_TO_RADIANS; }
130 inline SCALAR GetBetaRadIC(void) { return beta*DEGREES_TO_RADIANS; }
132 inline SCALAR GetRollAngleDegIC(void) { return phi*DEGREES_TO_RADIANS; }
133 inline SCALAR GetRollAngleRadIC(void) { return phi; }
135 inline SCALAR GetHeadingDegIC(void) { return psi*DEGREES_TO_RADIANS; }
136 inline SCALAR GetHeadingRadIC(void) { return psi; }
138 inline SCALAR GetLatitudeGDDegIC(void) { return latitude_gd*DEGREES_TO_RADIANS; }
139 inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; }
141 inline SCALAR GetLongitudeDegIC(void) { return longitude*DEGREES_TO_RADIANS; }
142 inline SCALAR GetLongitudeRadIC(void) { return longitude; }
144 inline SCALAR GetUBodyFpsIC(void) { return vt*cos(alpha)*cos(beta); }
145 inline SCALAR GetVBodyFpsIC(void) { return vt*sin(beta); }
146 inline SCALAR GetWBodyFpsIC(void) { return vt*sin(alpha)*cos(beta); }
148 inline SCALAR GetVnorthFpsIC(void) { calcNEDfromVt();return vnorth; }
149 inline SCALAR GetVeastFpsIC(void) { calcNEDfromVt();return veast; }
150 inline SCALAR GetVdownFpsIC(void) { calcNEDfromVt();return vdown; }
152 inline SCALAR GetVnorthAirmassFpsIC(void) { return vnorthwind; }
153 inline SCALAR GetVeastAirmassFpsIC(void) { return veastwind; }
154 inline SCALAR GetVdownAirmassFpsIC(void) { return vdownwind; }
156 inline SCALAR GetThetaRadIC(void) { return theta; }
157 inline SCALAR GetPhiRadIC(void) { return phi; }
158 inline SCALAR GetPsiRadIC(void) { return psi; }
163 SCALAR vt,vtg,vw,vc,ve;
164 SCALAR alpha,beta,gamma,theta,phi,psi;
166 SCALAR altitude,runway_altitude,hdot,alt_agl,sea_level_radius;
167 SCALAR latitude_gd,latitude_gc,longitude;
169 SCALAR vnorth,veast,vdown;
170 SCALAR vnorthwind, veastwind, vdownwind;
171 SCALAR p,T,soundspeed,density_ratio,rho;
173 SCALAR xlo, xhi,xmin,xmax;
175 typedef SCALAR (LaRCsimIC::*fp)(SCALAR x);
178 lsspeedset lastSpeedSet;
182 void calcVtfromNED(void);
183 void calcNEDfromVt(void);
184 void calcSpeeds(void);
189 SCALAR GammaEqOfTheta(SCALAR tt);
190 SCALAR GammaEqOfAlpha(SCALAR tt);
191 void get_atmosphere(void);
194 bool findInterval(SCALAR x,SCALAR guess);
195 bool solve(SCALAR *y, SCALAR x);