JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
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 Lesser General Public License as published by the Free
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later 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 Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on 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 "FGJSBBase.h"
61 #include "math/FGMatrix33.h"
62 
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 FORWARD DECLARATIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66 
67 namespace JSBSim {
68 
69 class FGFDMExec;
70 class FGMassBalance;
71 
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 CLASS DOCUMENTATION
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75 
217 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218 CLASS DECLARATION
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
220 
221 class FGForce : public FGJSBBase
222 {
223 public:
225  explicit FGForce(FGFDMExec *FDMExec);
226  FGForce(const FGForce& force);
227 
229  virtual ~FGForce();
230 
231  enum TransformType { tNone, tWindBody, tLocalBody, tCustom };
232 
233  virtual const FGColumnVector3& GetBodyForces(void);
234 
235  inline double GetBodyXForce(void) const { return vFb(eX); }
236  inline double GetBodyYForce(void) const { return vFb(eY); }
237  inline double GetBodyZForce(void) const { return vFb(eZ); }
238  inline const FGColumnVector3& GetMoments(void) const { return vM; }
239 
240  // Normal point of application, JSBsim structural coords
241  // (inches, x +back, y +right, z +up)
242  inline void SetLocation(double x, double y, double z) {
243  vXYZn(eX) = x;
244  vXYZn(eY) = y;
245  vXYZn(eZ) = z;
246  SetActingLocation(x, y, z);
247  }
248 
257  inline void SetActingLocation(double x, double y, double z) {
258  vActingXYZn(eX) = x;
259  vActingXYZn(eY) = y;
260  vActingXYZn(eZ) = z;
261  }
262  inline void SetLocationX(double x) {vXYZn(eX) = x; vActingXYZn(eX) = x;}
263  inline void SetLocationY(double y) {vXYZn(eY) = y; vActingXYZn(eY) = y;}
264  inline void SetLocationZ(double z) {vXYZn(eZ) = z; vActingXYZn(eZ) = z;}
265  inline double SetActingLocationX(double x) {vActingXYZn(eX) = x; return x;}
266  inline double SetActingLocationY(double y) {vActingXYZn(eY) = y; return y;}
267  inline double SetActingLocationZ(double z) {vActingXYZn(eZ) = z; return z;}
268  inline void SetLocation(const FGColumnVector3& vv) { vXYZn = vv; SetActingLocation(vv);}
269  inline void SetActingLocation(const FGColumnVector3& vv) { vActingXYZn = vv; }
270 
271  inline double GetLocationX( void ) const { return vXYZn(eX);}
272  inline double GetLocationY( void ) const { return vXYZn(eY);}
273  inline double GetLocationZ( void ) const { return vXYZn(eZ);}
274  inline double GetActingLocationX( void ) const { return vActingXYZn(eX);}
275  inline double GetActingLocationY( void ) const { return vActingXYZn(eY);}
276  inline double GetActingLocationZ( void ) const { return vActingXYZn(eZ);}
277  const FGColumnVector3& GetLocation(void) const { return vXYZn; }
278  const FGColumnVector3& GetActingLocation(void) const { return vActingXYZn; }
279 
280  //these angles are relative to body axes, not earth!!!!!
281  //I'm using these because pitch, roll, and yaw are easy to visualize,
282  //there's no equivalent to roll in wind axes i.e. alpha, ? , beta
283  //making up new names or using these is a toss-up: either way people
284  //are going to get confused.
285  //They are in radians.
286 
287  void SetAnglesToBody(double broll, double bpitch, double byaw);
288  inline void SetAnglesToBody(const FGColumnVector3& vv) {
289  SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
290  }
291 
292  void UpdateCustomTransformMatrix(void);
293  void SetPitch(double pitch) {vOrient(ePitch) = pitch; UpdateCustomTransformMatrix();}
294  void SetYaw(double yaw) {vOrient(eYaw) = yaw; UpdateCustomTransformMatrix();}
295 
296  double GetPitch(void) const {return vOrient(ePitch);}
297  double GetYaw(void) const {return vOrient(eYaw);}
298 
299  inline const FGColumnVector3& GetAnglesToBody(void) const {return vOrient;}
300  inline double GetAnglesToBody(int axis) const {return vOrient(axis);}
301 
302  inline void SetTransformType(TransformType ii) { ttype=ii; }
303  inline TransformType GetTransformType(void) const { return ttype; }
304 
305  const FGMatrix33& Transform(void) const;
306 
307 protected:
308  FGFDMExec *fdmex;
309  FGMassBalance* MassBalance;
310  FGColumnVector3 vFn;
311  FGColumnVector3 vMn;
312  FGColumnVector3 vOrient;
313  TransformType ttype;
314  FGColumnVector3 vXYZn;
315  FGColumnVector3 vActingXYZn;
316  FGMatrix33 mT;
317 
318 private:
319  FGColumnVector3 vFb;
320  FGColumnVector3 vM;
321 
322  void Debug(int from);
323 };
324 }
325 #endif
326 
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGForce::SetActingLocation
void SetActingLocation(double x, double y, double z)
Acting point of application.
Definition: FGForce.h:257
JSBSim::FGForce::~FGForce
virtual ~FGForce()
Destructor.
Definition: FGForce.cpp:74
JSBSim::FGForce
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:221
JSBSim::FGJSBBase
JSBSim Base class.
Definition: FGJSBBase.h:78
JSBSim::FGForce::FGForce
FGForce(FGFDMExec *FDMExec)
Constructor.
Definition: FGForce.cpp:53