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.27 2011/05/20 00:47:03 bcoconni Exp $"
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 class FGColumnVector3;
69 typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75 /** Initializes the simulation run.
76 Takes a set of initial conditions (IC) and provide a kinematically consistent set
77 of body axis velocity components, euler angles, and altitude. This class
78 does not attempt to trim the model i.e. the sim will most likely start in a
79 very dynamic state (unless, of course, you have chosen your IC's wisely, or
80 started on the ground) even after setting it up with this class.
84 With a valid object of FGFDMExec and an aircraft model loaded:
87 FGInitialCondition* fgic = FDMExec->GetIC();
89 // Reset the initial conditions and set VCAS and altitude
91 fgic->SetVcalibratedKtsIC(vcas);
92 fgic->SetAltitudeAGLFtIC(altitude);
95 FDMExec->GetPropagate()->SetInitialState(fgic);
99 //or to loop the sim w/o integrating
103 Alternatively, you can load initial conditions from an XML file:
106 FGInitialCondition* fgic = FDMExec->GetIC();
112 Since vc, ve, vt, and mach all represent speed, the remaining
113 three are recalculated each time one of them is set (using the
114 current altitude). The most recent speed set is remembered so
115 that if and when altitude is reset, the last set speed is used
116 to recalculate the remaining three. Setting any of the body
117 components forces a recalculation of vt and vt then becomes the
118 most recent speed set.
120 <h3>Alpha,Gamma, and Theta</h3>
122 This class assumes that it will be used to set up the sim for a
123 steady, zero pitch rate condition. Since any two of those angles
124 specifies the third gamma (flight path angle) is favored when setting
125 alpha and theta and alpha is favored when setting gamma. i.e.
127 - set alpha : recalculate theta using gamma as currently set
128 - set theta : recalculate alpha using gamma as currently set
129 - set gamma : recalculate theta using alpha as currently set
131 The idea being that gamma is most interesting to pilots (since it
132 is indicative of climb rate).
134 Setting climb rate is, for the purpose of this discussion,
135 considered equivalent to setting gamma.
137 These are the items that can be set in an initialization file:
139 - ubody (velocity, ft/sec)
140 - vbody (velocity, ft/sec)
141 - wbody (velocity, ft/sec)
142 - vnorth (velocity, ft/sec)
143 - veast (velocity, ft/sec)
144 - vdown (velocity, ft/sec)
145 - latitude (position, degrees)
146 - longitude (position, degrees)
147 - phi (orientation, degrees)
148 - theta (orientation, degrees)
149 - psi (orientation, degrees)
150 - alpha (angle, degrees)
151 - beta (angle, degrees)
152 - gamma (angle, degrees)
153 - roc (vertical velocity, ft/sec)
154 - elevation (local terrain elevation, ft)
155 - altitude (altitude AGL, ft)
156 - altitudeAGL (altitude AGL, ft)
157 - altitudeMSL (altitude MSL, ft)
158 - winddir (wind from-angle, degrees)
159 - vwind (magnitude wind speed, ft/sec)
160 - hwind (headwind speed, knots)
161 - xwind (crosswind speed, knots)
162 - vc (calibrated airspeed, ft/sec)
164 - vground (ground speed, ft/sec)
165 - running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)
168 @property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
169 @property ic/ve-kts (read/write) Knots equivalent airspeed initial condition
170 @property ic/vg-kts (read/write) Ground speed initial condition in knots
171 @property ic/vt-kts (read/write) True airspeed initial condition in knots
172 @property ic/mach (read/write) Mach initial condition
173 @property ic/roc-fpm (read/write) Rate of climb initial condition in feet/minute
174 @property ic/gamma-deg (read/write) Flightpath angle initial condition in degrees
175 @property ic/alpha-deg (read/write) Angle of attack initial condition in degrees
176 @property ic/beta-deg (read/write) Angle of sideslip initial condition in degrees
177 @property ic/theta-deg (read/write) Pitch angle initial condition in degrees
178 @property ic/phi-deg (read/write) Roll angle initial condition in degrees
179 @property ic/psi-true-deg (read/write) Heading angle initial condition in degrees
180 @property ic/lat-gc-deg (read/write) Latitude initial condition in degrees
181 @property ic/long-gc-deg (read/write) Longitude initial condition in degrees
182 @property ic/h-sl-ft (read/write) Height above sea level initial condition in feet
183 @property ic/h-agl-ft (read/write) Height above ground level initial condition in feet
184 @property ic/sea-level-radius-ft (read/write) Radius of planet at sea level in feet
185 @property ic/terrain-elevation-ft (read/write) Terrain elevation above sea level in feet
186 @property ic/vg-fps (read/write) Ground speed initial condition in feet/second
187 @property ic/vt-fps (read/write) True airspeed initial condition in feet/second
188 @property ic/vw-bx-fps (read/write) Wind velocity initial condition in Body X frame in feet/second
189 @property ic/vw-by-fps (read/write) Wind velocity initial condition in Body Y frame in feet/second
190 @property ic/vw-bz-fps (read/write) Wind velocity initial condition in Body Z frame in feet/second
191 @property ic/vw-north-fps (read/write) Wind northward velocity initial condition in feet/second
192 @property ic/vw-east-fps (read/write) Wind eastward velocity initial condition in feet/second
193 @property ic/vw-down-fps (read/write) Wind downward velocity initial condition in feet/second
194 @property ic/vw-mag-fps (read/write) Wind velocity magnitude initial condition in feet/sec.
195 @property ic/vw-dir-deg (read/write) Wind direction initial condition, in degrees from north
196 @property ic/roc-fps (read/write) Rate of climb initial condition, in feet/second
197 @property ic/u-fps (read/write) Body frame x-axis velocity initial condition in feet/second
198 @property ic/v-fps (read/write) Body frame y-axis velocity initial condition in feet/second
199 @property ic/w-fps (read/write) Body frame z-axis velocity initial condition in feet/second
200 @property ic/vn-fps (read/write) Local frame x-axis (north) velocity initial condition in feet/second
201 @property ic/ve-fps (read/write) Local frame y-axis (east) velocity initial condition in feet/second
202 @property ic/vd-fps (read/write) Local frame z-axis (down) velocity initial condition in feet/second
203 @property ic/gamma-rad (read/write) Flight path angle initial condition in radians
204 @property ic/alpha-rad (read/write) Angle of attack initial condition in radians
205 @property ic/theta-rad (read/write) Pitch angle initial condition in radians
206 @property ic/beta-rad (read/write) Angle of sideslip initial condition in radians
207 @property ic/phi-rad (read/write) Roll angle initial condition in radians
208 @property ic/psi-true-rad (read/write) Heading angle initial condition in radians
209 @property ic/lat-gc-rad (read/write) Geocentric latitude initial condition in radians
210 @property ic/long-gc-rad (read/write) Longitude initial condition in radians
211 @property ic/p-rad_sec (read/write) Roll rate initial condition in radians/second
212 @property ic/q-rad_sec (read/write) Pitch rate initial condition in radians/second
213 @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
216 @version "$Id: FGInitialCondition.h,v 1.27 2011/05/20 00:47:03 bcoconni Exp $"
219 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
223 class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
227 FGInitialCondition(FGFDMExec *fdmex);
229 ~FGInitialCondition();
231 /** Set calibrated airspeed initial condition in knots.
232 @param vc Calibrated airspeed in knots */
233 void SetVcalibratedKtsIC(double vc);
235 /** Set equivalent airspeed initial condition in knots.
236 @param ve Equivalent airspeed in knots */
237 void SetVequivalentKtsIC(double ve);
239 /** Set true airspeed initial condition in knots.
240 @param vt True airspeed in knots */
241 void SetVtrueKtsIC(double vtrue) { SetVtrueFpsIC(vtrue*ktstofps); }
243 /** Set ground speed initial condition in knots.
244 @param vg Ground speed in knots */
245 void SetVgroundKtsIC(double vg) { SetVgroundFpsIC(vg*ktstofps); }
247 /** Set mach initial condition.
248 @param mach Mach number */
249 void SetMachIC(double mach);
251 /** Sets angle of attack initial condition in degrees.
252 @param a Alpha in degrees */
253 void SetAlphaDegIC(double a) { SetAlphaRadIC(a*degtorad); }
255 /** Sets angle of sideslip initial condition in degrees.
256 @param B Beta in degrees */
257 void SetBetaDegIC(double b) { SetBetaRadIC(b*degtorad);}
259 /** Sets pitch angle initial condition in degrees.
260 @param theta Theta (pitch) angle in degrees */
261 void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
263 /** Resets the IC data structure to new values
264 @param u, v, w, ... **/
265 void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
266 double alpha0, double beta0, double phi0, double theta0, double psi0,
267 double latitudeRad0, double longitudeRad0, double altitudeAGL0,
270 /** Sets the roll angle initial condition in degrees.
271 @param phi roll angle in degrees */
272 void SetPhiDegIC(double phi) { SetPhiRadIC(phi*degtorad);}
274 /** Sets the heading angle initial condition in degrees.
275 @param psi Heading angle in degrees */
276 void SetPsiDegIC(double psi){ SetPsiRadIC(psi*degtorad); }
278 /** Sets the climb rate initial condition in feet/minute.
279 @param roc Rate of Climb in feet/minute */
280 void SetClimbRateFpmIC(double roc) { SetClimbRateFpsIC(roc/60.0); }
282 /** Sets the flight path angle initial condition in degrees.
283 @param gamma Flight path angle in degrees */
284 void SetFlightPathAngleDegIC(double gamma)
285 { SetClimbRateFpsIC(vt*sin(gamma*degtorad)); }
287 /** Sets the altitude above sea level initial condition in feet.
288 @param altitudeASL Altitude above sea level in feet */
289 void SetAltitudeASLFtIC(double altitudeASL);
291 /** Sets the initial Altitude above ground level.
292 @param agl Altitude above ground level in feet */
293 void SetAltitudeAGLFtIC(double agl)
294 { SetAltitudeASLFtIC(terrain_elevation + agl); }
296 /** Sets the initial sea level radius from planet center
297 @param sl_rad sea level radius in feet */
298 void SetSeaLevelRadiusFtIC(double sl_rad) { sea_level_radius = sl_rad; }
300 /** Sets the initial terrain elevation.
301 @param elev Initial terrain elevation in feet */
302 void SetTerrainElevationFtIC(double elev) { terrain_elevation = elev; }
304 /** Sets the initial latitude.
305 @param lat Initial latitude in degrees */
306 void SetLatitudeDegIC(double lat) { position.SetLatitude(lat*degtorad); }
308 /** Sets the initial longitude.
309 @param lon Initial longitude in degrees */
310 void SetLongitudeDegIC(double lon) { position.SetLongitude(lon*degtorad); }
312 /** Gets the initial calibrated airspeed.
313 @return Initial calibrated airspeed in knots */
314 double GetVcalibratedKtsIC(void) const;
316 /** Gets the initial equivalent airspeed.
317 @return Initial equivalent airspeed in knots */
318 double GetVequivalentKtsIC(void) const;
320 /** Gets the initial ground speed.
321 @return Initial ground speed in knots */
322 double GetVgroundKtsIC(void) const { return GetVgroundFpsIC() * fpstokts; }
324 /** Gets the initial true velocity.
325 @return Initial true airspeed in knots. */
326 double GetVtrueKtsIC(void) const { return vt*fpstokts; }
328 /** Gets the initial mach.
329 @return Initial mach number */
330 double GetMachIC(void) const;
332 /** Gets the initial climb rate.
333 @return Initial climb rate in feet/minute */
334 double GetClimbRateFpmIC(void) const
335 { return GetClimbRateFpsIC()*60; }
337 /** Gets the initial flight path angle.
338 @return Initial flight path angle in degrees */
339 double GetFlightPathAngleDegIC(void) const
340 { return GetFlightPathAngleRadIC()*radtodeg; }
342 /** Gets the initial angle of attack.
343 @return Initial alpha in degrees */
344 double GetAlphaDegIC(void) const { return alpha*radtodeg; }
346 /** Gets the initial sideslip angle.
347 @return Initial beta in degrees */
348 double GetBetaDegIC(void) const { return beta*radtodeg; }
350 /** Gets the initial pitch angle.
351 @return Initial pitch angle in degrees */
352 double GetThetaDegIC(void) const { return theta*radtodeg; }
354 /** Gets the initial roll angle.
355 @return Initial phi in degrees */
356 double GetPhiDegIC(void) const { return phi*radtodeg; }
358 /** Gets the initial heading angle.
359 @return Initial psi in degrees */
360 double GetPsiDegIC(void) const { return psi*radtodeg; }
362 /** Gets the initial latitude.
363 @return Initial geocentric latitude in degrees */
364 double GetLatitudeDegIC(void) const { return position.GetLatitudeDeg(); }
366 /** Gets the initial longitude.
367 @return Initial longitude in degrees */
368 double GetLongitudeDegIC(void) const { return position.GetLongitudeDeg(); }
370 /** Gets the initial altitude above sea level.
371 @return Initial altitude in feet. */
372 double GetAltitudeASLFtIC(void) const { return position.GetRadius() - sea_level_radius; }
374 /** Gets the initial altitude above ground level.
375 @return Initial altitude AGL in feet */
376 double GetAltitudeAGLFtIC(void) const { return position.GetRadius() - sea_level_radius - terrain_elevation; }
378 /** Gets the initial sea level radius.
379 @return Initial sea level radius */
380 double GetSeaLevelRadiusFtIC(void) const { return sea_level_radius; }
382 /** Gets the initial terrain elevation.
383 @return Initial terrain elevation in feet */
384 double GetTerrainElevationFtIC(void) const { return terrain_elevation; }
386 /** Sets the initial ground speed.
387 @param vg Initial ground speed in feet/second */
388 void SetVgroundFpsIC(double vg);
390 /** Sets the initial true airspeed.
391 @param vt Initial true airspeed in feet/second */
392 void SetVtrueFpsIC(double vt);
394 /** Sets the initial body axis X velocity.
395 @param ubody Initial X velocity in feet/second */
396 void SetUBodyFpsIC(double ubody) { SetBodyVelFpsIC(eU, ubody); }
398 /** Sets the initial body axis Y velocity.
399 @param vbody Initial Y velocity in feet/second */
400 void SetVBodyFpsIC(double vbody) { SetBodyVelFpsIC(eV, vbody); }
402 /** Sets the initial body axis Z velocity.
403 @param wbody Initial Z velocity in feet/second */
404 void SetWBodyFpsIC(double wbody) { SetBodyVelFpsIC(eW, wbody); }
406 /** Sets the initial local axis north velocity.
407 @param vn Initial north velocity in feet/second */
408 void SetVNorthFpsIC(double vn) { SetNEDVelFpsIC(eU, vn); }
410 /** Sets the initial local axis east velocity.
411 @param ve Initial east velocity in feet/second */
412 void SetVEastFpsIC(double ve) { SetNEDVelFpsIC(eV, ve); }
414 /** Sets the initial local axis down velocity.
415 @param vd Initial down velocity in feet/second */
416 void SetVDownFpsIC(double vd) { SetNEDVelFpsIC(eW, vd); }
418 /** Sets the initial roll rate.
419 @param P Initial roll rate in radians/second */
420 void SetPRadpsIC(double P) { p = P; }
422 /** Sets the initial pitch rate.
423 @param Q Initial pitch rate in radians/second */
424 void SetQRadpsIC(double Q) { q = Q; }
426 /** Sets the initial yaw rate.
427 @param R initial yaw rate in radians/second */
428 void SetRRadpsIC(double R) { r = R; }
430 /** Sets the initial wind velocity.
431 @param wN Initial wind velocity in local north direction, feet/second
432 @param wE Initial wind velocity in local east direction, feet/second
433 @param wD Initial wind velocity in local down direction, feet/second */
434 void SetWindNEDFpsIC(double wN, double wE, double wD);
436 /** Sets the initial total wind speed.
437 @param mag Initial wind velocity magnitude in knots */
438 void SetWindMagKtsIC(double mag);
440 /** Sets the initial wind direction.
441 @param dir Initial direction wind is coming from in degrees */
442 void SetWindDirDegIC(double dir);
444 /** Sets the initial headwind velocity.
445 @param head Initial headwind speed in knots */
446 void SetHeadWindKtsIC(double head);
448 /** Sets the initial crosswind speed.
449 @param cross Initial crosswind speed, positive from left to right */
450 void SetCrossWindKtsIC(double cross);
452 /** Sets the initial wind downward speed.
453 @param wD Initial downward wind speed in knots*/
454 void SetWindDownKtsIC(double wD);
456 /** Sets the initial climb rate.
457 @param roc Initial Rate of climb in feet/second */
458 void SetClimbRateFpsIC(double roc);
460 /** Gets the initial ground velocity.
461 @return Initial ground velocity in feet/second */
462 double GetVgroundFpsIC(void) const { return vUVW_NED.Magnitude(eU, eV); }
464 /** Gets the initial true velocity.
465 @return Initial true velocity in feet/second */
466 double GetVtrueFpsIC(void) const { return vt; }
468 /** Gets the initial body axis X wind velocity.
469 @return Initial body axis X wind velocity in feet/second */
470 double GetWindUFpsIC(void) const { return GetBodyWindFpsIC(eU); }
472 /** Gets the initial body axis Y wind velocity.
473 @return Initial body axis Y wind velocity in feet/second */
474 double GetWindVFpsIC(void) const { return GetBodyWindFpsIC(eV); }
476 /** Gets the initial body axis Z wind velocity.
477 @return Initial body axis Z wind velocity in feet/second */
478 double GetWindWFpsIC(void) const { return GetBodyWindFpsIC(eW); }
480 /** Gets the initial wind velocity in local frame.
481 @return Initial wind velocity toward north in feet/second */
482 double GetWindNFpsIC(void) const { return GetNEDWindFpsIC(eX); }
484 /** Gets the initial wind velocity in local frame.
485 @return Initial wind velocity eastwards in feet/second */
486 double GetWindEFpsIC(void) const { return GetNEDWindFpsIC(eY); }
488 /** Gets the initial wind velocity in local frame.
489 @return Initial wind velocity downwards in feet/second */
490 double GetWindDFpsIC(void) const { return GetNEDWindFpsIC(eZ); }
492 /** Gets the initial total wind velocity in feet/sec.
493 @return Initial wind velocity in feet/second */
494 double GetWindFpsIC(void) const;
496 /** Gets the initial wind direction.
497 @return Initial wind direction in feet/second */
498 double GetWindDirDegIC(void) const;
500 /** Gets the initial climb rate.
501 @return Initial rate of climb in feet/second */
502 double GetClimbRateFpsIC(void) const
504 FGColumnVector3 _vt_NED = Tb2l * Tw2b * FGColumnVector3(vt, 0., 0.);
508 /** Gets the initial body axis X velocity.
509 @return Initial body axis X velocity in feet/second. */
510 double GetUBodyFpsIC(void) const { return GetBodyVelFpsIC(eU); }
512 /** Gets the initial body axis Y velocity.
513 @return Initial body axis Y velocity in feet/second. */
514 double GetVBodyFpsIC(void) const { return GetBodyVelFpsIC(eV); }
516 /** Gets the initial body axis Z velocity.
517 @return Initial body axis Z velocity in feet/second. */
518 double GetWBodyFpsIC(void) const { return GetBodyVelFpsIC(eW); }
520 /** Gets the initial local frame X (North) velocity.
521 @return Initial local frame X (North) axis velocity in feet/second. */
522 double GetVNorthFpsIC(void) const { return vUVW_NED(eU); }
524 /** Gets the initial local frame Y (East) velocity.
525 @return Initial local frame Y (East) axis velocity in feet/second. */
526 double GetVEastFpsIC(void) const { return vUVW_NED(eV); }
528 /** Gets the initial local frame Z (Down) velocity.
529 @return Initial local frame Z (Down) axis velocity in feet/second. */
530 double GetVDownFpsIC(void) const { return vUVW_NED(eW); }
532 /** Gets the initial body axis roll rate.
533 @return Initial body axis roll rate in radians/second */
534 double GetPRadpsIC() const { return p; }
536 /** Gets the initial body axis pitch rate.
537 @return Initial body axis pitch rate in radians/second */
538 double GetQRadpsIC() const { return q; }
540 /** Gets the initial body axis yaw rate.
541 @return Initial body axis yaw rate in radians/second */
542 double GetRRadpsIC() const { return r; }
544 /** Sets the initial flight path angle.
545 @param gamma Initial flight path angle in radians */
546 void SetFlightPathAngleRadIC(double gamma)
547 { SetClimbRateFpsIC(vt*sin(gamma)); }
549 /** Sets the initial angle of attack.
550 @param alpha Initial angle of attack in radians */
551 void SetAlphaRadIC(double alpha);
553 /** Sets the initial pitch angle.
554 @param theta Initial pitch angle in radians */
555 void SetThetaRadIC(double theta);
557 /** Sets the initial sideslip angle.
558 @param beta Initial angle of sideslip in radians. */
559 void SetBetaRadIC(double beta);
561 /** Sets the initial roll angle.
562 @param phi Initial roll angle in radians */
563 void SetPhiRadIC(double phi);
565 /** Sets the initial heading angle.
566 @param psi Initial heading angle in radians */
567 void SetPsiRadIC(double psi);
569 /** Sets the initial latitude.
570 @param lat Initial latitude in radians */
571 void SetLatitudeRadIC(double lat) { position.SetLatitude(lat); }
573 /** Sets the initial longitude.
574 @param lon Initial longitude in radians */
575 void SetLongitudeRadIC(double lon) { position.SetLongitude(lon); }
577 /** Sets the target normal load factor.
578 @param nlf Normal load factor*/
579 void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
581 /** Gets the initial flight path angle.
582 If total velocity is zero, this function returns zero.
583 @return Initial flight path angle in radians */
584 double GetFlightPathAngleRadIC(void) const
585 { return (vt == 0.0)?0.0:asin(GetClimbRateFpsIC() / vt); }
587 /** Gets the initial angle of attack.
588 @return Initial alpha in radians */
589 double GetAlphaRadIC(void) const { return alpha; }
591 /** Gets the initial angle of sideslip.
592 @return Initial sideslip angle in radians */
593 double GetBetaRadIC(void) const { return beta; }
595 /** Gets the initial roll angle.
596 @return Initial roll angle in radians */
597 double GetPhiRadIC(void) const { return phi; }
599 /** Gets the initial latitude.
600 @return Initial latitude in radians */
601 double GetLatitudeRadIC(void) const { return position.GetLatitude(); }
603 /** Gets the initial longitude.
604 @return Initial longitude in radians */
605 double GetLongitudeRadIC(void) const { return position.GetLongitude(); }
607 /** Gets the initial pitch angle.
608 @return Initial pitch angle in radians */
609 double GetThetaRadIC(void) const { return theta; }
611 /** Gets the initial heading angle.
612 @return Initial heading angle in radians */
613 double GetPsiRadIC(void) const { return psi; }
615 /** Gets the initial speedset.
616 @return Initial speedset */
617 speedset GetSpeedSet(void) const { return lastSpeedSet; }
619 /** Gets the target normal load factor set from IC.
620 @return target normal load factor set from IC*/
621 double GetTargetNlfIC(void) const { return targetNlfIC; }
623 /** Loads the initial conditions.
624 @param rstname The name of an initial conditions file
625 @param useStoredPath true if the stored path to the IC file should be used
626 @return true if successful */
627 bool Load(string rstname, bool useStoredPath = true );
629 /** Get init-file name
631 string GetInitFile(void) const {return init_file_name;}
632 /** Set init-file name
634 void SetInitFile(string f) { init_file_name = f;}
635 void WriteStateFile(int num);
638 FGColumnVector3 vUVW_NED;
642 double sea_level_radius;
643 double terrain_elevation;
646 FGMatrix33 Tw2b, Tb2w;
647 FGMatrix33 Tl2b, Tb2l;
648 double alpha, beta, theta, phi, psi;
650 speedset lastSpeedSet;
653 FGPropertyManager *PropertyManager;
660 void InitializeIC(void);
661 void SetBodyVelFpsIC(int idx, double vel);
662 void SetNEDVelFpsIC(int idx, double vel);
663 double GetBodyWindFpsIC(int idx) const;
664 double GetNEDWindFpsIC(int idx) const;
665 double GetBodyVelFpsIC(int idx) const;
666 double getMachFromVcas(double vcas);
667 double calcVcas(double Mach) const;
668 void calcAeroAngles(const FGColumnVector3& _vt_BODY);
669 void calcThetaBeta(double alfa, const FGColumnVector3& _vt_NED);
671 void Debug(int from);
673 string init_file_name;