]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAuxiliary.cpp
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / FGAuxiliary.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGAuxiliary.cpp
4  Author:       Tony Peden, Jon Berndt
5  Date started: 01/26/99
6  Purpose:      Calculates additional parameters needed by the visual system, etc.
7  Called by:    FGFDMExec
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU Lesser General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
19  details.
20
21  You should have received a copy of the GNU Lesser General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU Lesser General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class calculates various auxiliary parameters.
31
32 REFERENCES
33   Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
34                     pgs. 112-126
35 HISTORY
36 --------------------------------------------------------------------------------
37 01/26/99   JSB   Created
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 INCLUDES
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 #include "FGAuxiliary.h"
44 #include "FGAerodynamics.h"
45 #include "FGPropagate.h"
46 #include "FGAtmosphere.h"
47 #include "FGFDMExec.h"
48 #include "FGAircraft.h"
49 #include "FGInertial.h"
50 #include "FGExternalReactions.h"
51 #include "FGBuoyantForces.h"
52 #include "FGGroundReactions.h"
53 #include "FGPropulsion.h"
54 #include "FGMassBalance.h"
55 #include "input_output/FGPropertyManager.h"
56 #include <iostream>
57
58 using namespace std;
59
60 namespace JSBSim {
61
62 static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.49 2011/05/20 03:18:36 jberndt Exp $";
63 static const char *IdHdr = ID_AUXILIARY;
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 CLASS IMPLEMENTATION
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69
70 FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
71 {
72   Name = "FGAuxiliary";
73   pt = p = psl = 1.0;
74   rho = rhosl = 1.0;
75   tat = sat = 1.0;
76   tatc = RankineToCelsius(tat);
77
78   vcas = veas = 0.0;
79   qbar = qbarUW = qbarUV = 0.0;
80   Mach = MachU = 0.0;
81   alpha = beta = 0.0;
82   adot = bdot = 0.0;
83   gamma = Vt = Vground = 0.0;
84   psigt = 0.0;
85   day_of_year = 1;
86   seconds_in_day = 0.0;
87   hoverbmac = hoverbcg = 0.0;
88   Re = 0.0;
89   Nz = 0.0;
90   lon_relative_position = lat_relative_position = relative_position = 0.0;
91
92   vPilotAccel.InitMatrix();
93   vPilotAccelN.InitMatrix();
94   vToEyePt.InitMatrix();
95   vAeroUVW.InitMatrix();
96   vAeroPQR.InitMatrix();
97   vMachUVW.InitMatrix();
98   vEuler.InitMatrix();
99   vEulerRates.InitMatrix();
100   vAircraftAccel.InitMatrix();
101
102   bind();
103
104   Debug(0);
105 }
106
107 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108
109 bool FGAuxiliary::InitModel(void)
110 {
111   pt = p = FDMExec->GetAtmosphere()->GetPressure();
112   rho = FDMExec->GetAtmosphere()->GetDensity();
113   rhosl = FDMExec->GetAtmosphere()->GetDensitySL();
114   psl = FDMExec->GetAtmosphere()->GetPressureSL();
115   tat = sat = FDMExec->GetAtmosphere()->GetTemperature();
116   tatc = RankineToCelsius(tat);
117
118   vcas = veas = 0.0;
119   qbar = qbarUW = qbarUV = 0.0;
120   Mach = MachU = 0.0;
121   alpha = beta = 0.0;
122   adot = bdot = 0.0;
123   gamma = Vt = Vground = 0.0;
124   psigt = 0.0;
125   day_of_year = 1;
126   seconds_in_day = 0.0;
127   hoverbmac = hoverbcg = 0.0;
128   Re = 0.0;
129   Nz = 0.0;
130   lon_relative_position = lat_relative_position = relative_position = 0.0;
131
132   vPilotAccel.InitMatrix();
133   vPilotAccelN.InitMatrix();
134   vToEyePt.InitMatrix();
135   vAeroUVW.InitMatrix();
136   vAeroPQR.InitMatrix();
137   vMachUVW.InitMatrix();
138   vEuler.InitMatrix();
139   vEulerRates.InitMatrix();
140   vAircraftAccel.InitMatrix();
141
142   return true;
143 }
144   
145 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146
147 FGAuxiliary::~FGAuxiliary()
148 {
149   Debug(1);
150 }
151
152 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153
154 bool FGAuxiliary::Run(bool Holding)
155 {
156   double A,B,D;
157
158   if (FGModel::Run(Holding)) return true; // return true if error returned from base class
159   if (Holding) return false;
160
161   RunPreFunctions();
162
163   const double density = FDMExec->GetAtmosphere()->GetDensity();
164   const double soundspeed = FDMExec->GetAtmosphere()->GetSoundSpeed();
165   const double DistanceAGL = FDMExec->GetPropagate()->GetDistanceAGL();
166   const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
167   const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b();
168   const FGMatrix33& Tb2l = FDMExec->GetPropagate()->GetTb2l();
169
170   const FGColumnVector3& vPQR = FDMExec->GetPropagate()->GetPQR();
171   const FGColumnVector3& vUVW = FDMExec->GetPropagate()->GetUVW();
172   const FGColumnVector3& vUVWdot = FDMExec->GetPropagate()->GetUVWdot();
173   const FGColumnVector3& vVel = FDMExec->GetPropagate()->GetVel();
174
175   p = FDMExec->GetAtmosphere()->GetPressure();
176   rhosl = FDMExec->GetAtmosphere()->GetDensitySL();
177   psl = FDMExec->GetAtmosphere()->GetPressureSL();
178   sat = FDMExec->GetAtmosphere()->GetTemperature();
179
180 // Rotation
181
182   double cTht = FDMExec->GetPropagate()->GetCosEuler(eTht);
183   double sTht = FDMExec->GetPropagate()->GetSinEuler(eTht);
184   double cPhi = FDMExec->GetPropagate()->GetCosEuler(ePhi);
185   double sPhi = FDMExec->GetPropagate()->GetSinEuler(ePhi);
186
187   vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
188   if (cTht != 0.0) {
189     vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht;
190     vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht;
191   }
192
193 // Combine the wind speed with aircraft speed to obtain wind relative speed
194   FGColumnVector3 wind = Tl2b*FDMExec->GetAtmosphere()->GetTotalWindNED();
195   vAeroPQR = vPQR - FDMExec->GetAtmosphere()->GetTurbPQR();
196   vAeroUVW = vUVW - wind;
197
198   Vt = vAeroUVW.Magnitude();
199   double Vt2 = Vt*Vt;
200   alpha = beta = adot = bdot = 0;
201   double mUW = (vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
202
203   if ( Vt > 1.0 ) {
204     if (vAeroUVW(eW) != 0.0)
205       alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
206     if (vAeroUVW(eV) != 0.0)
207       beta = mUW > 0.0 ? atan2(vAeroUVW(eV), sqrt(mUW)) : 0.0;
208
209     double signU=1;
210     if (vAeroUVW(eU) < 0.0) signU=-1;
211
212     if ( mUW >= 1.0 ) {
213       adot = (vAeroUVW(eU)*vUVWdot(eW) - vAeroUVW(eW)*vUVWdot(eU))/mUW;
214       bdot = (signU*mUW*vUVWdot(eV)
215              - vAeroUVW(eV)*(vAeroUVW(eU)*vUVWdot(eU) + vAeroUVW(eW)*vUVWdot(eW)))/(Vt2*sqrt(mUW));
216     }
217   }
218
219   Re = Vt * FDMExec->GetAircraft()->Getcbar() / FDMExec->GetAtmosphere()->GetKinematicViscosity();
220
221   qbar = 0.5*density*Vt2;
222   qbarUW = 0.5*density*(mUW);
223   qbarUV = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV));
224   Mach = Vt / soundspeed;
225   MachU = vMachUVW(eU) = vAeroUVW(eU) / soundspeed;
226   vMachUVW(eV) = vAeroUVW(eV) / soundspeed;
227   vMachUVW(eW) = vAeroUVW(eW) / soundspeed;
228
229 // Position
230
231   Vground = sqrt( vVel(eNorth)*vVel(eNorth) + vVel(eEast)*vVel(eEast) );
232
233   psigt = atan2(vVel(eEast), vVel(eNorth));
234   if (psigt < 0.0) psigt += 2*M_PI;
235   gamma = atan2(-vVel(eDown), Vground);
236
237   tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
238   tatc = RankineToCelsius(tat);
239
240   if (MachU < 1) {   // Calculate total pressure assuming isentropic flow
241     pt = p*pow((1 + 0.2*MachU*MachU),3.5);
242   } else {
243     // Use Rayleigh pitot tube formula for normal shock in front of pitot tube
244     B = 5.76*MachU*MachU/(5.6*MachU*MachU - 0.8);
245     D = (2.8*MachU*MachU-0.4)*0.4167;
246     pt = p*pow(B,3.5)*D;
247   }
248
249   A = pow(((pt-p)/psl+1),0.28571);
250   if (MachU > 0.0) {
251     vcas = sqrt(7*psl/rhosl*(A-1));
252     veas = sqrt(2*qbar/rhosl);
253   } else {
254     vcas = veas = 0.0;
255   }
256
257   const double SLgravity = FDMExec->GetInertial()->SLgravity();
258
259   vPilotAccel.InitMatrix();
260   if ( Vt > 1.0 ) {
261      vAircraftAccel = FDMExec->GetAircraft()->GetBodyAccel();
262      // Nz is Acceleration in "g's", along normal axis (-Z body axis)
263      Nz = -vAircraftAccel(eZ)/SLgravity;
264      vToEyePt = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZep());
265      vPilotAccel = vAircraftAccel + FDMExec->GetPropagate()->GetPQRdot() * vToEyePt;
266      vPilotAccel += vPQR * (vPQR * vToEyePt);
267   } else {
268      // The line below handles low velocity (and on-ground) cases, basically
269      // representing the opposite of the force that the landing gear would
270      // exert on the ground (which is just the total weight). This eliminates
271      // any jitter that could be introduced by the landing gear. Theoretically,
272      // this branch could be eliminated, with a penalty of having a short
273      // transient at startup (lasting only a fraction of a second).
274      vPilotAccel = Tl2b * FGColumnVector3( 0.0, 0.0, -SLgravity );
275      Nz = -vPilotAccel(eZ)/SLgravity;
276   }
277
278   vPilotAccelN = vPilotAccel/SLgravity;
279
280   // VRP computation
281   const FGLocation& vLocation = FDMExec->GetPropagate()->GetLocation();
282   const FGColumnVector3& vrpStructural = FDMExec->GetAircraft()->GetXYZvrp();
283   const FGColumnVector3 vrpBody = FDMExec->GetMassBalance()->StructuralToBody( vrpStructural );
284   const FGColumnVector3 vrpLocal = Tb2l * vrpBody;
285   vLocationVRP = vLocation.LocalToLocation( vrpLocal );
286
287   // Recompute some derived values now that we know the dependent parameters values ...
288   hoverbcg = DistanceAGL / wingspan;
289
290   FGColumnVector3 vMac = Tb2l*FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp());
291   hoverbmac = (DistanceAGL + vMac(3)) / wingspan;
292
293   // when all model are executed, 
294   // please calculate the distance from the initial point
295
296   CalculateRelativePosition();
297
298   RunPostFunctions();
299
300   return false;
301 }
302
303 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304 //
305 // A positive headwind is blowing with you, a negative headwind is blowing against you.
306 // psi is the direction the wind is blowing *towards*.
307 // ToDo: should this simply be in the atmosphere class? Same with Get Crosswind.
308
309 double FGAuxiliary::GetHeadWind(void) const
310 {
311   double psiw,vw;
312
313   psiw = FDMExec->GetAtmosphere()->GetWindPsi();
314   vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
315
316   return vw*cos(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
317 }
318
319 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 //
321 // A positive crosswind is blowing towards the right (from teh perspective of the
322 // pilot). A negative crosswind is blowing towards the -Y direction (left).
323 // psi is the direction the wind is blowing *towards*.
324
325 double FGAuxiliary::GetCrossWind(void) const
326 {
327   double psiw,vw;
328
329   psiw = FDMExec->GetAtmosphere()->GetWindPsi();
330   vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
331
332   return  vw*sin(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
333 }
334
335 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336
337 double FGAuxiliary::GethVRP(void) const
338 {
339   return vLocationVRP.GetRadius() - FDMExec->GetPropagate()->GetSeaLevelRadius();
340 }
341
342 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343
344 void FGAuxiliary::bind(void)
345 {
346   typedef double (FGAuxiliary::*PMF)(int) const;
347   typedef double (FGAuxiliary::*PF)(void) const;
348   PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
349   PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
350   PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
351   PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
352   PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
353   PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
354   PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
355   PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
356   PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);
357   PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);
358   PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);
359   PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, (PMF)&FGAuxiliary::GetEulerRates);
360   PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, (PMF)&FGAuxiliary::GetEulerRates);
361   PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, (PMF)&FGAuxiliary::GetEulerRates);
362   PropertyManager->Tie("velocities/u-aero-fps", this, eU, (PMF)&FGAuxiliary::GetAeroUVW);
363   PropertyManager->Tie("velocities/v-aero-fps", this, eV, (PMF)&FGAuxiliary::GetAeroUVW);
364   PropertyManager->Tie("velocities/w-aero-fps", this, eW, (PMF)&FGAuxiliary::GetAeroUVW);
365   PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt, &FGAuxiliary::SetVt, true);
366   PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach, &FGAuxiliary::SetMach, true);
367   PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);
368   PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, (PMF)&FGAuxiliary::GetPilotAccel);
369   PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, (PMF)&FGAuxiliary::GetPilotAccel);
370   PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, (PMF)&FGAuxiliary::GetPilotAccel);
371   PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, (PMF)&FGAuxiliary::GetNpilot);
372   PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, (PMF)&FGAuxiliary::GetNpilot);
373   PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, (PMF)&FGAuxiliary::GetNpilot);
374   PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
375   /* PropertyManager->Tie("atmosphere/headwind-fps", this, &FGAuxiliary::GetHeadWind, true);
376   PropertyManager->Tie("atmosphere/crosswind-fps", this, &FGAuxiliary::GetCrossWind, true); */
377   PropertyManager->Tie("aero/alpha-rad", this, (PF)&FGAuxiliary::Getalpha, &FGAuxiliary::Setalpha, true);
378   PropertyManager->Tie("aero/beta-rad", this, (PF)&FGAuxiliary::Getbeta, &FGAuxiliary::Setbeta, true);
379   PropertyManager->Tie("aero/mag-beta-rad", this, (PF)&FGAuxiliary::GetMagBeta);
380   PropertyManager->Tie("aero/alpha-deg", this, inDegrees, (PMF)&FGAuxiliary::Getalpha);
381   PropertyManager->Tie("aero/beta-deg", this, inDegrees, (PMF)&FGAuxiliary::Getbeta);
382   PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, (PMF)&FGAuxiliary::GetMagBeta);
383   PropertyManager->Tie("aero/Re", this, &FGAuxiliary::GetReynoldsNumber);
384   PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar, &FGAuxiliary::Setqbar, true);
385   PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW, &FGAuxiliary::SetqbarUW, true);
386   PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV, &FGAuxiliary::SetqbarUV, true);
387   PropertyManager->Tie("aero/alphadot-rad_sec", this, (PF)&FGAuxiliary::Getadot, &FGAuxiliary::Setadot, true);
388   PropertyManager->Tie("aero/betadot-rad_sec", this, (PF)&FGAuxiliary::Getbdot, &FGAuxiliary::Setbdot, true);
389   PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getadot);
390   PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getbdot);
391   PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);
392   PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);
393   PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma, &FGAuxiliary::SetGamma);
394   PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);
395
396   PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);
397   PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);
398   PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);
399   PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
400   PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
401   PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);
402 }
403
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405
406 void FGAuxiliary::CalculateRelativePosition(void)
407
408   const double earth_radius_mt = FDMExec->GetInertial()->GetRefRadius()*fttom;
409   lat_relative_position=(FDMExec->GetPropagate()->GetLatitude()  - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;
410   lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;
411   relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position);
412 };
413
414 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415
416 double FGAuxiliary::BadUnits(void) const
417 {
418   cerr << "Bad units" << endl; return 0.0;
419 }
420
421 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422 //    The bitmasked value choices are as follows:
423 //    unset: In this case (the default) JSBSim would only print
424 //       out the normally expected messages, essentially echoing
425 //       the config files as they are read. If the environment
426 //       variable is not set, debug_lvl is set to 1 internally
427 //    0: This requests JSBSim not to output any messages
428 //       whatsoever.
429 //    1: This value explicity requests the normal JSBSim
430 //       startup messages
431 //    2: This value asks for a message to be printed out when
432 //       a class is instantiated
433 //    4: When this value is set, a message is displayed when a
434 //       FGModel object executes its Run() method
435 //    8: When this value is set, various runtime state variables
436 //       are printed out periodically
437 //    16: When set various parameters are sanity checked and
438 //       a message is printed out when they go out of bounds
439
440 void FGAuxiliary::Debug(int from)
441 {
442   if (debug_lvl <= 0) return;
443
444   if (debug_lvl & 1) { // Standard console startup message output
445     if (from == 0) { // Constructor
446
447     }
448   }
449   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
450     if (from == 0) cout << "Instantiated: FGAuxiliary" << endl;
451     if (from == 1) cout << "Destroyed:    FGAuxiliary" << endl;
452   }
453   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
454   }
455   if (debug_lvl & 8 ) { // Runtime state variables
456   }
457   if (debug_lvl & 16) { // Sanity checking
458     if (Mach > 100 || Mach < 0.00)
459       cout << "FGPropagate::Mach is out of bounds: " << Mach << endl;
460     if (qbar > 1e6 || qbar < 0.00)
461       cout << "FGPropagate::qbar is out of bounds: " << qbar << endl;
462   }
463   if (debug_lvl & 64) {
464     if (from == 0) { // Constructor
465       cout << IdSrc << endl;
466       cout << IdHdr << endl;
467     }
468   }
469 }
470
471 } // namespace JSBSim