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 Gethdot(void) const { return -vVel(eDown); }
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.
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; }
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(); }
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(); }
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(); }
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(); }
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(); }
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 *);
164 struct VehicleState VState;
166 FGColumnVector3 vVel;
167 FGColumnVector3 vPQRdot;
168 FGColumnVector3 vUVWdot;
170 double RunwayRadius, SeaLevelRadius;
172 void Debug(int from);
175 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%