]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGPropagate.h
Sync. w. JSB CVS as of 15/01/2007
[flightgear.git] / src / FDM / JSBSim / models / 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 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 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 <models/FGModel.h>
42 #include <math/FGColumnVector3.h>
43 #include <initialization/FGInitialCondition.h>
44 #include <math/FGLocation.h>
45 #include <math/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 GetCosEuler(int idx) const { return VState.vQtrn.GetCosEuler(idx); }
111   double GetSinEuler(int idx) const { return VState.vQtrn.GetSinEuler(idx); }
112   double Gethdot(void) const { return -vVel(eDown); }
113
114   /** Returns the "constant" RunwayRadius.
115       The RunwayRadius parameter is set by the calling application or set to
116       zero if JSBSim is running in standalone mode.
117       @return distance of the runway from the center of the earth.
118       @units feet */
119   double GetRunwayRadius(void) const;
120   double GetSeaLevelRadius(void) const { return SeaLevelRadius; }
121   double GetDistanceAGL(void)  const;
122   double GetRadius(void) const { return VState.vLocation.GetRadius(); }
123   double GetLongitude(void) const { return VState.vLocation.GetLongitude(); }
124   double GetLatitude(void) const { return VState.vLocation.GetLatitude(); }
125   const FGLocation& GetLocation(void) const { return VState.vLocation; }
126
127   /** Retrieves the local-to-body transformation matrix.
128       @return a reference to the local-to-body transformation matrix.  */
129   const FGMatrix33& GetTl2b(void) const { return VState.vQtrn.GetT(); }
130
131   /** Retrieves the body-to-local transformation matrix.
132       @return a reference to the body-to-local matrix.  */
133   const FGMatrix33& GetTb2l(void) const { return VState.vQtrn.GetTInv(); }
134
135 // SET functions
136
137   void SetLongitude(double lon) { VState.vLocation.SetLongitude(lon); }
138   void SetLatitude(double lat) { VState.vLocation.SetLatitude(lat); }
139   void SetRadius(double r) { VState.vLocation.SetRadius(r); }
140   void SetLocation(const FGLocation& l) { VState.vLocation = l; }
141   void Seth(double tt);
142   void SetSeaLevelRadius(double tt) { SeaLevelRadius = tt; }
143   void SetDistanceAGL(double tt);
144   void SetInitialState(const FGInitialCondition *);
145   void RecomputeRunwayRadius(void);
146
147   void bind(void);
148   void unbind(void);
149
150 private:
151
152 // state vector
153
154   struct VehicleState VState;
155
156   FGColumnVector3 vVel;
157   FGColumnVector3 vPQRdot, last_vPQRdot, last2_vPQRdot;
158   FGColumnVector3 vUVWdot, last_vUVWdot, last2_vUVWdot;
159   FGColumnVector3 vLocationDot, last_vLocationDot, last2_vLocationDot;
160   FGQuaternion vQtrndot, last_vQtrndot, last2_vQtrndot;
161   
162   double RunwayRadius, SeaLevelRadius;
163
164   void Debug(int from);
165 };
166 }
167 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 #endif