]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTranslation.h
Fixed calibrated airspeed output so that it accounts for wind.
[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 COMMENTS, REFERENCES,  and NOTES
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
34     Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
35     School, January 1994
36 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
37     JSC 12960, July 1977
38 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
39     NASA-Ames", NASA CR-2497, January 1975
40 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
41     Wiley & Sons, 1979 ISBN 0-471-03032-5
42 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
43     1982 ISBN 0-471-08936-2
44  
45   The order of rotations used in this class corresponds to a 3-2-1 sequence,
46   or Y-P-R, or Z-Y-X, if you prefer.
47  
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 SENTRY
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52 #ifndef FGTRANSLATION_H
53 #define FGTRANSLATION_H
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 INCLUDES
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 #ifdef FGFS
60 #  include <simgear/compiler.h>
61 #  ifdef SG_HAVE_STD_INCLUDES
62 #    include <cmath>
63 #  else
64 #    include <math.h>
65 #  endif
66 #else
67 #  if defined(sgi) && !defined(__GNUC__)
68 #    include <math.h>
69 #  else
70 #    include <cmath>
71 #  endif
72 #endif
73
74 #include "FGModel.h"
75 #include "FGMatrix33.h"
76 #include "FGColumnVector3.h"
77 #include "FGColumnVector4.h"
78
79 #define ID_TRANSLATION "$Id$"
80
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 CLASS DECLARATION
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84
85 namespace JSBSim {
86
87 class FGTranslation : public FGModel {
88 public:
89   FGTranslation(FGFDMExec*);
90   ~FGTranslation();
91   
92     /** Bound Properties
93         GetUVW(1): velocities/u-fps
94         GetUVW(2): velocities/v-fps
95         GetUVW(3): velocities/w-fps
96     */
97   inline double           GetUVW   (int idx) const { return vUVW(idx); }
98   inline FGColumnVector3& GetUVW   (void)    { return vUVW; }
99   inline FGColumnVector3& GetUVWdot(void)    { return vUVWdot; }
100     /** Bound Properties
101         GetUVWdot(1): accelerations/udot-fps
102         GetUVWdot(2): accelerations/vdot-fps
103         GetUVWdot(3): accelerations/wdot-fps
104     */
105   inline double           GetUVWdot(int idx) const { return vUVWdot(idx); }
106   inline FGColumnVector3& GetAeroUVW (void)    { return vAeroUVW; }
107     /** Bound Properties
108         GetAeroUVW(1): velocities/u-aero-fps
109         GetAeroUVW(2): velocities/v-aero-fps
110         GetAeroUVW(3): velocities/w-aero-fps
111     */
112   inline double           GetAeroUVW (int idx) const { return vAeroUVW(idx); }
113
114     /** Bound Property:  aero/alpha-rad
115     */
116   double Getalpha(void) const { return alpha; }
117     /** Bound Property:  aero/beta-rad
118     */
119   double Getbeta (void) const { return beta; }
120     /** Bound Property:  aero/mag-beta-rad
121     */
122   inline double GetMagBeta(void) const { return fabs(beta); }
123     /** Bound Property:  aero/qbar-psf
124     */
125   double Getqbar (void) const { return qbar; }
126     /** Bound Property:  aero/qbarUW-psf
127     */
128   double GetqbarUW (void) const { return qbarUW; }
129     /** Bound Property:  aero/qbarUV-psf
130     */
131   double GetqbarUV (void) const { return qbarUV; }
132     /** Bound Property:  velocities/vt-fps
133     */
134   inline double GetVt   (void) const { return Vt; }
135     /** Bound Property:  velocities/mach-norm
136     */
137   double GetMach (void) const { return Mach; }
138     /** Bound Property:  aero/alphadot-rad_sec
139     */
140   double Getadot (void) const { return adot; }
141     /** Bound Property:  aero/betadot-rad_sec
142     */
143   double Getbdot (void) const { return bdot; }
144
145     /** Bound Properties
146         SetUVW(1): velocities/u-fps
147         SetUVW(2): velocities/v-fps
148         SetUVW(3): velocities/w-fps
149     */
150   void SetUVW(FGColumnVector3 tt) { vUVW = tt; }
151   void SetAeroUVW(FGColumnVector3 tt) { vAeroUVW = tt; }
152
153     /** Bound Property:  aero/alpha-rad
154     */
155   inline void Setalpha(double tt) { alpha = tt; }
156     /** Bound Property:  aero/beta-rad
157     */
158   inline void Setbeta (double tt) { beta  = tt; }
159     /** Bound Property:  aero/qbar-psf
160     */
161   inline void Setqbar (double tt) { qbar = tt; }
162     /** Bound Property:  aero/qbarUW-psf
163     */
164   inline void SetqbarUW (double tt) { qbarUW = tt; }
165     /** Bound Property:  aero/qbarUV-psf
166     */
167   inline void SetqbarUV (double tt) { qbarUV = tt; }
168     /** Bound Property:  velocities/vt-fps
169     */
170   inline void SetVt   (double tt) { Vt = tt; }
171     /** Bound Property:  velocities/mach-norm
172     */
173   inline void SetMach (double tt) { Mach=tt; }
174     /** Bound Property:  aero/alphadot-rad_sec
175     */
176   inline void Setadot (double tt) { adot = tt; }
177     /** Bound Property:  aero/betadot-rad_sec
178     */
179   inline void Setbdot (double tt) { bdot = tt; }
180
181   inline void SetAB(double t1, double t2) { alpha=t1; beta=t2; }
182   
183   bool Run(void);
184
185   void bind(void);
186   void unbind(void);
187
188 private:
189   FGColumnVector3 vUVW;
190   FGColumnVector3 vUVWdot;
191   FGColumnVector3 vUVWdot_prev[3];
192   FGMatrix33      mVel;
193   FGColumnVector3 vAeroUVW;
194
195   double Vt, Mach;
196   double qbar, qbarUW, qbarUV;
197   double dt;
198   double alpha, beta;
199   double adot,bdot;
200   void Debug(int from);
201 };
202 }
203 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 #endif
205