| 1 | /******************************************************************************* |
| 2 | |
| 3 | Header: LaRCsimIC.hxx |
| 4 | Author: Tony Peden |
| 5 | Date started: 10/9/00 |
| 6 | |
| 7 | ------------- Copyright (C) 2000 Anthony K. Peden ([email protected]) ------------- |
| 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 |
| 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. |
| 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 "ls_constants.h" |
| 34 | #include "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 | #define DEGREES_TO_RADIANS (M_PI / 180.0) |
| 45 | |
| 46 | enum lsspeedset { lssetvt, lssetvc, lssetve, lssetmach, lssetuvw, lssetned }; |
| 47 | enum lsaltset { lssetasl, lssetagl }; |
| 48 | |
| 49 | |
| 50 | class LaRCsimIC { |
| 51 | public: |
| 52 | |
| 53 | LaRCsimIC(void); |
| 54 | ~LaRCsimIC(void); |
| 55 | |
| 56 | void SetVcalibratedKtsIC(SCALAR tt); |
| 57 | void SetMachIC(SCALAR tt); |
| 58 | |
| 59 | void SetVtrueFpsIC(SCALAR tt); |
| 60 | |
| 61 | void SetVequivalentKtsIC(SCALAR tt); |
| 62 | |
| 63 | void SetUVWFpsIC(SCALAR vu, SCALAR vv, SCALAR vw); |
| 64 | |
| 65 | void SetVNEDFpsIC(SCALAR north, SCALAR east, SCALAR down); |
| 66 | |
| 67 | void SetVNEDAirmassFpsIC(SCALAR north, SCALAR east, SCALAR down ); |
| 68 | |
| 69 | void SetAltitudeFtIC(SCALAR tt); |
| 70 | void SetAltitudeAGLFtIC(SCALAR tt); |
| 71 | |
| 72 | //"vertical" flight path, recalculate theta |
| 73 | inline void SetFlightPathAngleDegIC(SCALAR tt) { SetFlightPathAngleRadIC(tt*DEGREES_TO_RADIANS); } |
| 74 | void SetFlightPathAngleRadIC(SCALAR tt); |
| 75 | |
| 76 | //set speed first |
| 77 | void SetClimbRateFpmIC(SCALAR tt); |
| 78 | void SetClimbRateFpsIC(SCALAR tt); |
| 79 | |
| 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(); } |
| 83 | |
| 84 | //use currently stored gamma, recalcualte alpha |
| 85 | inline void SetPitchAngleDegIC(SCALAR tt) { SetPitchAngleRadIC(tt*DEGREES_TO_RADIANS); } |
| 86 | void SetPitchAngleRadIC(SCALAR tt); |
| 87 | |
| 88 | inline void SetBetaDegIC(SCALAR tt) { beta=tt*DEGREES_TO_RADIANS; getTheta();} |
| 89 | inline void SetBetaRadIC(SCALAR tt) { beta=tt; getTheta(); } |
| 90 | |
| 91 | inline void SetRollAngleDegIC(SCALAR tt) { phi=tt*DEGREES_TO_RADIANS; getTheta(); } |
| 92 | inline void SetRollAngleRadIC(SCALAR tt) { phi=tt; getTheta(); } |
| 93 | |
| 94 | inline void SetHeadingDegIC(SCALAR tt) { psi=tt*DEGREES_TO_RADIANS; } |
| 95 | inline void SetHeadingRadIC(SCALAR tt) { psi=tt; } |
| 96 | |
| 97 | inline void SetLatitudeGDDegIC(SCALAR tt) { SetLatitudeGDRadIC(tt*DEGREES_TO_RADIANS); } |
| 98 | void SetLatitudeGDRadIC(SCALAR tt); |
| 99 | |
| 100 | inline void SetLongitudeDegIC(SCALAR tt) { longitude=tt*DEGREES_TO_RADIANS; } |
| 101 | inline void SetLongitudeRadIC(SCALAR tt) { longitude=tt; } |
| 102 | |
| 103 | void SetRunwayAltitudeFtIC(SCALAR tt); |
| 104 | |
| 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; } |
| 110 | |
| 111 | inline SCALAR GetAltitudeFtIC(void) { return altitude; } |
| 112 | inline SCALAR GetAltitudeAGLFtIC(void) { return alt_agl; } |
| 113 | |
| 114 | inline SCALAR GetRunwayAltitudeFtIC(void) { return runway_altitude; } |
| 115 | |
| 116 | inline SCALAR GetFlightPathAngleDegIC(void) { return gamma*DEGREES_TO_RADIANS; } |
| 117 | inline SCALAR GetFlightPathAngleRadIC(void) { return gamma; } |
| 118 | |
| 119 | inline SCALAR GetClimbRateFpmIC(void) { return hdot*60; } |
| 120 | inline SCALAR GetClimbRateFpsIC(void) { return hdot; } |
| 121 | |
| 122 | inline SCALAR GetAlphaDegIC(void) { return alpha*DEGREES_TO_RADIANS; } |
| 123 | inline SCALAR GetAlphaRadIC(void) { return alpha; } |
| 124 | |
| 125 | inline SCALAR GetPitchAngleDegIC(void) { return theta*DEGREES_TO_RADIANS; } |
| 126 | inline SCALAR GetPitchAngleRadIC(void) { return theta; } |
| 127 | |
| 128 | |
| 129 | inline SCALAR GetBetaDegIC(void) { return beta*DEGREES_TO_RADIANS; } |
| 130 | inline SCALAR GetBetaRadIC(void) { return beta*DEGREES_TO_RADIANS; } |
| 131 | |
| 132 | inline SCALAR GetRollAngleDegIC(void) { return phi*DEGREES_TO_RADIANS; } |
| 133 | inline SCALAR GetRollAngleRadIC(void) { return phi; } |
| 134 | |
| 135 | inline SCALAR GetHeadingDegIC(void) { return psi*DEGREES_TO_RADIANS; } |
| 136 | inline SCALAR GetHeadingRadIC(void) { return psi; } |
| 137 | |
| 138 | inline SCALAR GetLatitudeGDDegIC(void) { return latitude_gd*DEGREES_TO_RADIANS; } |
| 139 | inline SCALAR GetLatitudeGDRadIC(void) { return latitude_gd; } |
| 140 | |
| 141 | inline SCALAR GetLongitudeDegIC(void) { return longitude*DEGREES_TO_RADIANS; } |
| 142 | inline SCALAR GetLongitudeRadIC(void) { return longitude; } |
| 143 | |
| 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); } |
| 147 | |
| 148 | inline SCALAR GetVnorthFpsIC(void) { calcNEDfromVt();return vnorth; } |
| 149 | inline SCALAR GetVeastFpsIC(void) { calcNEDfromVt();return veast; } |
| 150 | inline SCALAR GetVdownFpsIC(void) { calcNEDfromVt();return vdown; } |
| 151 | |
| 152 | inline SCALAR GetVnorthAirmassFpsIC(void) { return vnorthwind; } |
| 153 | inline SCALAR GetVeastAirmassFpsIC(void) { return veastwind; } |
| 154 | inline SCALAR GetVdownAirmassFpsIC(void) { return vdownwind; } |
| 155 | |
| 156 | inline SCALAR GetThetaRadIC(void) { return theta; } |
| 157 | inline SCALAR GetPhiRadIC(void) { return phi; } |
| 158 | inline SCALAR GetPsiRadIC(void) { return psi; } |
| 159 | |
| 160 | |
| 161 | |
| 162 | private: |
| 163 | SCALAR vt,vtg,vw,vc,ve; |
| 164 | SCALAR alpha,beta,gamma,theta,phi,psi; |
| 165 | SCALAR mach; |
| 166 | SCALAR altitude,runway_altitude,hdot,alt_agl,sea_level_radius; |
| 167 | SCALAR latitude_gd,latitude_gc,longitude; |
| 168 | SCALAR u,v,w; |
| 169 | SCALAR vnorth,veast,vdown; |
| 170 | SCALAR vnorthwind, veastwind, vdownwind; |
| 171 | SCALAR p,T,soundspeed,density_ratio,rho; |
| 172 | |
| 173 | SCALAR xlo, xhi,xmin,xmax; |
| 174 | |
| 175 | typedef SCALAR (LaRCsimIC::*fp)(SCALAR x); |
| 176 | fp sfunc; |
| 177 | |
| 178 | lsspeedset lastSpeedSet; |
| 179 | lsaltset lastAltSet; |
| 180 | |
| 181 | |
| 182 | void calcVtfromNED(void); |
| 183 | void calcNEDfromVt(void); |
| 184 | void calcSpeeds(void); |
| 185 | |
| 186 | |
| 187 | bool getAlpha(void); |
| 188 | bool getTheta(void); |
| 189 | SCALAR GammaEqOfTheta(SCALAR tt); |
| 190 | SCALAR GammaEqOfAlpha(SCALAR tt); |
| 191 | void get_atmosphere(void); |
| 192 | |
| 193 | |
| 194 | bool findInterval(SCALAR x,SCALAR guess); |
| 195 | bool solve(SCALAR *y, SCALAR x); |
| 196 | }; |
| 197 | |
| 198 | #endif |