X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGMassBalance.h;h=c7468c5dbe0e9b6c0cda14945f7abc0d60cf53de;hb=416ba93a417c4cadde025ba4d7bbcce71d613372;hp=686b27b74de18571702f571dee6ba07d81ff489d;hpb=98d8a98ef26feb5724295fe89763ec50a1345eea;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h index 686b27b74..c7468c5db 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.h +++ b/src/FDM/JSBSim/models/FGMassBalance.h @@ -43,17 +43,20 @@ INCLUDES #include "math/FGMatrix33.h" #include "input_output/FGXMLElement.h" #include +#include /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MASSBALANCE "$Id$" +#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.22 2010/11/18 12:38:06 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONSS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +using std::string; + namespace JSBSim { /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -62,7 +65,11 @@ CLASS DOCUMENTATION /** Models weight, balance and moment of inertia information. Maintains a vector of point masses. Sums the contribution of all, and provides this to FGPropagate. - Loads the \ section of the aircraft configuration file. + Loads the \ section of the aircraft configuration file. There + can be any number of . Each can also have a shape which - if + present - causes an associated moment of inertia to be calculated based on + the shape. Note that a cylinder is solid, a tube is hollow, a ball is solid + and a sphere is hollow.

Configuration File Format:

@code @@ -74,20 +81,24 @@ CLASS DOCUMENTATION {number} {number} {number} - + {number} {number} {number} - + [ +
+ {number} + {number} +
{number} - + {number} {number} {number}
- ... other point masses ... + ... other point masses ...]
@endcode */ @@ -109,9 +120,10 @@ public: double GetMass(void) const {return Mass;} double GetWeight(void) const {return Weight;} - FGColumnVector3& GetXYZcg(void) {return vXYZcg;} + double GetEmptyWeight(void) const {return EmptyWeight;} + const FGColumnVector3& GetXYZcg(void) const {return vXYZcg;} double GetXYZcg(int axis) const {return vXYZcg(axis);} - FGColumnVector3& GetDeltaXYZcg(void) {return vDeltaXYZcg;} + const FGColumnVector3& GetDeltaXYZcg(void) const {return vDeltaXYZcg;} double GetDeltaXYZcg(int axis) const {return vDeltaXYZcg(axis);} /** Computes the inertia contribution of a pointmass. @@ -148,16 +160,17 @@ public: */ FGColumnVector3 StructuralToBody(const FGColumnVector3& r) const; - inline void SetEmptyWeight(double EW) { EmptyWeight = EW;} - inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;} + void SetEmptyWeight(double EW) { EmptyWeight = EW;} + void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;} void AddPointMass(Element* el); double GetTotalPointMassWeight(void); FGColumnVector3& GetPointMassMoment(void); - FGMatrix33& GetJ(void) {return mJ;} - FGMatrix33& GetJinv(void) {return mJinv;} + const FGMatrix33& GetJ(void) const {return mJ;} + const FGMatrix33& GetJinv(void) const {return mJinv;} void SetAircraftBaseInertias(FGMatrix33 BaseJ) {baseJ = BaseJ;} + void GetMassPropertiesReport(void) const; private: double Weight; @@ -177,17 +190,66 @@ private: FGColumnVector3 PointMassCG; FGMatrix33& CalculatePMInertias(void); + + /** The PointMass structure encapsulates a point mass object, moments of inertia + mass, location, etc. */ struct PointMass { PointMass(double w, FGColumnVector3& vXYZ) { Weight = w; Location = vXYZ; + mPMInertia.InitMatrix(); + Radius = 0.0; + Length = 0.0; } + + void CalculateShapeInertia(void) { + switch(eShapeType) { + case esTube: + mPMInertia(1,1) = (Weight/(slugtolb))*Radius*Radius; // mr^2 + mPMInertia(2,2) = (Weight/(slugtolb*12))*(6*Radius*Radius + Length*Length); + mPMInertia(3,3) = mPMInertia(2,2); + break; + case esCylinder: + mPMInertia(1,1) = (Weight/(slugtolb*2))*Radius*Radius; // 0.5*mr^2 + mPMInertia(2,2) = (Weight/(slugtolb*12))*(3*Radius*Radius + Length*Length); + mPMInertia(3,3) = mPMInertia(2,2); + break; + case esSphere: + mPMInertia(1,1) = (Weight/(slugtolb*3))*Radius*Radius*2; // (2mr^2)/3 + mPMInertia(2,2) = mPMInertia(1,1); + mPMInertia(3,3) = mPMInertia(1,1); + case esBall: + mPMInertia(1,1) = (Weight/(slugtolb*5))*Radius*Radius*2; // (2mr^2)/5 + mPMInertia(2,2) = mPMInertia(1,1); + mPMInertia(3,3) = mPMInertia(1,1); + break; + default: + break; + } + } + + enum esShape {esUnspecified, esTube, esCylinder, esSphere, esBall} eShapeType; FGColumnVector3 Location; - double Weight; + double Weight; /// Weight in pounds. + double Radius; /// Radius in feet. + double Length; /// Length in feet. + string Name; + FGMatrix33 mPMInertia; + double GetPointMassLocation(int axis) const {return Location(axis);} + double GetPointMassWeight(void) const {return Weight;} + esShape GetShapeType(void) {return eShapeType;} + FGColumnVector3 GetLocation(void) {return Location;} + FGMatrix33 GetPointMassInertia(void) {return mPMInertia;} + string GetName(void) {return Name;} + void SetPointMassLocation(int axis, double value) {Location(axis) = value;} void SetPointMassWeight(double wt) {Weight = wt;} - double GetPointMassWeight(void) const {return Weight;} + void SetPointMassShapeType(esShape st) {eShapeType = st;} + void SetRadius(double r) {Radius = r;} + void SetLength(double l) {Length = l;} + void SetName(string name) {Name = name;} + double GetPointMassMoI(int r, int c) {return mPMInertia(r,c);} void bind(FGPropertyManager* PropertyManager, int num); };