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 <simgear/compiler.h>
45 # if defined (sgi) && !defined(__GNUC__)
53 #include "FGColumnVector3.h"
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 #define ID_ROTATION "$Id$"
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 /** Models the rotational portion of the Equations of Motion.
72 Note: The order of rotations used in this class corresponds to a 3-2-1 sequence,
73 or Y-P-R, or Z-Y-X, if you prefer.
74 @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
75 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
77 @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
79 @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
80 NASA-Ames", NASA CR-2497, January 1975
81 @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
82 Wiley & Sons, 1979 ISBN 0-471-03032-5
83 @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
84 1982 ISBN 0-471-08936-2
87 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91 class FGRotation : public FGModel
94 FGRotation(FGFDMExec*);
99 inline FGColumnVector3& GetPQR(void) {return vPQR;}
100 inline double GetPQR(int axis) const {return vPQR(axis);}
101 inline FGColumnVector3& GetAeroPQR(void) {return vAeroPQR;}
102 inline double GetAeroPQR(int axis) const {return vAeroPQR(axis);}
103 inline FGColumnVector3& GetPQRdot(void) {return vPQRdot;}
104 inline double GetPQRdot(int idx) const {return vPQRdot(idx);}
105 inline FGColumnVector3& GetEuler(void) {return vEuler;}
106 inline double GetEuler(int axis) const {return vEuler(axis);}
107 inline FGColumnVector3& GetEulerRates(void) { return vEulerRates; }
108 inline double GetEulerRates(int axis) const { return vEulerRates(axis); }
109 inline void SetPQR(FGColumnVector3 tt) {vPQR = tt;}
110 inline void SetPQR(double p, double q, double r) {vPQR(eP)=p;
113 inline void SetAeroPQR(FGColumnVector3 tt) {vAeroPQR = tt;}
114 inline void SetAeroPQR(double p, double q, double r) {vAeroPQR(eP)=p;
117 inline void SetEuler(FGColumnVector3 tt) {vEuler = tt;}
119 inline double Getphi(void) const {return vEuler(1);}
120 inline double Gettht(void) const {return vEuler(2);}
121 inline double Getpsi(void) const {return vEuler(3);}
123 inline double GetCosphi(void) const {return cPhi;}
124 inline double GetCostht(void) const {return cTht;}
125 inline double GetCospsi(void) const {return cPsi;}
127 inline double GetSinphi(void) const {return sPhi;}
128 inline double GetSintht(void) const {return sTht;}
129 inline double GetSinpsi(void) const {return sPsi;}
135 FGColumnVector3 vPQR;
136 FGColumnVector3 vAeroPQR;
137 FGColumnVector3 vPQRdot;
138 FGColumnVector3 vPQRdot_prev[4];
139 FGColumnVector3 vMoments;
140 FGColumnVector3 vEuler;
141 FGColumnVector3 vEulerRates;
151 void Debug(int from);
154 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%