1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGInitialCondition.h
7 ------------- Copyright (C) 1999 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 Lesser 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 Lesser General Public License for more
19 You should have received a copy of the GNU Lesser 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.
23 Further information about the GNU Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 FUNCTIONAL DESCRIPTION
31 --------------------------------------------------------------------------------
33 The purpose of this class is to take a set of initial conditions and provide
34 a kinematically consistent set of body axis velocity components, euler
35 angles, and altitude. This class does not attempt to trim the model i.e.
36 the sim will most likely start in a very dynamic state (unless, of course,
37 you have chosen your IC's wisely) even after setting it up with this class.
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #ifndef FGINITIALCONDITION_H
44 #define FGINITIALCONDITION_H
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 #include "input_output/FGXMLFileRead.h"
51 #include "math/FGLocation.h"
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 #define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.32 2011/11/06 18:14:51 bcoconni Exp $"
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 class FGColumnVector3;
70 typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
71 typedef enum { setasl, setagl} altitudeset;
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77 /** Initializes the simulation run.
78 Takes a set of initial conditions (IC) and provide a kinematically consistent set
79 of body axis velocity components, euler angles, and altitude. This class
80 does not attempt to trim the model i.e. the sim will most likely start in a
81 very dynamic state (unless, of course, you have chosen your IC's wisely, or
82 started on the ground) even after setting it up with this class.
86 With a valid object of FGFDMExec and an aircraft model loaded:
89 FGInitialCondition* fgic = FDMExec->GetIC();
91 // Reset the initial conditions and set VCAS and altitude
93 fgic->SetVcalibratedKtsIC(vcas);
94 fgic->SetAltitudeAGLFtIC(altitude);
97 FDMExec->GetPropagate()->SetInitialState(fgic);
101 //or to loop the sim w/o integrating
105 Alternatively, you can load initial conditions from an XML file:
108 FGInitialCondition* fgic = FDMExec->GetIC();
114 Since vc, ve, vt, and mach all represent speed, the remaining
115 three are recalculated each time one of them is set (using the
116 current altitude). The most recent speed set is remembered so
117 that if and when altitude is reset, the last set speed is used
118 to recalculate the remaining three. Setting any of the body
119 components forces a recalculation of vt and vt then becomes the
120 most recent speed set.
122 <h3>Alpha,Gamma, and Theta</h3>
124 This class assumes that it will be used to set up the sim for a
125 steady, zero pitch rate condition. Since any two of those angles
126 specifies the third gamma (flight path angle) is favored when setting
127 alpha and theta and alpha is favored when setting gamma. i.e.
129 - set alpha : recalculate theta using gamma as currently set
130 - set theta : recalculate alpha using gamma as currently set
131 - set gamma : recalculate theta using alpha as currently set
133 The idea being that gamma is most interesting to pilots (since it
134 is indicative of climb rate).
136 Setting climb rate is, for the purpose of this discussion,
137 considered equivalent to setting gamma.
139 These are the items that can be set in an initialization file:
141 - ubody (velocity, ft/sec)
142 - vbody (velocity, ft/sec)
143 - wbody (velocity, ft/sec)
144 - vnorth (velocity, ft/sec)
145 - veast (velocity, ft/sec)
146 - vdown (velocity, ft/sec)
147 - latitude (position, degrees)
148 - longitude (position, degrees)
149 - phi (orientation, degrees)
150 - theta (orientation, degrees)
151 - psi (orientation, degrees)
152 - alpha (angle, degrees)
153 - beta (angle, degrees)
154 - gamma (angle, degrees)
155 - roc (vertical velocity, ft/sec)
156 - elevation (local terrain elevation, ft)
157 - altitude (altitude AGL, ft)
158 - altitudeAGL (altitude AGL, ft)
159 - altitudeMSL (altitude MSL, ft)
160 - winddir (wind from-angle, degrees)
161 - vwind (magnitude wind speed, ft/sec)
162 - hwind (headwind speed, knots)
163 - xwind (crosswind speed, knots)
164 - vc (calibrated airspeed, ft/sec)
166 - vground (ground speed, ft/sec)
167 - running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)
170 @property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
171 @property ic/ve-kts (read/write) Knots equivalent airspeed initial condition
172 @property ic/vg-kts (read/write) Ground speed initial condition in knots
173 @property ic/vt-kts (read/write) True airspeed initial condition in knots
174 @property ic/mach (read/write) Mach initial condition
175 @property ic/roc-fpm (read/write) Rate of climb initial condition in feet/minute
176 @property ic/gamma-deg (read/write) Flightpath angle initial condition in degrees
177 @property ic/alpha-deg (read/write) Angle of attack initial condition in degrees
178 @property ic/beta-deg (read/write) Angle of sideslip initial condition in degrees
179 @property ic/theta-deg (read/write) Pitch angle initial condition in degrees
180 @property ic/phi-deg (read/write) Roll angle initial condition in degrees
181 @property ic/psi-true-deg (read/write) Heading angle initial condition in degrees
182 @property ic/lat-gc-deg (read/write) Latitude initial condition in degrees
183 @property ic/long-gc-deg (read/write) Longitude initial condition in degrees
184 @property ic/h-sl-ft (read/write) Height above sea level initial condition in feet
185 @property ic/h-agl-ft (read/write) Height above ground level initial condition in feet
186 @property ic/sea-level-radius-ft (read/write) Radius of planet at sea level in feet
187 @property ic/terrain-elevation-ft (read/write) Terrain elevation above sea level in feet
188 @property ic/vg-fps (read/write) Ground speed initial condition in feet/second
189 @property ic/vt-fps (read/write) True airspeed initial condition in feet/second
190 @property ic/vw-bx-fps (read/write) Wind velocity initial condition in Body X frame in feet/second
191 @property ic/vw-by-fps (read/write) Wind velocity initial condition in Body Y frame in feet/second
192 @property ic/vw-bz-fps (read/write) Wind velocity initial condition in Body Z frame in feet/second
193 @property ic/vw-north-fps (read/write) Wind northward velocity initial condition in feet/second
194 @property ic/vw-east-fps (read/write) Wind eastward velocity initial condition in feet/second
195 @property ic/vw-down-fps (read/write) Wind downward velocity initial condition in feet/second
196 @property ic/vw-mag-fps (read/write) Wind velocity magnitude initial condition in feet/sec.
197 @property ic/vw-dir-deg (read/write) Wind direction initial condition, in degrees from north
198 @property ic/roc-fps (read/write) Rate of climb initial condition, in feet/second
199 @property ic/u-fps (read/write) Body frame x-axis velocity initial condition in feet/second
200 @property ic/v-fps (read/write) Body frame y-axis velocity initial condition in feet/second
201 @property ic/w-fps (read/write) Body frame z-axis velocity initial condition in feet/second
202 @property ic/vn-fps (read/write) Local frame x-axis (north) velocity initial condition in feet/second
203 @property ic/ve-fps (read/write) Local frame y-axis (east) velocity initial condition in feet/second
204 @property ic/vd-fps (read/write) Local frame z-axis (down) velocity initial condition in feet/second
205 @property ic/gamma-rad (read/write) Flight path angle initial condition in radians
206 @property ic/alpha-rad (read/write) Angle of attack initial condition in radians
207 @property ic/theta-rad (read/write) Pitch angle initial condition in radians
208 @property ic/beta-rad (read/write) Angle of sideslip initial condition in radians
209 @property ic/phi-rad (read/write) Roll angle initial condition in radians
210 @property ic/psi-true-rad (read/write) Heading angle initial condition in radians
211 @property ic/lat-gc-rad (read/write) Geocentric latitude initial condition in radians
212 @property ic/long-gc-rad (read/write) Longitude initial condition in radians
213 @property ic/p-rad_sec (read/write) Roll rate initial condition in radians/second
214 @property ic/q-rad_sec (read/write) Pitch rate initial condition in radians/second
215 @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
218 @version "$Id: FGInitialCondition.h,v 1.32 2011/11/06 18:14:51 bcoconni Exp $"
221 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
225 class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
229 FGInitialCondition(FGFDMExec *fdmex);
231 ~FGInitialCondition();
233 /** Set calibrated airspeed initial condition in knots.
234 @param vc Calibrated airspeed in knots */
235 void SetVcalibratedKtsIC(double vc);
237 /** Set equivalent airspeed initial condition in knots.
238 @param ve Equivalent airspeed in knots */
239 void SetVequivalentKtsIC(double ve);
241 /** Set true airspeed initial condition in knots.
242 @param vtrue True airspeed in knots */
243 void SetVtrueKtsIC(double vtrue) { SetVtrueFpsIC(vtrue*ktstofps); }
245 /** Set ground speed initial condition in knots.
246 @param vg Ground speed in knots */
247 void SetVgroundKtsIC(double vg) { SetVgroundFpsIC(vg*ktstofps); }
249 /** Set mach initial condition.
250 @param mach Mach number */
251 void SetMachIC(double mach);
253 /** Sets angle of attack initial condition in degrees.
254 @param a Alpha in degrees */
255 void SetAlphaDegIC(double a) { SetAlphaRadIC(a*degtorad); }
257 /** Sets angle of sideslip initial condition in degrees.
258 @param B Beta in degrees */
259 void SetBetaDegIC(double b) { SetBetaRadIC(b*degtorad);}
261 /** Sets pitch angle initial condition in degrees.
262 @param theta Theta (pitch) angle in degrees */
263 void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
265 /** Resets the IC data structure to new values
266 @param u, v, w, ... **/
267 void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
268 double alpha0, double beta0, double phi0, double theta0, double psi0,
269 double latitudeRad0, double longitudeRad0, double altitudeAGL0,
272 /** Sets the roll angle initial condition in degrees.
273 @param phi roll angle in degrees */
274 void SetPhiDegIC(double phi) { SetPhiRadIC(phi*degtorad);}
276 /** Sets the heading angle initial condition in degrees.
277 @param psi Heading angle in degrees */
278 void SetPsiDegIC(double psi){ SetPsiRadIC(psi*degtorad); }
280 /** Sets the climb rate initial condition in feet/minute.
281 @param roc Rate of Climb in feet/minute */
282 void SetClimbRateFpmIC(double roc) { SetClimbRateFpsIC(roc/60.0); }
284 /** Sets the flight path angle initial condition in degrees.
285 @param gamma Flight path angle in degrees */
286 void SetFlightPathAngleDegIC(double gamma)
287 { SetClimbRateFpsIC(vt*sin(gamma*degtorad)); }
289 /** Sets the altitude above sea level initial condition in feet.
290 @param altitudeASL Altitude above sea level in feet */
291 void SetAltitudeASLFtIC(double altitudeASL);
293 /** Sets the initial Altitude above ground level.
294 @param agl Altitude above ground level in feet */
295 void SetAltitudeAGLFtIC(double agl);
297 /** Sets the initial sea level radius from planet center
298 @param sl_rad sea level radius in feet */
299 void SetSeaLevelRadiusFtIC(double slr);
301 /** Sets the initial terrain elevation.
302 @param elev Initial terrain elevation in feet */
303 void SetTerrainElevationFtIC(double elev);
305 /** Sets the initial latitude.
306 @param lat Initial latitude in degrees */
307 void SetLatitudeDegIC(double lat) { SetLatitudeRadIC(lat*degtorad); }
309 /** Sets the initial longitude.
310 @param lon Initial longitude in degrees */
311 void SetLongitudeDegIC(double lon) { SetLongitudeRadIC(lon*degtorad); }
313 /** Gets the initial calibrated airspeed.
314 @return Initial calibrated airspeed in knots */
315 double GetVcalibratedKtsIC(void) const;
317 /** Gets the initial equivalent airspeed.
318 @return Initial equivalent airspeed in knots */
319 double GetVequivalentKtsIC(void) const;
321 /** Gets the initial ground speed.
322 @return Initial ground speed in knots */
323 double GetVgroundKtsIC(void) const { return GetVgroundFpsIC() * fpstokts; }
325 /** Gets the initial true velocity.
326 @return Initial true airspeed in knots. */
327 double GetVtrueKtsIC(void) const { return vt*fpstokts; }
329 /** Gets the initial mach.
330 @return Initial mach number */
331 double GetMachIC(void) const;
333 /** Gets the initial climb rate.
334 @return Initial climb rate in feet/minute */
335 double GetClimbRateFpmIC(void) const
336 { return GetClimbRateFpsIC()*60; }
338 /** Gets the initial flight path angle.
339 @return Initial flight path angle in degrees */
340 double GetFlightPathAngleDegIC(void) const
341 { return GetFlightPathAngleRadIC()*radtodeg; }
343 /** Gets the initial angle of attack.
344 @return Initial alpha in degrees */
345 double GetAlphaDegIC(void) const { return alpha*radtodeg; }
347 /** Gets the initial sideslip angle.
348 @return Initial beta in degrees */
349 double GetBetaDegIC(void) const { return beta*radtodeg; }
351 /** Gets the initial pitch angle.
352 @return Initial pitch angle in degrees */
353 double GetThetaDegIC(void) const { return orientation.GetEulerDeg(eTht); }
355 /** Gets the initial roll angle.
356 @return Initial phi in degrees */
357 double GetPhiDegIC(void) const { return orientation.GetEulerDeg(ePhi); }
359 /** Gets the initial heading angle.
360 @return Initial psi in degrees */
361 double GetPsiDegIC(void) const { return orientation.GetEulerDeg(ePsi); }
363 /** Gets the initial latitude.
364 @return Initial geocentric latitude in degrees */
365 double GetLatitudeDegIC(void) const { return position.GetLatitudeDeg(); }
367 /** Gets the initial longitude.
368 @return Initial longitude in degrees */
369 double GetLongitudeDegIC(void) const { return position.GetLongitudeDeg(); }
371 /** Gets the initial altitude above sea level.
372 @return Initial altitude in feet. */
373 double GetAltitudeASLFtIC(void) const { return position.GetAltitudeASL(); }
375 /** Gets the initial altitude above ground level.
376 @return Initial altitude AGL in feet */
377 double GetAltitudeAGLFtIC(void) const;
379 /** Gets the initial terrain elevation.
380 @return Initial terrain elevation in feet */
381 double GetTerrainElevationFtIC(void) const;
383 /** Sets the initial ground speed.
384 @param vg Initial ground speed in feet/second */
385 void SetVgroundFpsIC(double vg);
387 /** Sets the initial true airspeed.
388 @param vt Initial true airspeed in feet/second */
389 void SetVtrueFpsIC(double vt);
391 /** Sets the initial body axis X velocity.
392 @param ubody Initial X velocity in feet/second */
393 void SetUBodyFpsIC(double ubody) { SetBodyVelFpsIC(eU, ubody); }
395 /** Sets the initial body axis Y velocity.
396 @param vbody Initial Y velocity in feet/second */
397 void SetVBodyFpsIC(double vbody) { SetBodyVelFpsIC(eV, vbody); }
399 /** Sets the initial body axis Z velocity.
400 @param wbody Initial Z velocity in feet/second */
401 void SetWBodyFpsIC(double wbody) { SetBodyVelFpsIC(eW, wbody); }
403 /** Sets the initial local axis north velocity.
404 @param vn Initial north velocity in feet/second */
405 void SetVNorthFpsIC(double vn) { SetNEDVelFpsIC(eU, vn); }
407 /** Sets the initial local axis east velocity.
408 @param ve Initial east velocity in feet/second */
409 void SetVEastFpsIC(double ve) { SetNEDVelFpsIC(eV, ve); }
411 /** Sets the initial local axis down velocity.
412 @param vd Initial down velocity in feet/second */
413 void SetVDownFpsIC(double vd) { SetNEDVelFpsIC(eW, vd); }
415 /** Sets the initial body axis roll rate.
416 @param P Initial roll rate in radians/second */
417 void SetPRadpsIC(double P) { vPQR_body(eP) = P; }
419 /** Sets the initial body axis pitch rate.
420 @param Q Initial pitch rate in radians/second */
421 void SetQRadpsIC(double Q) { vPQR_body(eQ) = Q; }
423 /** Sets the initial body axis yaw rate.
424 @param R initial yaw rate in radians/second */
425 void SetRRadpsIC(double R) { vPQR_body(eR) = R; }
427 /** Sets the initial wind velocity.
428 @param wN Initial wind velocity in local north direction, feet/second
429 @param wE Initial wind velocity in local east direction, feet/second
430 @param wD Initial wind velocity in local down direction, feet/second */
431 void SetWindNEDFpsIC(double wN, double wE, double wD);
433 /** Sets the initial total wind speed.
434 @param mag Initial wind velocity magnitude in knots */
435 void SetWindMagKtsIC(double mag);
437 /** Sets the initial wind direction.
438 @param dir Initial direction wind is coming from in degrees */
439 void SetWindDirDegIC(double dir);
441 /** Sets the initial headwind velocity.
442 @param head Initial headwind speed in knots */
443 void SetHeadWindKtsIC(double head);
445 /** Sets the initial crosswind speed.
446 @param cross Initial crosswind speed, positive from left to right */
447 void SetCrossWindKtsIC(double cross);
449 /** Sets the initial wind downward speed.
450 @param wD Initial downward wind speed in knots*/
451 void SetWindDownKtsIC(double wD);
453 /** Sets the initial climb rate.
454 @param roc Initial Rate of climb in feet/second */
455 void SetClimbRateFpsIC(double roc);
457 /** Gets the initial ground velocity.
458 @return Initial ground velocity in feet/second */
459 double GetVgroundFpsIC(void) const { return vUVW_NED.Magnitude(eU, eV); }
461 /** Gets the initial true velocity.
462 @return Initial true velocity in feet/second */
463 double GetVtrueFpsIC(void) const { return vt; }
465 /** Gets the initial body axis X wind velocity.
466 @return Initial body axis X wind velocity in feet/second */
467 double GetWindUFpsIC(void) const { return GetBodyWindFpsIC(eU); }
469 /** Gets the initial body axis Y wind velocity.
470 @return Initial body axis Y wind velocity in feet/second */
471 double GetWindVFpsIC(void) const { return GetBodyWindFpsIC(eV); }
473 /** Gets the initial body axis Z wind velocity.
474 @return Initial body axis Z wind velocity in feet/second */
475 double GetWindWFpsIC(void) const { return GetBodyWindFpsIC(eW); }
477 /** Gets the initial wind velocity in the NED local frame
478 @return Initial wind velocity in NED frame in feet/second */
479 const FGColumnVector3 GetWindNEDFpsIC(void) const {
480 const FGMatrix33& Tb2l = orientation.GetTInv();
481 FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
482 return _vt_NED - vUVW_NED;
485 /** Gets the initial wind velocity in local frame.
486 @return Initial wind velocity toward north in feet/second */
487 double GetWindNFpsIC(void) const { return GetNEDWindFpsIC(eX); }
489 /** Gets the initial wind velocity in local frame.
490 @return Initial wind velocity eastwards in feet/second */
491 double GetWindEFpsIC(void) const { return GetNEDWindFpsIC(eY); }
493 /** Gets the initial wind velocity in local frame.
494 @return Initial wind velocity downwards in feet/second */
495 double GetWindDFpsIC(void) const { return GetNEDWindFpsIC(eZ); }
497 /** Gets the initial total wind velocity in feet/sec.
498 @return Initial wind velocity in feet/second */
499 double GetWindFpsIC(void) const;
501 /** Gets the initial wind direction.
502 @return Initial wind direction in feet/second */
503 double GetWindDirDegIC(void) const;
505 /** Gets the initial climb rate.
506 @return Initial rate of climb in feet/second */
507 double GetClimbRateFpsIC(void) const
509 const FGMatrix33& Tb2l = orientation.GetTInv();
510 FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
514 /** Gets the initial body velocity
515 @return Initial body velocity in feet/second. */
516 const FGColumnVector3 GetUVWFpsIC(void) const {
517 const FGMatrix33& Tl2b = orientation.GetT();
518 return Tl2b * vUVW_NED;
521 /** Gets the initial body axis X velocity.
522 @return Initial body axis X velocity in feet/second. */
523 double GetUBodyFpsIC(void) const { return GetBodyVelFpsIC(eU); }
525 /** Gets the initial body axis Y velocity.
526 @return Initial body axis Y velocity in feet/second. */
527 double GetVBodyFpsIC(void) const { return GetBodyVelFpsIC(eV); }
529 /** Gets the initial body axis Z velocity.
530 @return Initial body axis Z velocity in feet/second. */
531 double GetWBodyFpsIC(void) const { return GetBodyVelFpsIC(eW); }
533 /** Gets the initial local frame X (North) velocity.
534 @return Initial local frame X (North) axis velocity in feet/second. */
535 double GetVNorthFpsIC(void) const { return vUVW_NED(eU); }
537 /** Gets the initial local frame Y (East) velocity.
538 @return Initial local frame Y (East) axis velocity in feet/second. */
539 double GetVEastFpsIC(void) const { return vUVW_NED(eV); }
541 /** Gets the initial local frame Z (Down) velocity.
542 @return Initial local frame Z (Down) axis velocity in feet/second. */
543 double GetVDownFpsIC(void) const { return vUVW_NED(eW); }
545 /** Gets the initial body rotation rate
546 @return Initial body rotation rate in radians/second */
547 const FGColumnVector3 GetPQRRadpsIC(void) const { return vPQR_body; }
549 /** Gets the initial body axis roll rate.
550 @return Initial body axis roll rate in radians/second */
551 double GetPRadpsIC() const { return vPQR_body(eP); }
553 /** Gets the initial body axis pitch rate.
554 @return Initial body axis pitch rate in radians/second */
555 double GetQRadpsIC() const { return vPQR_body(eQ); }
557 /** Gets the initial body axis yaw rate.
558 @return Initial body axis yaw rate in radians/second */
559 double GetRRadpsIC() const { return vPQR_body(eR); }
561 /** Sets the initial flight path angle.
562 @param gamma Initial flight path angle in radians */
563 void SetFlightPathAngleRadIC(double gamma)
564 { SetClimbRateFpsIC(vt*sin(gamma)); }
566 /** Sets the initial angle of attack.
567 @param alpha Initial angle of attack in radians */
568 void SetAlphaRadIC(double alpha);
570 /** Sets the initial sideslip angle.
571 @param beta Initial angle of sideslip in radians. */
572 void SetBetaRadIC(double beta);
574 /** Sets the initial roll angle.
575 @param phi Initial roll angle in radians */
576 void SetPhiRadIC(double phi) { SetEulerAngleRadIC(ePhi, phi); }
578 /** Sets the initial pitch angle.
579 @param theta Initial pitch angle in radians */
580 void SetThetaRadIC(double theta) { SetEulerAngleRadIC(eTht, theta); }
582 /** Sets the initial heading angle.
583 @param psi Initial heading angle in radians */
584 void SetPsiRadIC(double psi) { SetEulerAngleRadIC(ePsi, psi); }
586 /** Sets the initial latitude.
587 @param lat Initial latitude in radians */
588 void SetLatitudeRadIC(double lat);
590 /** Sets the initial longitude.
591 @param lon Initial longitude in radians */
592 void SetLongitudeRadIC(double lon);
594 /** Sets the target normal load factor.
595 @param nlf Normal load factor*/
596 void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
598 /** Gets the initial flight path angle.
599 If total velocity is zero, this function returns zero.
600 @return Initial flight path angle in radians */
601 double GetFlightPathAngleRadIC(void) const
602 { return (vt == 0.0)?0.0:asin(GetClimbRateFpsIC() / vt); }
604 /** Gets the initial angle of attack.
605 @return Initial alpha in radians */
606 double GetAlphaRadIC(void) const { return alpha; }
608 /** Gets the initial angle of sideslip.
609 @return Initial sideslip angle in radians */
610 double GetBetaRadIC(void) const { return beta; }
612 /** Gets the initial position
613 @return Initial location */
614 const FGLocation& GetPosition(void) const { return position; }
616 /** Gets the initial latitude.
617 @return Initial latitude in radians */
618 double GetLatitudeRadIC(void) const { return position.GetLatitude(); }
620 /** Gets the initial longitude.
621 @return Initial longitude in radians */
622 double GetLongitudeRadIC(void) const { return position.GetLongitude(); }
624 /** Gets the initial orientation
625 @return Initial orientation */
626 const FGQuaternion& GetOrientation(void) const { return orientation; }
628 /** Gets the initial roll angle.
629 @return Initial roll angle in radians */
630 double GetPhiRadIC(void) const { return orientation.GetEuler(ePhi); }
632 /** Gets the initial pitch angle.
633 @return Initial pitch angle in radians */
634 double GetThetaRadIC(void) const { return orientation.GetEuler(eTht); }
636 /** Gets the initial heading angle.
637 @return Initial heading angle in radians */
638 double GetPsiRadIC(void) const { return orientation.GetEuler(ePsi); }
640 /** Gets the initial speedset.
641 @return Initial speedset */
642 speedset GetSpeedSet(void) const { return lastSpeedSet; }
644 /** Gets the target normal load factor set from IC.
645 @return target normal load factor set from IC*/
646 double GetTargetNlfIC(void) const { return targetNlfIC; }
648 /** Loads the initial conditions.
649 @param rstname The name of an initial conditions file
650 @param useStoredPath true if the stored path to the IC file should be used
651 @return true if successful */
652 bool Load(string rstname, bool useStoredPath = true );
654 /** Get init-file name
656 string GetInitFile(void) const {return init_file_name;}
657 /** Set init-file name
659 void SetInitFile(string f) { init_file_name = f;}
660 void WriteStateFile(int num);
663 FGColumnVector3 vUVW_NED;
664 FGColumnVector3 vPQR_body;
666 FGQuaternion orientation;
671 FGMatrix33 Tw2b, Tb2w;
674 speedset lastSpeedSet;
675 altitudeset lastAltitudeSet;
678 FGPropertyManager *PropertyManager;
679 FGAtmosphere* Atmosphere;
686 void InitializeIC(void);
687 void SetEulerAngleRadIC(int idx, double angle);
688 void SetBodyVelFpsIC(int idx, double vel);
689 void SetNEDVelFpsIC(int idx, double vel);
690 double GetBodyWindFpsIC(int idx) const;
691 double GetNEDWindFpsIC(int idx) const;
692 double GetBodyVelFpsIC(int idx) const;
693 void calcAeroAngles(const FGColumnVector3& _vt_BODY);
694 void calcThetaBeta(double alfa, const FGColumnVector3& _vt_NED);
696 void Debug(int from);
698 string init_file_name;