]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGForce.h
Oct 2, 2000 JSBSim sync.
[flightgear.git] / src / FDM / JSBSim / FGForce.h
1 /*******************************************************************************
2
3  Header:       FGForce.h
4  Author:       Tony Peden
5  Date started: 5/20/00
6
7  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
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
27  HISTORY
28 --------------------------------------------------------------------------------
29 5/20/00  TP   Created
30
31
32 FUNCTIONAL DESCRIPTION
33 --------------------------------------------------------------------------------
34
35 The purpose of this class is to provide storage for computed forces and
36 encapsulate all the functionality associated with transforming those
37 forces from their native coord system to the body system.  This includes
38 computing the moments due to the difference between the point of application
39 and the cg.
40
41 CAVEAT:  if the custom transform is used for wind-to-body transforms then the
42          user *must* always pass this class the negative of beta. This is true
43          because sideslip angle does not follow the right hand rule i.e. it is
44          positive for aircraft nose left sideslip.  Note that use of the custom
45          transform for this purpose shouldn't be necessary as it is already
46          provided by SetTransform(tWindBody) and is not subject to the same
47          restriction.
48
49 ********************************************************************************
50 SENTRY
51 *******************************************************************************/
52
53 #ifndef FGFORCE_H
54 #define FGFORCE_H
55
56 /*******************************************************************************
57 INCLUDES
58 *******************************************************************************/
59
60 #include "FGFDMExec.h"
61 #include "FGMatrix.h"
62
63 /*******************************************************************************
64 CLASS DECLARATION
65 *******************************************************************************/
66
67 typedef enum { tNone, tWindBody, tLocalBody, tCustom } TransformType;
68
69 class FGForce {
70
71 public:
72
73   FGForce(FGFDMExec *FDMExec);
74   ~FGForce(void);
75
76   inline void SetNativeForces(float Fnx, float Fny, float Fnz) {
77     vFn(1)=Fnx;
78     vFn(2)=Fny;
79     vFn(3)=Fnz;
80   }
81   inline void SetNativeForces(FGColumnVector vv) { vFn = vv; };
82
83   inline void SetNativeMoments(float Ln,float Mn, float Nn) {
84     vMn(1)=Ln;
85     vMn(2)=Mn;
86     vMn(3)=Nn;
87   }
88   inline void SetNativeMoments(FGColumnVector vv) { vMn = vv; }
89
90   inline FGColumnVector GetNativeForces(void) { return vFn; }
91   inline FGColumnVector GetNativeMoments(void) { return vMn; }
92
93
94   FGColumnVector GetBodyForces(void);
95
96   inline FGColumnVector GetMoments(void) { return vM; }
97
98   //point of application, JSBsim structural coords
99   //(inches, x +back, y +right, z +up)
100   inline void SetLocation(float x, float y, float z) {
101     vXYZn(1) = x;
102     vXYZn(2) = y;
103     vXYZn(3) = z;
104   }
105   inline void SetLocation(FGColumnVector vv) { vXYZn = vv; }
106   FGColumnVector GetLocation(void) { return vXYZn; }
107
108   //these angles are relative to body axes, not earth!!!!!
109   //I'm using these because pitch, roll, and yaw are easy to visualize,
110   //there's no equivalent to roll in wind axes i.e. alpha, ? , beta
111   //making up new names or using these is a toss-up: either way people
112   //are going to get confused.
113   //They are in radians.
114
115   void SetAnglesToBody(float broll, float bpitch, float byaw);
116   inline void  SetAnglesToBody(FGColumnVector vv) { SetAnglesToBody(vv(1), vv(2), vv(3));}
117
118   inline void SetSense(float x, float y, float z) { vSense(1)=x, vSense(2)=y, vSense(3)=z; }
119   inline void SetSense(FGColumnVector vv) { vSense=vv; }
120
121   inline FGColumnVector GetSense(void) { return vSense; }
122
123   inline void SetTransformType(TransformType ii) { ttype=ii; }
124   inline TransformType GetTransformType(void) { return ttype; }
125
126   FGMatrix Transform(void);
127
128 protected:
129   FGColumnVector vFn;
130   FGColumnVector vMn;
131
132 private:
133   FGColumnVector vFb;
134   FGColumnVector vM;
135   FGColumnVector vXYZn;
136   FGColumnVector vDXYZ;
137   FGColumnVector vSense;
138
139   FGMatrix mT;
140
141   FGFDMExec *fdmex;
142   TransformType ttype;
143
144 };
145
146 #endif
147