1 /*******************************************************************************
3 Module: FGTranslation.cpp
6 Purpose: Integrates the translational EOM
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class integrates the translational EOM.
33 --------------------------------------------------------------------------------
37 --------------------------------------------------------------------------------
40 ********************************************************************************
41 COMMENTS, REFERENCES, and NOTES
42 ********************************************************************************
43 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
44 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
46 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
48 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
49 NASA-Ames", NASA CR-2497, January 1975
50 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
51 Wiley & Sons, 1979 ISBN 0-471-03032-5
52 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
53 1982 ISBN 0-471-08936-2
55 The order of rotations used in this class corresponds to a 3-2-1 sequence,
56 or Y-P-R, or Z-Y-X, if you prefer.
58 ********************************************************************************
60 *******************************************************************************/
62 #include "FGTranslation.h"
64 /*******************************************************************************
65 ************************************ CODE **************************************
66 *******************************************************************************/
69 FGTranslation::FGTranslation(void) : FGModel()
71 strcpy(Name, "FGTranslation");
75 FGTranslation::~FGTranslation(void)
80 bool FGTranslation::Run(void)
82 if (!FGModel::Run()) {
90 Udot = V*R - W*Q + Fx/m;
91 Vdot = W*P - U*R + Fy/m;
92 Wdot = U*Q - V*P + Fz/m;
94 U += 0.5*dt*(lastUdot + Udot);
95 V += 0.5*dt*(lastVdot + Vdot);
96 W += 0.5*dt*(lastWdot + Wdot);
98 Vt = U*U+V*V+W*W > 0.0 ? sqrt(U*U + V*V + W*W) : 0.0;
101 alpha = U*U > 0.0 ? atan2(W, U) : 0.0;
103 beta = U*U+W*W > 0.0 ? atan2(V, (fabs(U)/U)*sqrt(U*U + W*W)) : 0.0;
105 qbar = 0.5*rho*Vt*Vt;
114 void FGTranslation::GetState(void)
128 rho = State->Getrho();
130 phi = State->Getphi();
131 tht = State->Gettht();
132 psi = State->Getpsi();
138 Udot = State->GetUdot();
139 Vdot = State->GetVdot();
140 Wdot = State->GetWdot();
142 alpha = State->Getalpha();
143 beta = State->Getbeta();
147 void FGTranslation::PutState(void)
154 State->Setqbar(qbar);
156 State->SetUdot(Udot);
157 State->SetVdot(Vdot);
158 State->SetWdot(Wdot);
160 State->Setalpha(alpha);
161 State->Setbeta(beta);