]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropagate.h
Frederic Bouvier:
[flightgear.git] / src / FDM / JSBSim / FGPropagate.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGPropagate.h
4  Author:       Jon S. Berndt
5  Date started: 1/5/99
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU 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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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 General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 01/05/99   JSB   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGPROPAGATE_H
35 #define FGPROPAGATE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGModel.h"
42 #include "FGColumnVector3.h"
43 #include "FGInitialCondition.h"
44 #include "FGLocation.h"
45 #include "FGQuaternion.h"
46
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51 #define ID_PROPAGATE "$Id$"
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 namespace JSBSim {
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 CLASS DOCUMENTATION
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /** Models the EOM and integration/propagation of state
64     @author Jon S. Berndt, Mathias Froehlich
65     @version $Id$
66   */
67
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS DECLARATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 // state vector
73
74 struct VehicleState {
75   FGLocation vLocation;
76   FGColumnVector3 vUVW;
77   FGColumnVector3 vPQR;
78   FGQuaternion vQtrn;
79 };
80
81 class FGPropagate : public FGModel {
82 public:
83   /** Constructor
84       @param Executive a pointer to the parent executive object */
85   FGPropagate(FGFDMExec* Executive);
86
87   /// Destructor
88   ~FGPropagate();
89
90   bool InitModel(void);
91
92   /** Runs the Propagate model; called by the Executive
93       @return false if no error */
94   bool Run(void);
95
96   const FGColumnVector3& GetVel(void) const { return vVel; }
97   const FGColumnVector3& GetUVW(void) const { return VState.vUVW; }
98   const FGColumnVector3& GetUVWdot(void) const { return vUVWdot; }
99   const FGColumnVector3& GetPQR(void) const {return VState.vPQR;}
100   const FGColumnVector3& GetPQRdot(void) const {return vPQRdot;}
101   const FGColumnVector3& GetEuler(void) const { return VState.vQtrn.GetEuler(); }
102
103   double GetUVW   (int idx) const { return VState.vUVW(idx); }
104   double GetUVWdot(int idx) const { return vUVWdot(idx); }
105   double GetVel(int idx) const { return vVel(idx); }
106   double Geth(void)   const { return VState.vLocation.GetRadius() - SeaLevelRadius; }
107   double GetPQR(int axis) const {return VState.vPQR(axis);}
108   double GetPQRdot(int idx) const {return vPQRdot(idx);}
109   double GetEuler(int axis) const { return VState.vQtrn.GetEuler()(axis); }
110   double Gethdot(void) const { return -vVel(eDown); }
111
112   /** Returns the "constant" RunwayRadius.
113       The RunwayRadius parameter is set by the calling application or set to
114       zero if JSBSim is running in standalone mode.
115       @return distance of the runway from the center of the earth.
116       @units feet */
117   double GetRunwayRadius(void) const { return RunwayRadius; }
118   double GetSeaLevelRadius(void) const { return SeaLevelRadius; }
119   double GetDistanceAGL(void)  const { return VState.vLocation.GetRadius()-RunwayRadius; }
120   double GetRadius(void) const { return VState.vLocation.GetRadius(); }
121   double GetLongitude(void) const { return VState.vLocation.GetLongitude(); }
122   double GetLatitude(void) const { return VState.vLocation.GetLatitude(); }
123   const FGLocation& GetLocation(void) const { return VState.vLocation; }
124
125   double Getphi(void) const { return VState.vQtrn.GetEulerPhi(); }
126   double Gettht(void) const { return VState.vQtrn.GetEulerTheta(); }
127   double Getpsi(void) const { return VState.vQtrn.GetEulerPsi(); }
128
129   double GetCosphi(void) const { return VState.vQtrn.GetCosEulerPhi(); }
130   double GetCostht(void) const { return VState.vQtrn.GetCosEulerTheta(); }
131   double GetCospsi(void) const { return VState.vQtrn.GetCosEulerPsi(); }
132
133   double GetSinphi(void) const { return VState.vQtrn.GetSinEulerPhi(); }
134   double GetSintht(void) const { return VState.vQtrn.GetSinEulerTheta(); }
135   double GetSinpsi(void) const { return VState.vQtrn.GetSinEulerPsi(); }
136
137   /** Retrieves the local-to-body transformation matrix.
138       @return a reference to the local-to-body transformation matrix.  */
139   const FGMatrix33& GetTl2b(void) const { return VState.vQtrn.GetT(); }
140
141   /** Retrieves the body-to-local transformation matrix.
142       @return a reference to the body-to-local matrix.  */
143   const FGMatrix33& GetTb2l(void) const { return VState.vQtrn.GetTInv(); }
144
145 // SET functions
146
147   void SetLongitude(double lon) { VState.vLocation.SetLongitude(lon); }
148   void SetLatitude(double lat) { VState.vLocation.SetLatitude(lat); }
149   void SetRadius(double r) { VState.vLocation.SetRadius(r); }
150   void SetLocation(const FGLocation& l) { VState.vLocation = l; }
151   void Seth(double tt);
152   void SetRunwayRadius(double tt) { RunwayRadius = tt; }
153   void SetSeaLevelRadius(double tt) { SeaLevelRadius = tt; }
154   void SetDistanceAGL(double tt);
155   void SetInitialState(const FGInitialCondition *);
156
157   void bind(void);
158   void unbind(void);
159
160 private:
161
162 // state vector
163
164   struct VehicleState VState;
165
166   FGColumnVector3 vVel;
167   FGColumnVector3 vPQRdot;
168   FGColumnVector3 vUVWdot;
169
170   double RunwayRadius, SeaLevelRadius;
171
172   void Debug(int from);
173 };
174 }
175 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 #endif