1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #include "FGColumnVector3.h"
43 #include "FGInitialCondition.h"
44 #include "FGLocation.h"
45 #include "FGQuaternion.h"
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 #define ID_PROPAGATE "$Id$"
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63 /** Models the EOM and integration/propagation of state
64 @author Jon S. Berndt, Mathias Froehlich
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81 class FGPropagate : public FGModel {
84 @param Executive a pointer to the parent executive object */
85 FGPropagate(FGFDMExec* Executive);
92 /** Runs the Propagate model; called by the Executive
93 @return false if no error */
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(); }
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); }
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.
119 double GetRunwayRadius(void) const { return RunwayRadius; }
120 double GetSeaLevelRadius(void) const { return SeaLevelRadius; }
121 double GetDistanceAGL(void) const { return VState.vLocation.GetRadius()-RunwayRadius; }
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; }
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(); }
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(); }
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 SetRunwayRadius(double tt) { RunwayRadius = tt; }
143 void SetSeaLevelRadius(double tt) { SeaLevelRadius = tt; }
144 void SetDistanceAGL(double tt);
145 void SetInitialState(const FGInitialCondition *);
154 struct VehicleState VState;
156 FGColumnVector3 vVel;
157 FGColumnVector3 vPQRdot;
158 FGColumnVector3 vUVWdot;
160 double RunwayRadius, SeaLevelRadius;
162 void Debug(int from);
165 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%