2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
Header: FGMassBalance.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 09/12/2000
|
|
|
|
|
|
|
|
------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) --------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
09/12/2000 JSB Created
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
SENTRY
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#ifndef FGMASSBALANCE_H
|
|
|
|
#define FGMASSBALANCE_H
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#include "FGModel.h"
|
2004-03-14 14:57:07 +00:00
|
|
|
#include "FGColumnVector3.h"
|
|
|
|
#include "FGMatrix33.h"
|
2001-12-07 17:10:17 +00:00
|
|
|
#include <vector>
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2004-01-14 22:09:39 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#define ID_MASSBALANCE "$Id$"
|
2000-10-14 02:10:10 +00:00
|
|
|
|
2004-01-14 22:09:39 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
FORWARD DECLARATIONSS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2003-06-03 08:46:15 +00:00
|
|
|
namespace JSBSim {
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2004-01-14 22:09:39 +00:00
|
|
|
CLASS DOCUMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/** Models weight and balance information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
CLASS DECLARATION
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
class FGMassBalance : public FGModel
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2000-10-09 21:16:21 +00:00
|
|
|
FGMassBalance(FGFDMExec*);
|
2000-10-02 23:07:30 +00:00
|
|
|
~FGMassBalance();
|
|
|
|
|
|
|
|
bool Run(void);
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2002-03-20 12:45:02 +00:00
|
|
|
inline double GetMass(void) const {return Mass;}
|
|
|
|
inline double GetWeight(void) const {return Weight;}
|
2001-10-05 20:19:59 +00:00
|
|
|
inline FGColumnVector3& GetXYZcg(void) {return vXYZcg;}
|
2002-03-20 12:45:02 +00:00
|
|
|
inline double GetXYZcg(int axis) const {return vXYZcg(axis);}
|
2001-11-20 22:34:24 +00:00
|
|
|
|
2004-03-14 14:57:07 +00:00
|
|
|
/** Computes the inertia contribution of a pointmass.
|
|
|
|
Computes and returns the inertia matrix of a pointmass of mass
|
|
|
|
slugs at the given vector r in the structural frame. The units
|
|
|
|
should be for the mass in slug and the vector in the structural
|
|
|
|
frame as usual in inches.
|
|
|
|
@param slugs the mass of this single pointmass given in slugs
|
|
|
|
@param r the location of this single pointmass in the structural frame
|
|
|
|
*/
|
|
|
|
FGMatrix33 GetPointmassInertia(double slugs, const FGColumnVector3& r) const
|
|
|
|
{
|
|
|
|
FGColumnVector3 v = StructuralToBody( r );
|
|
|
|
FGColumnVector3 sv = slugs*v;
|
|
|
|
double xx = sv(1)*v(1);
|
|
|
|
double yy = sv(2)*v(2);
|
|
|
|
double zz = sv(3)*v(3);
|
|
|
|
double xy = -sv(1)*v(2);
|
|
|
|
double xz = -sv(1)*v(3);
|
|
|
|
double yz = -sv(2)*v(3);
|
|
|
|
return FGMatrix33( yy+zz, xy, xz,
|
|
|
|
xy, xx+zz, yz,
|
|
|
|
xz, yz, xx+yy );
|
|
|
|
}
|
|
|
|
|
2004-02-14 10:19:56 +00:00
|
|
|
/** Conversion from the structural frame to the body frame.
|
2004-03-14 14:57:07 +00:00
|
|
|
Converts the location given in the structural frame
|
|
|
|
coordinate system to the body frame. The units of the structural
|
|
|
|
frame are assumed to be in inches. The unit of the result is in
|
|
|
|
ft.
|
|
|
|
@param r vector coordinate in the structural reference frame (X positive
|
|
|
|
aft, measurements in inches).
|
|
|
|
@return vector coordinate in the body frame, in feet.
|
2004-02-14 10:19:56 +00:00
|
|
|
*/
|
|
|
|
FGColumnVector3 StructuralToBody(const FGColumnVector3& r) const;
|
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
inline void SetEmptyWeight(double EW) { EmptyWeight = EW;}
|
2004-03-14 14:57:07 +00:00
|
|
|
inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = vXYZcg = CG;}
|
|
|
|
|
2001-12-07 17:10:17 +00:00
|
|
|
void AddPointMass(double weight, double X, double Y, double Z);
|
|
|
|
double GetPointMassWeight(void);
|
2002-06-08 03:14:03 +00:00
|
|
|
FGColumnVector3& GetPointMassMoment(void);
|
2004-03-14 14:57:07 +00:00
|
|
|
FGMatrix33& GetJ(void) {return mJ;}
|
|
|
|
FGMatrix33& GetJinv(void) {return mJinv;}
|
|
|
|
void SetAircraftBaseInertias(FGMatrix33 BaseJ) {baseJ = BaseJ;}
|
|
|
|
|
2002-03-20 12:45:02 +00:00
|
|
|
void bind(void);
|
|
|
|
void unbind(void);
|
2001-06-05 20:58:48 +00:00
|
|
|
|
|
|
|
private:
|
2001-11-20 22:34:24 +00:00
|
|
|
double Weight;
|
|
|
|
double EmptyWeight;
|
|
|
|
double Mass;
|
2004-03-14 14:57:07 +00:00
|
|
|
FGMatrix33 mJ;
|
|
|
|
FGMatrix33 mJinv;
|
|
|
|
FGMatrix33 pmJ;
|
|
|
|
FGMatrix33 baseJ;
|
2001-10-05 20:19:59 +00:00
|
|
|
FGColumnVector3 vXYZcg;
|
|
|
|
FGColumnVector3 vXYZtank;
|
|
|
|
FGColumnVector3 vbaseXYZcg;
|
2004-03-14 14:57:07 +00:00
|
|
|
FGColumnVector3 vPMxyz;
|
2001-12-07 17:10:17 +00:00
|
|
|
vector <FGColumnVector3> PointMassLoc;
|
|
|
|
vector <double> PointMassWeight;
|
|
|
|
FGColumnVector3 PointMassCG;
|
2004-03-14 14:57:07 +00:00
|
|
|
FGMatrix33& CalculatePMInertias(void);
|
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
void Debug(int from);
|
2000-10-02 23:07:30 +00:00
|
|
|
};
|
2003-01-24 12:55:28 +00:00
|
|
|
}
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
#endif
|