JSBSim Flight Dynamics Model  1.0 (02 March 2017)
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 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 Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser 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 Lesser 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 "FGJSBBase.h"
62 #include "math/FGMatrix33.h"
63 #include "math/FGColumnVector3.h"
64 
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 DEFINITIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 
69 #define ID_FORCE "$Id: FGForce.h,v 1.17 2012/04/01 17:05:51 bcoconni Exp $"
70 
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 FORWARD DECLARATIONS
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74 
75 namespace JSBSim {
76 
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DOCUMENTATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80 
221 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
222 CLASS DECLARATION
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
224 
225 class FGForce : public FGJSBBase
226 {
227 public:
229  FGForce(FGFDMExec *FDMExec);
230  FGForce(const FGForce& force) {
231  vFn = force.vFn;
232  vXYZn = force.vXYZn;
233  ttype = force.ttype;
234  fdmex = force.fdmex;
235  }
237  ~FGForce();
238 
239  enum TransformType { tNone, tWindBody, tLocalBody, tCustom };
240 
241  virtual const FGColumnVector3& GetBodyForces(void);
242 
243  inline double GetBodyXForce(void) const { return vFb(eX); }
244  inline double GetBodyYForce(void) const { return vFb(eY); }
245  inline double GetBodyZForce(void) const { return vFb(eZ); }
246  inline const FGColumnVector3& GetMoments(void) const { return vM; }
247 
248  // Normal point of application, JSBsim structural coords
249  // (inches, x +back, y +right, z +up)
250  inline void SetLocation(double x, double y, double z) {
251  vXYZn(eX) = x;
252  vXYZn(eY) = y;
253  vXYZn(eZ) = z;
254  SetActingLocation(x, y, z);
255  }
256 
265  inline void SetActingLocation(double x, double y, double z) {
266  vActingXYZn(eX) = x;
267  vActingXYZn(eY) = y;
268  vActingXYZn(eZ) = z;
269  }
270  inline void SetLocationX(double x) {vXYZn(eX) = x; vActingXYZn(eX) = x;}
271  inline void SetLocationY(double y) {vXYZn(eY) = y; vActingXYZn(eY) = y;}
272  inline void SetLocationZ(double z) {vXYZn(eZ) = z; vActingXYZn(eZ) = z;}
273  inline double SetActingLocationX(double x) {vActingXYZn(eX) = x; return x;}
274  inline double SetActingLocationY(double y) {vActingXYZn(eY) = y; return y;}
275  inline double SetActingLocationZ(double z) {vActingXYZn(eZ) = z; return z;}
276  inline void SetLocation(const FGColumnVector3& vv) { vXYZn = vv; SetActingLocation(vv);}
277  inline void SetActingLocation(const FGColumnVector3& vv) { vActingXYZn = vv; }
278 
279  inline double GetLocationX( void ) const { return vXYZn(eX);}
280  inline double GetLocationY( void ) const { return vXYZn(eY);}
281  inline double GetLocationZ( void ) const { return vXYZn(eZ);}
282  inline double GetActingLocationX( void ) const { return vActingXYZn(eX);}
283  inline double GetActingLocationY( void ) const { return vActingXYZn(eY);}
284  inline double GetActingLocationZ( void ) const { return vActingXYZn(eZ);}
285  const FGColumnVector3& GetLocation(void) const { return vXYZn; }
286  const FGColumnVector3& GetActingLocation(void) const { return vActingXYZn; }
287 
288  //these angles are relative to body axes, not earth!!!!!
289  //I'm using these because pitch, roll, and yaw are easy to visualize,
290  //there's no equivalent to roll in wind axes i.e. alpha, ? , beta
291  //making up new names or using these is a toss-up: either way people
292  //are going to get confused.
293  //They are in radians.
294 
295  void SetAnglesToBody(double broll, double bpitch, double byaw);
296  inline void SetAnglesToBody(const FGColumnVector3& vv) {
297  SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
298  }
299 
300  void UpdateCustomTransformMatrix(void);
301  void SetPitch(double pitch) {vOrient(ePitch) = pitch; UpdateCustomTransformMatrix();}
302  void SetYaw(double yaw) {vOrient(eYaw) = yaw; UpdateCustomTransformMatrix();}
303 
304  double GetPitch(void) const {return vOrient(ePitch);}
305  double GetYaw(void) const {return vOrient(eYaw);}
306 
307  inline const FGColumnVector3& GetAnglesToBody(void) const {return vOrient;}
308  inline double GetAnglesToBody(int axis) const {return vOrient(axis);}
309 
310  inline void SetTransformType(TransformType ii) { ttype=ii; }
311  inline TransformType GetTransformType(void) const { return ttype; }
312 
313  const FGMatrix33& Transform(void) const;
314 
315 protected:
316  FGFDMExec *fdmex;
317  FGColumnVector3 vFn;
318  FGColumnVector3 vMn;
319  FGColumnVector3 vH;
320  FGColumnVector3 vOrient;
321  TransformType ttype;
322  FGColumnVector3 vXYZn;
323  FGColumnVector3 vActingXYZn;
324  FGMatrix33 mT;
325 
326 private:
327  FGColumnVector3 vFb;
328  FGColumnVector3 vM;
329  FGColumnVector3 vDXYZ;
330 
331  void Debug(int from);
332 };
333 }
334 #endif
335 
void SetActingLocation(double x, double y, double z)
Acting point of application.
Definition: FGForce.h:265
~FGForce()
Destructor.
Definition: FGForce.cpp:85
JSBSim Base class.
Definition: FGJSBBase.h:80
FGForce(FGFDMExec *FDMExec)
Constructor.
Definition: FGForce.cpp:61
This class implements a 3 element column vector.
Handles matrix math operations.
Definition: FGMatrix33.h:92
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:225