]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTranslation.h
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGTranslation.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Header:       FGTranslation.h
4  Author:       Jon Berndt
5  Date started: 12/02/98
6  
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8  
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
12  version.
13  
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
17  details.
18  
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.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/02/98   JSB   Created
29  
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGTRANSLATION_H
35 #define FGTRANSLATION_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  ifdef SG_HAVE_STD_INCLUDES
44 #    include <cmath>
45 #  else
46 #    include <math.h>
47 #  endif
48 #else
49 #  if defined(sgi) && !defined(__GNUC__)
50 #    include <math.h>
51 #  else
52 #    include <cmath>
53 #  endif
54 #endif
55
56 #include "FGModel.h"
57 #include "FGMatrix33.h"
58 #include "FGColumnVector3.h"
59 #include "FGColumnVector4.h"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 DEFINITIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 #define ID_TRANSLATION "$Id$"
66
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 FORWARD DECLARATION
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70
71 namespace JSBSim {
72
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 CLASS DOCUMENTATION
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76
77 /** Models the translation aspects of the EOM.
78     Note: The order of rotations used in this class corresponds to a 3-2-1 sequence,
79     or Y-P-R, or Z-Y-X, if you prefer.
80     @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
81     Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
82     School, January 1994
83     @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
84     JSC 12960, July 1977
85     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
86     NASA-Ames", NASA CR-2497, January 1975
87     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
88     Wiley & Sons, 1979 ISBN 0-471-03032-5
89     @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
90     1982 ISBN 0-471-08936-2
91   */
92
93 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 CLASS DECLARATION
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
96
97 class FGTranslation : public FGModel {
98 public:
99   FGTranslation(FGFDMExec*);
100   ~FGTranslation();
101   
102   inline double           GetUVW   (int idx) const { return vUVW(idx); }
103   inline FGColumnVector3& GetUVW   (void)    { return vUVW; }
104   inline FGColumnVector3& GetUVWdot(void)    { return vUVWdot; }
105   inline double           GetUVWdot(int idx) const { return vUVWdot(idx); }
106   inline FGColumnVector3& GetAeroUVW (void)    { return vAeroUVW; }
107   inline double           GetAeroUVW (int idx) const { return vAeroUVW(idx); }
108
109   double Getalpha(void) const { return alpha; }
110   double Getbeta (void) const { return beta; }
111   inline double GetMagBeta(void) const { return fabs(beta); }
112   double Getqbar (void) const { return qbar; }
113   double GetqbarUW (void) const { return qbarUW; }
114   double GetqbarUV (void) const { return qbarUV; }
115   inline double GetVt   (void) const { return Vt; }
116   double GetMach (void) const { return Mach; }
117   double GetMachU(void) const { return vMachUVW(eU); }
118   double Getadot (void) const { return adot; }
119   double Getbdot (void) const { return bdot; }
120
121   void SetUVW(FGColumnVector3 tt) { vUVW = tt; }
122   void SetAeroUVW(FGColumnVector3 tt) { vAeroUVW = tt; }
123
124   inline void Setalpha(double tt) { alpha = tt; }
125   inline void Setbeta (double tt) { beta  = tt; }
126   inline void Setqbar (double tt) { qbar = tt; }
127   inline void SetqbarUW (double tt) { qbarUW = tt; }
128   inline void SetqbarUV (double tt) { qbarUV = tt; }
129   inline void SetVt   (double tt) { Vt = tt; }
130   inline void SetMach (double tt) { Mach=tt; }
131   inline void Setadot (double tt) { adot = tt; }
132   inline void Setbdot (double tt) { bdot = tt; }
133
134   inline void SetAB(double t1, double t2) { alpha=t1; beta=t2; }
135   
136   bool Run(void);
137
138   void bind(void);
139   void unbind(void);
140
141 private:
142   FGColumnVector3 vUVW;
143   FGColumnVector3 vUVWdot;
144   FGColumnVector3 vUVWdot_prev[4];
145   FGMatrix33      mVel;
146   FGColumnVector3 vAeroUVW;
147   FGColumnVector3 vMachUVW;
148
149   double Vt, Mach;
150   double qbar, qbarUW, qbarUV;
151   double dt;
152   double alpha, beta;
153   double adot,bdot;
154   void Debug(int from);
155 };
156 }
157 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 #endif
159