]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGAerodynamics.h
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGAerodynamics.h
index e25faa761ebdcf472f9e621e21704c8c70f1dfb0..a5e2781959da3b3e8ce398c697b8203d53c06ed6 100644 (file)
@@ -4,7 +4,7 @@
  Author:       Jon S. Berndt
  Date started: 09/13/00
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -38,29 +38,21 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#ifdef FGFS
-#  include <simgear/compiler.h>
-#  ifdef SG_HAVE_STD_INCLUDES
-#    include <vector>
-#    include <map>
-#  else
-#    include <vector.h>
-#    include <map.h>
-#  endif
-#else
-#  include <vector>
-#  include <map>
-#endif
+#include <string>
+#include <vector>
+#include <map>
 
 #include "FGModel.h"
-#include <math/FGFunction.h>
-#include <math/FGColumnVector3.h>
+#include "math/FGFunction.h"
+#include "math/FGColumnVector3.h"
+#include "math/FGMatrix33.h"
+#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_AERODYNAMICS "$Id$"
+#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.21 2010/11/18 12:38:06 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -80,22 +72,52 @@ CLASS DOCUMENTATION
 
     @code
     <aerodynamics>
-       <axis name="{LIFT|DRAG|SIDE|ROLL|PITCH|YAW}">
+       <alphalimits unit="{RAD | DEG}">
+         <min> {number} </min>
+         <max> {number} </max>
+       </alphalimits>
+       <hysteresis_limits unit="{RAD | DEG}">
+         <min> {number} </min>
+         <max> {number} </max>
+       </hysteresis_limits>
+       <aero_ref_pt_shift_x>  
+         <function>
+           {function contents}
+         </function> 
+       </aero_ref_pt_shift_x>  
+       <function>
+         {function contents}
+       </function>
+       <axis name="{LIFT | DRAG | SIDE | ROLL | PITCH | YAW}">
          {force coefficient definitions}
        </axis>
        {additional axis definitions}
     </aerodynamics>
     @endcode
 
+    Optionally two other coordinate systems may be used.<br><br>
+    1) Body coordinate system:
+    @code
+       <axis name="{X | Y | Z}">
+    @endcode
+    <br>
+    2) Axial-Normal coordinate system:
+    @code
+       <axis name="{AXIAL | NORMAL}">
+    @endcode
+    <br>
+    Systems may NOT be combined, or a load error will occur.
+
     @author Jon S. Berndt, Tony Peden
-    @Id $Revision$
+    @version $Revision: 1.21 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGAerodynamics : public FGModel {
+class FGAerodynamics : public FGModel, public FGXMLFileRead
+{
 
 public:
   /** Constructor
@@ -104,6 +126,8 @@ public:
   /// Destructor
   ~FGAerodynamics();
 
+  bool InitModel(void);
+
   /** Runs the Aerodynamics model; called by the Executive
       @return false if no error */
   bool Run(void);
@@ -117,7 +141,7 @@ public:
 
   /** Gets the total aerodynamic force vector.
       @return a force vector reference. */
-  FGColumnVector3& GetForces(void) {return vForces;}
+  const FGColumnVector3& GetForces(void) const {return vForces;}
 
   /** Gets the aerodynamic force for an axis.
       @param n Axis index. This could be 0, 1, or 2, or one of the
@@ -127,65 +151,79 @@ public:
 
   /** Gets the total aerodynamic moment vector.
       @return a moment vector reference. */
-  FGColumnVector3& GetMoments(void) {return vMoments;}
+  const FGColumnVector3& GetMoments(void) const {return vMoments;}
 
   /** Gets the aerodynamic moment for an axis.
       @return the moment about a single axis (as described also in the
               similar call to GetForces(int n).*/
   double GetMoments(int n) const {return vMoments(n);}
 
-  /** Retrieves the aerodynamic forces in the stability axes.
-      @return a reference to a column vector containing the stability axis forces. */
-  FGColumnVector3& GetvFs(void) { return vFs; }
+  /** Retrieves the aerodynamic forces in the wind axes.
+      @return a reference to a column vector containing the wind axis forces. */
+  const FGColumnVector3& GetvFw(void) const { return vFw; }
 
-  /** Retrieves the aerodynamic forces in the stability axes, given an axis.
+  /** Retrieves the aerodynamic forces in the wind axes, given an axis.
       @param axis the axis to return the force for (eX, eY, eZ).
-      @return a reference to a column vector containing the requested stability
+      @return a reference to a column vector containing the requested wind
       axis force. */
-  double GetvFs(int axis) const { return vFs(axis); }
+  double GetvFw(int axis) const { return vFw(axis); }
 
   /** Retrieves the lift over drag ratio */
-  inline double GetLoD(void) const { return lod; }
+  double GetLoD(void) const { return lod; }
 
   /** Retrieves the square of the lift coefficient. */
-  inline double GetClSquared(void) const { return clsq; }
-  inline double GetAlphaCLMax(void) const { return alphaclmax; }
-  inline double GetAlphaCLMin(void) const { return alphaclmin; }
+  double GetClSquared(void) const { return clsq; }
+  double GetAlphaCLMax(void) const { return alphaclmax; }
+  double GetAlphaCLMin(void) const { return alphaclmin; }
 
-  inline double GetHysteresisParm(void) const { return stall_hyst; }
-  inline double GetStallWarn(void) const { return impending_stall; }
+  double GetHysteresisParm(void) const { return stall_hyst; }
+  double GetStallWarn(void) const { return impending_stall; }
   double GetAlphaW(void) const { return alphaw; }
 
   double GetBI2Vel(void) const { return bi2vel; }
   double GetCI2Vel(void) const { return ci2vel; }
 
-  inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
-  inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
+  void SetAlphaCLMax(double tt) { alphaclmax=tt; }
+  void SetAlphaCLMin(double tt) { alphaclmin=tt; }
 
   /** Gets the strings for the current set of coefficients.
       @param delimeter either a tab or comma string depending on output type
       @return a string containing the descriptive names for all coefficients */
-  std::string GetCoefficientStrings(std::string delimeter);
+  std::string GetCoefficientStrings(const std::string& delimeter) const;
 
   /** Gets the coefficient values.
       @param delimeter either a tab or comma string depending on output type
       @return a string containing the numeric values for the current set of
       coefficients */
-  std::string GetCoefficientValues(std::string delimeter);
+  std::string GetCoefficientValues(const std::string& delimeter) const;
+
+  /** Calculates and returns the wind-to-body axis transformation matrix.
+      @return a reference to the wind-to-body transformation matrix.
+      */
+  FGMatrix33& GetTw2b(void);
+
+  /** Calculates and returns the body-to-wind axis transformation matrix.
+      @return a reference to the wind-to-body transformation matrix.
+      */
+  FGMatrix33& GetTb2w(void);
+
+  std::vector <FGFunction*> * GetCoeff(void) const { return Coeff; }
 
 private:
+  enum eAxisType {atNone, atLiftDrag, atAxialNormal, atBodyXYZ} axisType;
   typedef std::map<std::string,int> AxisIndex;
   AxisIndex AxisIdx;
   FGFunction* AeroRPShift;
-  std::vector <FGFunction*> variables;
-  typedef std::vector <FGFunction*> CoeffArray;
+  typedef vector <FGFunction*> CoeffArray;
   CoeffArray* Coeff;
-  FGColumnVector3 vFs;
+  FGColumnVector3 vFnative;
+  FGColumnVector3 vFw;
   FGColumnVector3 vForces;
   FGColumnVector3 vMoments;
-  FGColumnVector3 vLastFs;
   FGColumnVector3 vDXYZcg;
   FGColumnVector3 vDeltaRP;
+  FGMatrix33 mTw2b;
+  FGMatrix33 mTb2w;
   double alphaclmax, alphaclmin;
   double alphahystmax, alphahystmin;
   double impending_stall, stall_hyst;
@@ -193,8 +231,8 @@ private:
   double clsq, lod, qbar_area;
 
   typedef double (FGAerodynamics::*PMF)(int) const;
+  void DetermineAxisSystem(void);
   void bind(void);
-  void unbind(void);
 
   void Debug(int from);
 };