]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/initialization/FGInitialCondition.h
Bugfix: no automatic runway selection with --parkpos=
[flightgear.git] / src / FDM / JSBSim / initialization / FGInitialCondition.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGInitialCondition.h
4  Author:       Tony Peden
5  Date started: 7/1/99
6
7  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
8
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
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 Lesser General Public License for more
17  details.
18
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.
22
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.
25
26  HISTORY
27 --------------------------------------------------------------------------------
28 7/1/99   TP   Created
29
30 FUNCTIONAL DESCRIPTION
31 --------------------------------------------------------------------------------
32
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.
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 SENTRY
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 #ifndef FGINITIALCONDITION_H
44 #define FGINITIALCONDITION_H
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 INCLUDES
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #include "FGFDMExec.h"
51 #include "FGJSBBase.h"
52 #include "math/FGColumnVector3.h"
53 #include "input_output/FGXMLFileRead.h"
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 DEFINITIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 #define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 FORWARD DECLARATIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 namespace JSBSim {
66
67 typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
68 typedef enum { setwned, setwmd, setwhc } windset;
69
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 CLASS DOCUMENTATION
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73
74 /** Initializes the simulation run.
75     Takes a set of initial conditions (IC) and provide a kinematically consistent set
76     of body axis velocity components, euler angles, and altitude.  This class
77     does not attempt to trim the model i.e. the sim will most likely start in a
78     very dynamic state (unless, of course, you have chosen your IC's wisely, or
79     started on the ground) even after setting it up with this class.
80
81    <h3>Usage Notes</h3>
82
83    With a valid object of FGFDMExec and an aircraft model loaded:
84
85    @code
86    FGInitialCondition fgic=new FGInitialCondition(FDMExec);
87    fgic->SetVcalibratedKtsIC()
88    fgic->SetAltitudeAGLFtIC();
89
90    // directly into Run
91    FDMExec->GetState()->Initialize(fgic)
92    delete fgic;
93    FDMExec->Run()
94
95    //or to loop the sim w/o integrating
96    FDMExec->RunIC(fgic)
97    @endcode
98
99    <h3>Speed</h3>
100
101    Since vc, ve, vt, and mach all represent speed, the remaining
102    three are recalculated each time one of them is set (using the
103    current altitude).  The most recent speed set is remembered so
104    that if and when altitude is reset, the last set speed is used
105    to recalculate the remaining three. Setting any of the body
106    components forces a recalculation of vt and vt then becomes the
107    most recent speed set.
108
109    <h3>Alpha,Gamma, and Theta</h3>
110
111    This class assumes that it will be used to set up the sim for a
112    steady, zero pitch rate condition. Since any two of those angles
113    specifies the third gamma (flight path angle) is favored when setting
114    alpha and theta and alpha is favored when setting gamma. i.e.
115
116    - set alpha : recalculate theta using gamma as currently set
117    - set theta : recalculate alpha using gamma as currently set
118    - set gamma : recalculate theta using alpha as currently set
119
120    The idea being that gamma is most interesting to pilots (since it
121    is indicative of climb rate).
122
123    Setting climb rate is, for the purpose of this discussion,
124    considered equivalent to setting gamma.
125
126    These are the items that can be set in an initialization file:
127
128    - ubody (velocity, ft/sec)
129    - vbody (velocity, ft/sec)
130    - wbody (velocity, ft/sec)
131    - vnorth (velocity, ft/sec)
132    - veast (velocity, ft/sec)
133    - vdown (velocity, ft/sec)
134    - latitude (position, degrees)
135    - longitude (position, degrees)
136    - phi (orientation, degrees)
137    - theta (orientation, degrees)
138    - psi (orientation, degrees)
139    - alpha (angle, degrees)
140    - beta (angle, degrees)
141    - gamma (angle, degrees)
142    - roc (vertical velocity, ft/sec)
143    - elevation (local terrain elevation, ft)
144    - altitude (altitude AGL, ft)
145    - altitudeAGL (altitude AGL, ft)
146    - altitudeMSL (altitude MSL, ft)
147    - winddir (wind from-angle, degrees)
148    - vwind (magnitude wind speed, ft/sec)
149    - hwind (headwind speed, knots)
150    - xwind (crosswind speed, knots)
151    - vc (calibrated airspeed, ft/sec)
152    - mach (mach)
153    - vground (ground speed, ft/sec)
154    - running (0 or 1)
155
156    <h3>Properties</h3>
157    @property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
158    @property ic/ve-kts (read/write) Knots equivalent airspeed initial condition
159    @property ic/vg-kts (read/write) Ground speed initial condition in knots
160    @property ic/vt-kts (read/write) True airspeed initial condition in knots
161    @property ic/mach (read/write) Mach initial condition
162    @property ic/roc-fpm (read/write) Rate of climb initial condition in feet/minute
163    @property ic/gamma-deg (read/write) Flightpath angle initial condition in degrees
164    @property ic/alpha-deg (read/write) Angle of attack initial condition in degrees
165    @property ic/beta-deg (read/write) Angle of sideslip initial condition in degrees
166    @property ic/theta-deg (read/write) Pitch angle initial condition in degrees
167    @property ic/phi-deg (read/write) Roll angle initial condition in degrees
168    @property ic/psi-true-deg (read/write) Heading angle initial condition in degrees
169    @property ic/lat-gc-deg (read/write) Latitude initial condition in degrees
170    @property ic/long-gc-deg (read/write) Longitude initial condition in degrees
171    @property ic/h-sl-ft (read/write) Height above sea level initial condition in feet
172    @property ic/h-agl-ft (read/write) Height above ground level initial condition in feet
173    @property ic/sea-level-radius-ft (read/write) Radius of planet at sea level in feet
174    @property ic/terrain-elevation-ft (read/write) Terrain elevation above sea level in feet
175    @property ic/vg-fps (read/write) Ground speed initial condition in feet/second
176    @property ic/vt-fps (read/write) True airspeed initial condition in feet/second
177    @property ic/vw-bx-fps (read/write) Wind velocity initial condition in Body X frame in feet/second
178    @property ic/vw-by-fps (read/write) Wind velocity initial condition in Body Y frame in feet/second
179    @property ic/vw-bz-fps (read/write) Wind velocity initial condition in Body Z frame in feet/second
180    @property ic/vw-north-fps (read/write) Wind northward velocity initial condition in feet/second
181    @property ic/vw-east-fps (read/write) Wind eastward velocity initial condition in feet/second
182    @property ic/vw-down-fps (read/write) Wind downward velocity initial condition in feet/second
183    @property ic/vw-mag-fps (read/write) Wind velocity magnitude initial condition in feet/sec.
184    @property ic/vw-dir-deg (read/write) Wind direction initial condition, in degrees from north
185    @property ic/roc-fps (read/write) Rate of climb initial condition, in feet/second
186    @property ic/u-fps (read/write) Body frame x-axis velocity initial condition in feet/second
187    @property ic/v-fps (read/write) Body frame y-axis velocity initial condition in feet/second
188    @property ic/w-fps (read/write) Body frame z-axis velocity initial condition in feet/second
189    @property ic/vn-fps (read/write) Local frame x-axis (north) velocity initial condition in feet/second
190    @property ic/ve-fps (read/write) Local frame y-axis (east) velocity initial condition in feet/second
191    @property ic/vd-fps (read/write) Local frame z-axis (down) velocity initial condition in feet/second
192    @property ic/gamma-rad (read/write) Flight path angle initial condition in radians
193    @property ic/alpha-rad (read/write) Angle of attack initial condition in radians
194    @property ic/theta-rad (read/write) Pitch angle initial condition in radians
195    @property ic/beta-rad (read/write) Angle of sideslip initial condition in radians
196    @property ic/phi-rad (read/write) Roll angle initial condition in radians
197    @property ic/psi-true-rad (read/write) Heading angle initial condition in radians
198    @property ic/lat-gc-rad (read/write) Geocentric latitude initial condition in radians
199    @property ic/long-gc-rad (read/write) Longitude initial condition in radians
200    @property ic/p-rad_sec (read/write) Roll rate initial condition in radians/second
201    @property ic/q-rad_sec (read/write) Pitch rate initial condition in radians/second
202    @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
203
204    @author Tony Peden
205    @version "$Id: FGInitialCondition.h,v 1.20 2010/02/15 03:22:57 jberndt Exp $"
206 */
207
208 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 CLASS DECLARATION
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
211
212 class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
213 {
214 public:
215   /// Constructor
216   FGInitialCondition(FGFDMExec *fdmex);
217   /// Destructor
218   ~FGInitialCondition();
219
220   /** Set calibrated airspeed initial condition in knots.
221       @param vc Calibrated airspeed in knots  */
222   void SetVcalibratedKtsIC(double vc);
223
224   /** Set equivalent airspeed initial condition in knots.
225       @param ve Equivalent airspeed in knots  */
226   void SetVequivalentKtsIC(double ve);
227
228   /** Set true airspeed initial condition in knots.
229       @param vt True airspeed in knots  */
230   inline void SetVtrueKtsIC(double vt)   { SetVtrueFpsIC(vt*ktstofps);   }
231
232   /** Set ground speed initial condition in knots.
233       @param vg Ground speed in knots  */
234   inline void SetVgroundKtsIC(double vg) { SetVgroundFpsIC(vg*ktstofps); }
235
236   /** Set mach initial condition.
237       @param mach Mach number  */
238   void SetMachIC(double mach);
239
240   /** Sets angle of attack initial condition in degrees.
241       @param a Alpha in degrees */
242   inline void SetAlphaDegIC(double a)      { SetAlphaRadIC(a*degtorad); }
243
244   /** Sets angle of sideslip initial condition in degrees.
245       @param B Beta in degrees */
246   inline void SetBetaDegIC(double B)       { SetBetaRadIC(B*degtorad);}
247
248   /** Sets pitch angle initial condition in degrees.
249       @param theta Theta (pitch) angle in degrees */
250   inline void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
251
252   /** Resets the IC data structure to new values
253       @param u, v, w, ... **/
254   void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
255                double alpha0, double beta0, double phi0, double theta0, double psi0,
256                double latitudeRad0, double longitudeRad0, double altitudeAGL0,
257                double gamma0);
258
259   /** Sets the roll angle initial condition in degrees.
260       @param phi roll angle in degrees */
261   inline void SetPhiDegIC(double phi)  { SetPhiRadIC(phi*degtorad);}
262
263   /** Sets the heading angle initial condition in degrees.
264       @param psi Heading angle in degrees */
265   inline void SetPsiDegIC(double psi){ SetPsiRadIC(psi*degtorad); }
266
267   /** Sets the climb rate initial condition in feet/minute.
268       @param roc Rate of Climb in feet/minute  */
269   void SetClimbRateFpmIC(double roc);
270
271   /** Sets the flight path angle initial condition in degrees.
272       @param gamma Flight path angle in degrees  */
273   inline void SetFlightPathAngleDegIC(double gamma) { SetFlightPathAngleRadIC(gamma*degtorad); }
274
275   /** Sets the altitude above sea level initial condition in feet.
276       @param altitudeASL Altitude above sea level in feet */
277   void SetAltitudeASLFtIC(double altitudeASL);
278
279   /** Sets the initial Altitude above ground level.
280       @param agl Altitude above ground level in feet */
281   void SetAltitudeAGLFtIC(double agl);
282
283   /** Sets the initial sea level radius from planet center
284       @param sl_rad sea level radius in feet */
285   void SetSeaLevelRadiusFtIC(double sl_rad);
286
287   /** Sets the initial terrain elevation.
288       @param elev Initial terrain elevation in feet */
289   void SetTerrainElevationFtIC(double elev);
290
291   /** Sets the initial latitude.
292       @param lat Initial latitude in degrees */
293   inline void SetLatitudeDegIC(double lat)  { latitude=lat*degtorad; }
294
295   /** Sets the initial longitude.
296       @param lon Initial longitude in degrees */
297   inline void SetLongitudeDegIC(double lon) { longitude=lon*degtorad; }
298
299   /** Gets the initial calibrated airspeed.
300       @return Initial calibrated airspeed in knots */
301   inline double GetVcalibratedKtsIC(void) const { return vc*fpstokts; }
302
303   /** Gets the initial equivalent airspeed.
304       @return Initial equivalent airspeed in knots */
305   inline double GetVequivalentKtsIC(void) const { return ve*fpstokts; }
306
307   /** Gets the initial ground speed.
308       @return Initial ground speed in knots */
309   inline double GetVgroundKtsIC(void) const { return vg*fpstokts; }
310
311   /** Gets the initial true velocity.
312       @return Initial true airspeed in knots. */
313   inline double GetVtrueKtsIC(void) const { return vt*fpstokts; }
314
315   /** Gets the initial mach.
316       @return Initial mach number */
317   inline double GetMachIC(void) const { return mach; }
318
319   /** Gets the initial climb rate.
320       @return Initial climb rate in feet/minute */
321   inline double GetClimbRateFpmIC(void) const { return hdot*60; }
322
323   /** Gets the initial flight path angle.
324       @return Initial flight path angle in degrees */
325   inline double GetFlightPathAngleDegIC(void)const  { return gamma*radtodeg; }
326
327   /** Gets the initial angle of attack.
328       @return Initial alpha in degrees */
329   inline double GetAlphaDegIC(void) const { return alpha*radtodeg; }
330
331   /** Gets the initial sideslip angle.
332       @return Initial beta in degrees */
333   inline double GetBetaDegIC(void) const  { return beta*radtodeg; }
334
335   /** Gets the initial pitch angle.
336       @return Initial pitch angle in degrees */
337   inline double GetThetaDegIC(void) const { return theta*radtodeg; }
338
339   /** Gets the initial roll angle.
340       @return Initial phi in degrees */
341   inline double GetPhiDegIC(void) const { return phi*radtodeg; }
342
343   /** Gets the initial heading angle.
344       @return Initial psi in degrees */
345   inline double GetPsiDegIC(void) const { return psi*radtodeg; }
346
347   /** Gets the initial latitude.
348       @return Initial geocentric latitude in degrees */
349   inline double GetLatitudeDegIC(void) const { return latitude*radtodeg; }
350
351   /** Gets the initial longitude.
352       @return Initial longitude in degrees */
353   inline double GetLongitudeDegIC(void) const { return longitude*radtodeg; }
354
355   /** Gets the initial altitude above sea level.
356       @return Initial altitude in feet. */
357   inline double GetAltitudeASLFtIC(void) const { return altitudeASL; }
358
359   /** Gets the initial altitude above ground level.
360       @return Initial altitude AGL in feet */
361   inline double GetAltitudeAGLFtIC(void) const { return altitudeASL - terrain_elevation; }
362
363   /** Gets the initial sea level radius.
364       @return Initial sea level radius */
365   inline double GetSeaLevelRadiusFtIC(void) const { return sea_level_radius; }
366
367   /** Gets the initial terrain elevation.
368       @return Initial terrain elevation in feet */
369   inline double GetTerrainElevationFtIC(void) const { return terrain_elevation; }
370
371   /** Sets the initial ground speed.
372       @param vg Initial ground speed in feet/second */
373   void SetVgroundFpsIC(double vg);
374
375   /** Sets the initial true airspeed.
376       @param vt Initial true airspeed in feet/second */
377   void SetVtrueFpsIC(double vt);
378
379   /** Sets the initial body axis X velocity.
380       @param ubody Initial X velocity in feet/second */
381   void SetUBodyFpsIC(double ubody);
382
383   /** Sets the initial body axis Y velocity.
384       @param vbody Initial Y velocity in feet/second */
385   void SetVBodyFpsIC(double vbody);
386
387   /** Sets the initial body axis Z velocity.
388       @param wbody Initial Z velocity in feet/second */
389   void SetWBodyFpsIC(double wbody);
390
391   /** Sets the initial local axis north velocity.
392       @param vn Initial north velocity in feet/second */
393   void SetVNorthFpsIC(double vn);
394
395   /** Sets the initial local axis east velocity.
396       @param ve Initial east velocity in feet/second */
397   void SetVEastFpsIC(double ve);
398
399   /** Sets the initial local axis down velocity.
400       @param vd Initial down velocity in feet/second */
401   void SetVDownFpsIC(double vd);
402
403   /** Sets the initial roll rate.
404       @param P Initial roll rate in radians/second */
405   void SetPRadpsIC(double P)  { p = P; }
406
407   /** Sets the initial pitch rate.
408       @param Q Initial pitch rate in radians/second */
409   void SetQRadpsIC(double Q) { q = Q; }
410
411   /** Sets the initial yaw rate.
412       @param R initial yaw rate in radians/second */
413   void SetRRadpsIC(double R) { r = R; }
414
415   /** Sets the initial wind velocity.
416       @param wN Initial wind velocity in local north direction, feet/second
417       @param wE Initial wind velocity in local east direction, feet/second
418       @param wD Initial wind velocity in local down direction, feet/second   */
419   void SetWindNEDFpsIC(double wN, double wE, double wD);
420
421   /** Sets the initial total wind speed.
422       @param mag Initial wind velocity magnitude in knots */
423   void SetWindMagKtsIC(double mag);
424
425   /** Sets the initial wind direction.
426       @param dir Initial direction wind is coming from in degrees */
427   void SetWindDirDegIC(double dir);
428
429   /** Sets the initial headwind velocity.
430       @param head Initial headwind speed in knots */
431   void SetHeadWindKtsIC(double head);
432
433   /** Sets the initial crosswind speed.
434       @param cross Initial crosswind speed, positive from left to right */
435   void SetCrossWindKtsIC(double cross);
436
437   /** Sets the initial wind downward speed.
438       @param wD Initial downward wind speed in knots*/
439   void SetWindDownKtsIC(double wD);
440
441   /** Sets the initial climb rate.
442       @param roc Initial Rate of climb in feet/second */
443   void SetClimbRateFpsIC(double roc);
444
445   /** Gets the initial ground velocity.
446       @return Initial ground velocity in feet/second */
447   inline double GetVgroundFpsIC(void) const  { return vg; }
448
449   /** Gets the initial true velocity.
450       @return Initial true velocity in feet/second */
451   inline double GetVtrueFpsIC(void) const { return vt; }
452
453   /** Gets the initial body axis X wind velocity.
454       @return Initial body axis X wind velocity in feet/second */
455   inline double GetWindUFpsIC(void) const { return uw; }
456
457   /** Gets the initial body axis Y wind velocity.
458       @return Initial body axis Y wind velocity in feet/second */
459   inline double GetWindVFpsIC(void) const { return vw; }
460
461   /** Gets the initial body axis Z wind velocity.
462       @return Initial body axis Z wind velocity in feet/second */
463   inline double GetWindWFpsIC(void) const { return ww; }
464
465   /** Gets the initial wind velocity in local frame.
466       @return Initial wind velocity toward north in feet/second */
467   inline double GetWindNFpsIC(void) const { return wnorth; }
468
469   /** Gets the initial wind velocity in local frame.
470       @return Initial wind velocity eastwards in feet/second */
471   inline double GetWindEFpsIC(void) const { return weast; }
472
473   /** Gets the initial wind velocity in local frame.
474       @return Initial wind velocity downwards in feet/second */
475   inline double GetWindDFpsIC(void) const { return wdown; }
476
477   /** Gets the initial total wind velocity in feet/sec.
478       @return Initial wind velocity in feet/second */
479   inline double GetWindFpsIC(void)  const { return sqrt(wnorth*wnorth + weast*weast); }
480
481   /** Gets the initial wind direction.
482       @return Initial wind direction in feet/second */
483   double GetWindDirDegIC(void) const;
484
485   /** Gets the initial climb rate.
486       @return Initial rate of climb in feet/second */
487   inline double GetClimbRateFpsIC(void) const { return hdot; }
488
489   /** Gets the initial body axis X velocity.
490       @return Initial body axis X velocity in feet/second. */
491   double GetUBodyFpsIC(void) const;
492
493   /** Gets the initial body axis Y velocity.
494       @return Initial body axis Y velocity in feet/second. */
495   double GetVBodyFpsIC(void) const;
496
497   /** Gets the initial body axis Z velocity.
498       @return Initial body axis Z velocity in feet/second. */
499   double GetWBodyFpsIC(void) const;
500
501   /** Gets the initial local frame X (North) velocity.
502       @return Initial local frame X (North) axis velocity in feet/second. */
503   double GetVNorthFpsIC(void) const {return vnorth;};
504
505   /** Gets the initial local frame Y (East) velocity.
506       @return Initial local frame Y (East) axis velocity in feet/second. */
507   double GetVEastFpsIC(void) const {return veast;};
508
509   /** Gets the initial local frame Z (Down) velocity.
510       @return Initial local frame Z (Down) axis velocity in feet/second. */
511   double GetVDownFpsIC(void) const {return vdown;};
512
513   /** Gets the initial body axis roll rate.
514       @return Initial body axis roll rate in radians/second */
515   double GetPRadpsIC() const { return p; }
516
517   /** Gets the initial body axis pitch rate.
518       @return Initial body axis pitch rate in radians/second */
519   double GetQRadpsIC() const { return q; }
520
521   /** Gets the initial body axis yaw rate.
522       @return Initial body axis yaw rate in radians/second */
523   double GetRRadpsIC() const { return r; }
524
525   /** Sets the initial flight path angle.
526       @param gamma Initial flight path angle in radians */
527   void SetFlightPathAngleRadIC(double gamma);
528
529   /** Sets the initial angle of attack.
530       @param alpha Initial angle of attack in radians */
531   void SetAlphaRadIC(double alpha);
532
533   /** Sets the initial pitch angle.
534       @param theta Initial pitch angle in radians */
535   void SetThetaRadIC(double theta);
536
537   /** Sets the initial sideslip angle.
538       @param beta Initial angle of sideslip in radians. */
539   void SetBetaRadIC(double beta);
540
541   /** Sets the initial roll angle.
542       @param phi Initial roll angle in radians */
543   void SetPhiRadIC(double phi);
544
545   /** Sets the initial heading angle.
546       @param psi Initial heading angle in radians */
547   void SetPsiRadIC(double psi);
548
549   /** Sets the initial latitude.
550       @param lat Initial latitude in radians */
551   inline void SetLatitudeRadIC(double lat) { latitude=lat; }
552
553   /** Sets the initial longitude.
554       @param lon Initial longitude in radians */
555   inline void SetLongitudeRadIC(double lon) { longitude=lon; }
556
557   /** Sets the target normal load factor.
558       @param nlf Normal load factor*/
559   inline void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
560
561   /** Gets the initial flight path angle.
562       @return Initial flight path angle in radians */
563   inline double GetFlightPathAngleRadIC(void) const { return gamma; }
564
565   /** Gets the initial angle of attack.
566       @return Initial alpha in radians */
567   inline double GetAlphaRadIC(void) const      { return alpha; }
568
569   /** Gets the initial angle of sideslip.
570       @return Initial sideslip angle in radians */
571   inline double GetBetaRadIC(void) const       { return beta; }
572
573   /** Gets the initial roll angle.
574       @return Initial roll angle in radians */
575   inline double GetPhiRadIC(void) const  { return phi; }
576
577   /** Gets the initial latitude.
578       @return Initial latitude in radians */
579   inline double GetLatitudeRadIC(void) const { return latitude; }
580
581   /** Gets the initial longitude.
582       @return Initial longitude in radians */
583   inline double GetLongitudeRadIC(void) const { return longitude; }
584
585   /** Gets the initial pitch angle.
586       @return Initial pitch angle in radians */
587   inline double GetThetaRadIC(void) const { return theta; }
588
589   /** Gets the initial heading angle.
590       @return Initial heading angle in radians */
591   inline double GetPsiRadIC(void) const   { return psi; }
592
593   /** Gets the initial speedset.
594       @return Initial speedset */
595   inline speedset GetSpeedSet(void) { return lastSpeedSet; }
596
597   /** Gets the initial windset.
598       @return Initial windset */
599   inline windset GetWindSet(void) { return lastWindSet; }
600
601   /** Gets the target normal load factor set from IC.
602       @return target normal load factor set from IC*/
603   inline double GetTargetNlfIC(void) { return targetNlfIC; }
604
605   /** Loads the initial conditions.
606       @param rstname The name of an initial conditions file
607       @param useStoredPath true if the stored path to the IC file should be used
608       @return true if successful */
609   bool Load(string rstname, bool useStoredPath = true );
610
611   /** Get init-file name
612   */
613   string GetInitFile(void) {return init_file_name;}
614   /** Set init-file name
615   */
616   void SetInitFile(string f) { init_file_name = f;}
617   void WriteStateFile(int num);
618
619 private:
620   double vt,vc,ve,vg;
621   double mach;
622   double altitudeASL,hdot;
623   double latitude,longitude;
624   double u,v,w;
625   double p,q,r;
626   double uw,vw,ww;
627   double vnorth,veast,vdown;
628   double wnorth,weast,wdown;
629   double whead, wcross, wdir, wmag;
630   double sea_level_radius;
631   double terrain_elevation;
632   double radius_to_vehicle;
633   double targetNlfIC;
634
635   double  alpha, beta, theta, phi, psi, gamma;
636   double salpha,sbeta,stheta,sphi,spsi,sgamma;
637   double calpha,cbeta,ctheta,cphi,cpsi,cgamma;
638
639   double xlo, xhi,xmin,xmax;
640
641   typedef double (FGInitialCondition::*fp)(double x);
642   fp sfunc;
643
644   speedset lastSpeedSet;
645   windset lastWindSet;
646
647   FGFDMExec *fdmex;
648   FGPropertyManager *PropertyManager;
649
650   bool Load_v1(void);
651   bool Load_v2(void);
652
653   bool Constructing;
654   bool getAlpha(void);
655   bool getTheta(void);
656   bool getMachFromVcas(double *Mach,double vcas);
657
658   double GammaEqOfTheta(double Theta);
659   void InitializeIC(void);
660   double GammaEqOfAlpha(double Alpha);
661   double calcVcas(double Mach);
662   void calcUVWfromNED(void);
663   void calcWindUVW(void);
664
665   bool findInterval(double x,double guess);
666   bool solve(double *y, double x);
667   void bind(void);
668   void Debug(int from);
669
670   string init_file_name;
671 };
672 }
673 #endif
674