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"
51 FGForce::FGForce(FGFDMExec *FDMExec) :
63 mT(1,1)=1; //identity matrix
69 FGForce::~FGForce(void) {}
71 FGColumnVector FGForce::GetBodyForces(void) {
74 vFb=Transform()*(vFn.multElementWise(vSense));
76 //find the distance from this vector's location to the cg
77 //needs to be done like this to convert from structural to body coords
78 vDXYZ(1) = -(vXYZn(1) - fdmex->GetAircraft()->GetXYZcg()(1))*INCHTOFT;
79 vDXYZ(2) = (vXYZn(2) - fdmex->GetAircraft()->GetXYZcg()(2))*INCHTOFT; //cg and rp values are in inches
80 vDXYZ(3) = -(vXYZn(3) - fdmex->GetAircraft()->GetXYZcg()(3))*INCHTOFT;
89 FGMatrix FGForce::Transform(void) {
92 return fdmex->GetState()->GetTs2b(fdmex->GetTranslation()->Getalpha(),fdmex->GetTranslation()->Getbeta());
94 return fdmex->GetState()->GetTl2b();
100 cout << "Unrecognized tranform requested from FGForce::Transform()" << endl;
105 void FGForce::SetAnglesToBody(float broll, float bpitch, float byaw) {
107 if(ttype == tCustom) {
108 float cp,sp,cr,sr,cy,sy;
110 cp=cos(bpitch); sp=sin(bpitch);
111 cr=cos(broll); sr=sin(broll);
112 cy=cos(byaw); sy=sin(byaw);
118 mT(2,1)=sr*sp*cy-cr*sy;
119 mT(2,2)=sr*sp*sy+cr*cy;
122 mT(3,1)=cr*sp*cy+sr*sy;
123 mT(3,2)=cr*sp*sy-sr*cy;