]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/initialization/FGInitialCondition.h
Merge branch 'maint' into next
[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$"
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->SetAltitudeFtIC();
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    - altitude (altitude, ft)
144    - winddir (wind from-angle, degrees)
145    - vwind (magnitude wind speed, ft/sec)
146    - hwind (headwind speed, knots)
147    - xwind (crosswind speed, knots)
148    - vc (calibrated airspeed, ft/sec)
149    - mach (mach)
150    - vground (ground speed, ft/sec)
151    - running (0 or 1)
152
153    <h3>Properties</h3>
154    @property ic/vc-kts (read/write) Calibrated airspeed initial condition in knots
155    @property ic/ve-kts (read/write) Knots equivalent airspeed initial condition
156    @property ic/vg-kts (read/write) Ground speed initial condition in knots
157    @property ic/vt-kts (read/write) True airspeed initial condition in knots
158    @property ic/mach (read/write) Mach initial condition
159    @property ic/roc-fpm (read/write) Rate of climb initial condition in feet/minute
160    @property ic/gamma-deg (read/write) Flightpath angle initial condition in degrees
161    @property ic/alpha-deg (read/write) Angle of attack initial condition in degrees
162    @property ic/beta-deg (read/write) Angle of sideslip initial condition in degrees
163    @property ic/theta-deg (read/write) Pitch angle initial condition in degrees
164    @property ic/phi-deg (read/write) Roll angle initial condition in degrees
165    @property ic/psi-true-deg (read/write) Heading angle initial condition in degrees
166    @property ic/lat-gc-deg (read/write) Latitude initial condition in degrees
167    @property ic/long-gc-deg (read/write) Longitude initial condition in degrees
168    @property ic/h-sl-ft (read/write) Height above sea level initial condition in feet
169    @property ic/h-agl-ft (read/write) Height above ground level initial condition in feet
170    @property ic/sea-level-radius-ft (read/write) Radius of planet at sea level in feet
171    @property ic/terrain-altitude-ft (read/write) Terrain elevation above sea level in feet
172    @property ic/vg-fps (read/write) Ground speed initial condition in feet/second
173    @property ic/vt-fps (read/write) True airspeed initial condition in feet/second
174    @property ic/vw-bx-fps (read/write) Wind velocity initial condition in Body X frame in feet/second
175    @property ic/vw-by-fps (read/write) Wind velocity initial condition in Body Y frame in feet/second
176    @property ic/vw-bz-fps (read/write) Wind velocity initial condition in Body Z frame in feet/second
177    @property ic/vw-north-fps (read/write) Wind northward velocity initial condition in feet/second
178    @property ic/vw-east-fps (read/write) Wind eastward velocity initial condition in feet/second
179    @property ic/vw-down-fps (read/write) Wind downward velocity initial condition in feet/second
180    @property ic/vw-mag-fps (read/write) Wind velocity magnitude initial condition in feet/sec.
181    @property ic/vw-dir-deg (read/write) Wind direction initial condition, in degrees from north
182    @property ic/roc-fps (read/write) Rate of climb initial condition, in feet/second
183    @property ic/u-fps (read/write) Body frame x-axis velocity initial condition in feet/second
184    @property ic/v-fps (read/write) Body frame y-axis velocity initial condition in feet/second
185    @property ic/w-fps (read/write) Body frame z-axis velocity initial condition in feet/second
186    @property ic/vn-fps (read/write) Local frame x-axis (north) velocity initial condition in feet/second
187    @property ic/ve-fps (read/write) Local frame y-axis (east) velocity initial condition in feet/second
188    @property ic/vd-fps (read/write) Local frame z-axis (down) velocity initial condition in feet/second
189    @property ic/gamma-rad (read/write) Flight path angle initial condition in radians
190    @property ic/alpha-rad (read/write) Angle of attack initial condition in radians
191    @property ic/theta-rad (read/write) Pitch angle initial condition in radians
192    @property ic/beta-rad (read/write) Angle of sideslip initial condition in radians
193    @property ic/phi-rad (read/write) Roll angle initial condition in radians
194    @property ic/psi-true-rad (read/write) Heading angle initial condition in radians
195    @property ic/lat-gc-rad (read/write) Geocentric latitude initial condition in radians
196    @property ic/long-gc-rad (read/write) Longitude initial condition in radians
197    @property ic/p-rad_sec (read/write) Roll rate initial condition in radians/second
198    @property ic/q-rad_sec (read/write) Pitch rate initial condition in radians/second
199    @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
200
201    @author Tony Peden
202    @version "$Id$"
203 */
204
205 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 CLASS DECLARATION
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
208
209 class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
210 {
211 public:
212   /// Constructor
213   FGInitialCondition(FGFDMExec *fdmex);
214   /// Destructor
215   ~FGInitialCondition();
216
217   /** Set calibrated airspeed initial condition in knots.
218       @param vc Calibrated airspeed in knots  */
219   void SetVcalibratedKtsIC(double vc);
220
221   /** Set equivalent airspeed initial condition in knots.
222       @param ve Equivalent airspeed in knots  */
223   void SetVequivalentKtsIC(double ve);
224
225   /** Set true airspeed initial condition in knots.
226       @param vt True airspeed in knots  */
227   inline void SetVtrueKtsIC(double vt)   { SetVtrueFpsIC(vt*ktstofps);   }
228
229   /** Set ground speed initial condition in knots.
230       @param vg Ground speed in knots  */
231   inline void SetVgroundKtsIC(double vg) { SetVgroundFpsIC(vg*ktstofps); }
232
233   /** Set mach initial condition.
234       @param mach Mach number  */
235   void SetMachIC(double mach);
236
237   /** Sets angle of attack initial condition in degrees.
238       @param a Alpha in degrees */
239   inline void SetAlphaDegIC(double a)      { SetAlphaRadIC(a*degtorad); }
240
241   /** Sets angle of sideslip initial condition in degrees.
242       @param B Beta in degrees */
243   inline void SetBetaDegIC(double B)       { SetBetaRadIC(B*degtorad);}
244
245   /** Sets pitch angle initial condition in degrees.
246       @param theta Theta (pitch) angle in degrees */
247   inline void SetThetaDegIC(double theta) { SetThetaRadIC(theta*degtorad); }
248
249   /** Resets the IC data structure to new values
250       @param u, v, w, ... **/
251   void ResetIC(double u0, double v0, double w0, double p0, double q0, double r0,
252                double alpha0, double beta0, double phi0, double theta0, double psi0,
253                double latitudeRad0, double longitudeRad0, double altitudeAGL0,
254                double gamma0);
255
256   /** Sets the roll angle initial condition in degrees.
257       @param phi roll angle in degrees */
258   inline void SetPhiDegIC(double phi)  { SetPhiRadIC(phi*degtorad);}
259
260   /** Sets the heading angle initial condition in degrees.
261       @param psi Heading angle in degrees */
262   inline void SetPsiDegIC(double psi){ SetPsiRadIC(psi*degtorad); }
263
264   /** Sets the climb rate initial condition in feet/minute.
265       @param roc Rate of Climb in feet/minute  */
266   void SetClimbRateFpmIC(double roc);
267
268   /** Sets the flight path angle initial condition in degrees.
269       @param gamma Flight path angle in degrees  */
270   inline void SetFlightPathAngleDegIC(double gamma) { SetFlightPathAngleRadIC(gamma*degtorad); }
271
272   /** Sets the altitude initial condition in feet.
273       @param alt Altitude in feet */
274   void SetAltitudeFtIC(double alt);
275
276   /** Sets the initial Altitude above ground level.
277       @param agl Altitude above ground level in feet */
278   void SetAltitudeAGLFtIC(double agl);
279
280   /** Sets the initial sea level radius from planet center
281       @param sl_rad sea level radius in feet */
282   void SetSeaLevelRadiusFtIC(double sl_rad);
283
284   /** Sets the initial terrain elevation.
285       @param elev Initial terrain elevation in feet */
286   void SetTerrainAltitudeFtIC(double elev);
287
288   /** Sets the initial latitude.
289       @param lat Initial latitude in degrees */
290   inline void SetLatitudeDegIC(double lat)  { latitude=lat*degtorad; }
291
292   /** Sets the initial longitude.
293       @param lon Initial longitude in degrees */
294   inline void SetLongitudeDegIC(double lon) { longitude=lon*degtorad; }
295
296   /** Gets the initial calibrated airspeed.
297       @return Initial calibrated airspeed in knots */
298   inline double GetVcalibratedKtsIC(void) const { return vc*fpstokts; }
299
300   /** Gets the initial equivalent airspeed.
301       @return Initial equivalent airspeed in knots */
302   inline double GetVequivalentKtsIC(void) const { return ve*fpstokts; }
303
304   /** Gets the initial ground speed.
305       @return Initial ground speed in knots */
306   inline double GetVgroundKtsIC(void) const { return vg*fpstokts; }
307
308   /** Gets the initial true velocity.
309       @return Initial true airspeed in knots. */
310   inline double GetVtrueKtsIC(void) const { return vt*fpstokts; }
311
312   /** Gets the initial mach.
313       @return Initial mach number */
314   inline double GetMachIC(void) const { return mach; }
315
316   /** Gets the initial climb rate.
317       @return Initial climb rate in feet/minute */
318   inline double GetClimbRateFpmIC(void) const { return hdot*60; }
319
320   /** Gets the initial flight path angle.
321       @return Initial flight path angle in degrees */
322   inline double GetFlightPathAngleDegIC(void)const  { return gamma*radtodeg; }
323
324   /** Gets the initial angle of attack.
325       @return Initial alpha in degrees */
326   inline double GetAlphaDegIC(void) const { return alpha*radtodeg; }
327
328   /** Gets the initial sideslip angle.
329       @return Initial beta in degrees */
330   inline double GetBetaDegIC(void) const  { return beta*radtodeg; }
331
332   /** Gets the initial pitch angle.
333       @return Initial pitch angle in degrees */
334   inline double GetThetaDegIC(void) const { return theta*radtodeg; }
335
336   /** Gets the initial roll angle.
337       @return Initial phi in degrees */
338   inline double GetPhiDegIC(void) const { return phi*radtodeg; }
339
340   /** Gets the initial heading angle.
341       @return Initial psi in degrees */
342   inline double GetPsiDegIC(void) const { return psi*radtodeg; }
343
344   /** Gets the initial latitude.
345       @return Initial geocentric latitude in degrees */
346   inline double GetLatitudeDegIC(void) const { return latitude*radtodeg; }
347
348   /** Gets the initial longitude.
349       @return Initial longitude in degrees */
350   inline double GetLongitudeDegIC(void) const { return longitude*radtodeg; }
351
352   /** Gets the initial altitude.
353       @return Initial altitude in feet. */
354   inline double GetAltitudeFtIC(void) const { return altitude; }
355
356   /** Gets the initial altitude above ground level.
357       @return Initial altitude AGL in feet */
358   inline double GetAltitudeAGLFtIC(void) const { return altitude - terrain_altitude; }
359
360   /** Gets the initial sea level radius.
361       @return Initial sea level radius */
362   inline double GetSeaLevelRadiusFtIC(void) const { return sea_level_radius; }
363
364   /** Gets the initial terrain elevation.
365       @return Initial terrain elevation in feet */
366   inline double GetTerrainAltitudeFtIC(void) const { return terrain_altitude; }
367
368   /** Sets the initial ground speed.
369       @param vg Initial ground speed in feet/second */
370   void SetVgroundFpsIC(double vg);
371
372   /** Sets the initial true airspeed.
373       @param vt Initial true airspeed in feet/second */
374   void SetVtrueFpsIC(double vt);
375
376   /** Sets the initial body axis X velocity.
377       @param ubody Initial X velocity in feet/second */
378   void SetUBodyFpsIC(double ubody);
379
380   /** Sets the initial body axis Y velocity.
381       @param vbody Initial Y velocity in feet/second */
382   void SetVBodyFpsIC(double vbody);
383
384   /** Sets the initial body axis Z velocity.
385       @param wbody Initial Z velocity in feet/second */
386   void SetWBodyFpsIC(double wbody);
387
388   /** Sets the initial local axis north velocity.
389       @param vn Initial north velocity in feet/second */
390   void SetVNorthFpsIC(double vn);
391
392   /** Sets the initial local axis east velocity.
393       @param ve Initial east velocity in feet/second */
394   void SetVEastFpsIC(double ve);
395
396   /** Sets the initial local axis down velocity.
397       @param vd Initial down velocity in feet/second */
398   void SetVDownFpsIC(double vd);
399
400   /** Sets the initial roll rate.
401       @param P Initial roll rate in radians/second */
402   void SetPRadpsIC(double P)  { p = P; }
403
404   /** Sets the initial pitch rate.
405       @param Q Initial pitch rate in radians/second */
406   void SetQRadpsIC(double Q) { q = Q; }
407
408   /** Sets the initial yaw rate.
409       @param R initial yaw rate in radians/second */
410   void SetRRadpsIC(double R) { r = R; }
411
412   /** Sets the initial wind velocity.
413       @param wN Initial wind velocity in local north direction, feet/second
414       @param wE Initial wind velocity in local east direction, feet/second
415       @param wD Initial wind velocity in local down direction, feet/second   */
416   void SetWindNEDFpsIC(double wN, double wE, double wD);
417
418   /** Sets the initial total wind speed.
419       @param mag Initial wind velocity magnitude in knots */
420   void SetWindMagKtsIC(double mag);
421
422   /** Sets the initial wind direction.
423       @param dir Initial direction wind is coming from in degrees */
424   void SetWindDirDegIC(double dir);
425
426   /** Sets the initial headwind velocity.
427       @param head Initial headwind speed in knots */
428   void SetHeadWindKtsIC(double head);
429
430   /** Sets the initial crosswind speed.
431       @param cross Initial crosswind speed, positive from left to right */
432   void SetCrossWindKtsIC(double cross);
433
434   /** Sets the initial wind downward speed.
435       @param wD Initial downward wind speed in knots*/
436   void SetWindDownKtsIC(double wD);
437
438   /** Sets the initial climb rate.
439       @param roc Initial Rate of climb in feet/second */
440   void SetClimbRateFpsIC(double roc);
441
442   /** Gets the initial ground velocity.
443       @return Initial ground velocity in feet/second */
444   inline double GetVgroundFpsIC(void) const  { return vg; }
445
446   /** Gets the initial true velocity.
447       @return Initial true velocity in feet/second */
448   inline double GetVtrueFpsIC(void) const { return vt; }
449
450   /** Gets the initial body axis X wind velocity.
451       @return Initial body axis X wind velocity in feet/second */
452   inline double GetWindUFpsIC(void) const { return uw; }
453
454   /** Gets the initial body axis Y wind velocity.
455       @return Initial body axis Y wind velocity in feet/second */
456   inline double GetWindVFpsIC(void) const { return vw; }
457
458   /** Gets the initial body axis Z wind velocity.
459       @return Initial body axis Z wind velocity in feet/second */
460   inline double GetWindWFpsIC(void) const { return ww; }
461
462   /** Gets the initial wind velocity in local frame.
463       @return Initial wind velocity toward north in feet/second */
464   inline double GetWindNFpsIC(void) const { return wnorth; }
465
466   /** Gets the initial wind velocity in local frame.
467       @return Initial wind velocity eastwards in feet/second */
468   inline double GetWindEFpsIC(void) const { return weast; }
469
470   /** Gets the initial wind velocity in local frame.
471       @return Initial wind velocity downwards in feet/second */
472   inline double GetWindDFpsIC(void) const { return wdown; }
473
474   /** Gets the initial total wind velocity in feet/sec.
475       @return Initial wind velocity in feet/second */
476   inline double GetWindFpsIC(void)  const { return sqrt(wnorth*wnorth + weast*weast); }
477
478   /** Gets the initial wind direction.
479       @return Initial wind direction in feet/second */
480   double GetWindDirDegIC(void) const;
481
482   /** Gets the initial climb rate.
483       @return Initial rate of climb in feet/second */
484   inline double GetClimbRateFpsIC(void) const { return hdot; }
485
486   /** Gets the initial body axis X velocity.
487       @return Initial body axis X velocity in feet/second. */
488   double GetUBodyFpsIC(void) const;
489
490   /** Gets the initial body axis Y velocity.
491       @return Initial body axis Y velocity in feet/second. */
492   double GetVBodyFpsIC(void) const;
493
494   /** Gets the initial body axis Z velocity.
495       @return Initial body axis Z velocity in feet/second. */
496   double GetWBodyFpsIC(void) const;
497
498   /** Gets the initial local frame X (North) velocity.
499       @return Initial local frame X (North) axis velocity in feet/second. */
500   double GetVNorthFpsIC(void) const {return vnorth;};
501
502   /** Gets the initial local frame Y (East) velocity.
503       @return Initial local frame Y (East) axis velocity in feet/second. */
504   double GetVEastFpsIC(void) const {return veast;};
505
506   /** Gets the initial local frame Z (Down) velocity.
507       @return Initial local frame Z (Down) axis velocity in feet/second. */
508   double GetVDownFpsIC(void) const {return vdown;};
509
510   /** Gets the initial body axis roll rate.
511       @return Initial body axis roll rate in radians/second */
512   double GetPRadpsIC() const { return p; }
513
514   /** Gets the initial body axis pitch rate.
515       @return Initial body axis pitch rate in radians/second */
516   double GetQRadpsIC() const { return q; }
517
518   /** Gets the initial body axis yaw rate.
519       @return Initial body axis yaw rate in radians/second */
520   double GetRRadpsIC() const { return r; }
521
522   /** Sets the initial flight path angle.
523       @param gamma Initial flight path angle in radians */
524   void SetFlightPathAngleRadIC(double gamma);
525
526   /** Sets the initial angle of attack.
527       @param alpha Initial angle of attack in radians */
528   void SetAlphaRadIC(double alpha);
529
530   /** Sets the initial pitch angle.
531       @param theta Initial pitch angle in radians */
532   void SetThetaRadIC(double theta);
533
534   /** Sets the initial sideslip angle.
535       @param beta Initial angle of sideslip in radians. */
536   void SetBetaRadIC(double beta);
537
538   /** Sets the initial roll angle.
539       @param phi Initial roll angle in radians */
540   void SetPhiRadIC(double phi);
541
542   /** Sets the initial heading angle.
543       @param psi Initial heading angle in radians */
544   void SetPsiRadIC(double psi);
545
546   /** Sets the initial latitude.
547       @param lat Initial latitude in radians */
548   inline void SetLatitudeRadIC(double lat) { latitude=lat; }
549
550   /** Sets the initial longitude.
551       @param lon Initial longitude in radians */
552   inline void SetLongitudeRadIC(double lon) { longitude=lon; }
553
554   /** Sets the target normal load factor.
555       @param nlf Normal load factor*/
556   inline void SetTargetNlfIC(double nlf) { targetNlfIC=nlf; }
557
558   /** Gets the initial flight path angle.
559       @return Initial flight path angle in radians */
560   inline double GetFlightPathAngleRadIC(void) const { return gamma; }
561
562   /** Gets the initial angle of attack.
563       @return Initial alpha in radians */
564   inline double GetAlphaRadIC(void) const      { return alpha; }
565
566   /** Gets the initial angle of sideslip.
567       @return Initial sideslip angle in radians */
568   inline double GetBetaRadIC(void) const       { return beta; }
569
570   /** Gets the initial roll angle.
571       @return Initial roll angle in radians */
572   inline double GetPhiRadIC(void) const  { return phi; }
573
574   /** Gets the initial latitude.
575       @return Initial latitude in radians */
576   inline double GetLatitudeRadIC(void) const { return latitude; }
577
578   /** Gets the initial longitude.
579       @return Initial longitude in radians */
580   inline double GetLongitudeRadIC(void) const { return longitude; }
581
582   /** Gets the initial pitch angle.
583       @return Initial pitch angle in radians */
584   inline double GetThetaRadIC(void) const { return theta; }
585
586   /** Gets the initial heading angle.
587       @return Initial heading angle in radians */
588   inline double GetPsiRadIC(void) const   { return psi; }
589
590   /** Gets the initial speedset.
591       @return Initial speedset */
592   inline speedset GetSpeedSet(void) { return lastSpeedSet; }
593
594   /** Gets the initial windset.
595       @return Initial windset */
596   inline windset GetWindSet(void) { return lastWindSet; }
597
598   /** Gets the target normal load factor set from IC.
599       @return target normal load factor set from IC*/
600   inline double GetTargetNlfIC(void) { return targetNlfIC; }
601
602   /** Loads the initial conditions.
603       @param rstname The name of an initial conditions file
604       @param useStoredPath true if the stored path to the IC file should be used
605       @return true if successful */
606   bool Load(string rstname, bool useStoredPath = true );
607
608   /** Get init-file name
609   */
610   string GetInitFile(void) {return init_file_name;}
611   /** Set init-file name
612   */
613   void SetInitFile(string f) { init_file_name = f;}
614   void WriteStateFile(int num);
615
616 private:
617   double vt,vc,ve,vg;
618   double mach;
619   double altitude,hdot;
620   double latitude,longitude;
621   double u,v,w;
622   double p,q,r;
623   double uw,vw,ww;
624   double vnorth,veast,vdown;
625   double wnorth,weast,wdown;
626   double whead, wcross, wdir, wmag;
627   double sea_level_radius;
628   double terrain_altitude;
629   double radius_to_vehicle;
630   double targetNlfIC;
631
632   double  alpha, beta, theta, phi, psi, gamma;
633   double salpha,sbeta,stheta,sphi,spsi,sgamma;
634   double calpha,cbeta,ctheta,cphi,cpsi,cgamma;
635
636   double xlo, xhi,xmin,xmax;
637
638   typedef double (FGInitialCondition::*fp)(double x);
639   fp sfunc;
640
641   speedset lastSpeedSet;
642   windset lastWindSet;
643
644   FGFDMExec *fdmex;
645   FGPropertyManager *PropertyManager;
646
647   bool Constructing;
648   bool getAlpha(void);
649   bool getTheta(void);
650   bool getMachFromVcas(double *Mach,double vcas);
651
652   double GammaEqOfTheta(double Theta);
653   void InitializeIC(void);
654   double GammaEqOfAlpha(double Alpha);
655   double calcVcas(double Mach);
656   void calcUVWfromNED(void);
657   void calcWindUVW(void);
658
659   bool findInterval(double x,double guess);
660   bool solve(double *y, double x);
661   void bind(void);
662   void Debug(int from);
663
664   string init_file_name;
665 };
666 }
667 #endif
668