1 /*******************************************************************************
7 ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
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 General Public License for more
19 You should have received a copy of the GNU 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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
28 --------------------------------------------------------------------------------
32 FUNCTIONAL DESCRIPTION
33 --------------------------------------------------------------------------------
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
43 #include "FGFDMExec.h"
44 #include "FGAircraft.h"
45 #include "FGTranslation.h"
50 static const char *IdSrc = "$Header$";
51 static const char *IdHdr = "ID_FORCE";
53 FGForce::FGForce(FGFDMExec *FDMExec) :
65 mT(1,1)=1; //identity matrix
71 FGForce::~FGForce(void) {}
73 FGColumnVector FGForce::GetBodyForces(void) {
76 vFb=Transform()*(vFn.multElementWise(vSense));
78 //find the distance from this vector's location to the cg
79 //needs to be done like this to convert from structural to body coords
80 vDXYZ(1) = -(vXYZn(1) - fdmex->GetAircraft()->GetXYZcg()(1))*INCHTOFT;
81 vDXYZ(2) = (vXYZn(2) - fdmex->GetAircraft()->GetXYZcg()(2))*INCHTOFT; //cg and rp values are in inches
82 vDXYZ(3) = -(vXYZn(3) - fdmex->GetAircraft()->GetXYZcg()(3))*INCHTOFT;
91 FGMatrix FGForce::Transform(void) {
94 return fdmex->GetState()->GetTs2b(fdmex->GetTranslation()->Getalpha(),fdmex->GetTranslation()->Getbeta());
96 return fdmex->GetState()->GetTl2b();
102 cout << "Unrecognized tranform requested from FGForce::Transform()" << endl;
107 void FGForce::SetAnglesToBody(float broll, float bpitch, float byaw) {
109 if(ttype == tCustom) {
110 float cp,sp,cr,sr,cy,sy;
112 cp=cos(bpitch); sp=sin(bpitch);
113 cr=cos(broll); sr=sin(broll);
114 cy=cos(byaw); sy=sin(byaw);
120 mT(2,1)=sr*sp*cy-cr*sy;
121 mT(2,2)=sr*sp*sy+cr*cy;
124 mT(3,1)=cr*sp*cy+sr*sy;
125 mT(3,2)=cr*sp*sy-sr*cy;