1 /*******************************************************************************
6 Purpose: Integrates the rotational 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 rotational EOM.
33 --------------------------------------------------------------------------------
36 ********************************************************************************
37 COMMENTS, REFERENCES, and NOTES
38 ********************************************************************************
39 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
40 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
42 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
44 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
45 NASA-Ames", NASA CR-2497, January 1975
46 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
47 Wiley & Sons, 1979 ISBN 0-471-03032-5
48 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
49 1982 ISBN 0-471-08936-2
51 The order of rotations used in this class corresponds to a 3-2-1 sequence,
52 or Y-P-R, or Z-Y-X, if you prefer.
54 ********************************************************************************
56 *******************************************************************************/
58 #include "FGRotation.h"
59 #include "FGAtmosphere.h"
61 #include "FGFDMExec.h"
63 #include "FGAircraft.h"
64 #include "FGTranslation.h"
65 #include "FGPosition.h"
66 #include "FGAuxiliary.h"
70 /* get a definition for pi */
71 #include <Include/fg_constants.h>
75 /*******************************************************************************
76 ************************************ CODE **************************************
77 *******************************************************************************/
80 FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex),
89 /******************************************************************************/
91 FGRotation::~FGRotation(void)
95 /******************************************************************************/
97 bool FGRotation::Run(void)
100 static FGColumnVector vlastPQRdot(3);
102 if (!FGModel::Run()) {
105 L2 = vMoments(eL) + Ixz*vPQR(eP)*vPQR(eQ) - (Izz-Iyy)*vPQR(eR)*vPQR(eQ);
106 N1 = vMoments(eN) - (Iyy-Ixx)*vPQR(eP)*vPQR(eQ) - Ixz*vPQR(eR)*vPQR(eQ);
108 vPQRdot(eP) = (L2*Izz - N1*Ixz) / (Ixx*Izz - Ixz*Ixz);
109 vPQRdot(eQ) = (vMoments(eM) - (Ixx-Izz)*vPQR(eP)*vPQR(eR) - Ixz*(vPQR(eP)*vPQR(eP) - vPQR(eR)*vPQR(eR)))/Iyy;
110 vPQRdot(eR) = (N1*Ixx + L2*Ixz) / (Ixx*Izz - Ixz*Ixz);
112 vPQR += dt*rate*(vlastPQRdot + vPQRdot)/2.0;
114 State->IntegrateQuat(vPQR, rate);
115 State->CalcMatrices();
116 vEuler = State->CalcEuler();
118 vlastPQRdot = vPQRdot;
125 /******************************************************************************/
127 void FGRotation::GetState(void)
131 vMoments = Aircraft->GetMoments();
133 Ixx = Aircraft->GetIxx();
134 Iyy = Aircraft->GetIyy();
135 Izz = Aircraft->GetIzz();
136 Ixz = Aircraft->GetIxz();
139 /******************************************************************************/