1 /*******************************************************************************
6 Purpose: Encapsulates the landing gear elements
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
32 --------------------------------------------------------------------------------
35 ********************************************************************************
37 *******************************************************************************/
42 /*******************************************************************************
43 ************************************ CODE **************************************
44 *******************************************************************************/
47 FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
52 *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3) >> kSpring >> bDamp
53 >> statFCoeff >> brakeCoeff;
54 State = Exec->GetState();
55 Aircraft = Exec->GetAircraft();
56 Position = Exec->GetPosition();
57 Rotation = Exec->GetRotation();
63 /******************************************************************************/
65 FGLGear::~FGLGear(void)
69 /******************************************************************************/
71 FGColumnVector FGLGear::Force(void)
73 static FGColumnVector vForce(3);
74 static FGColumnVector vLocalForce(3);
75 static FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
76 static FGColumnVector vWhlBodyVec(3); // Vector: CG to this wheel (Body)
77 static FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
79 vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
80 vWhlBodyVec(eX) = -vWhlBodyVec(eX);
81 vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
83 vLocalGear = State->GetTb2l() * vWhlBodyVec;
85 compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
87 if (compressLength > 0.00) {
91 vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
92 vWhlVelVec += Position->GetVel();
93 compressSpeed = vWhlVelVec(eZ);
95 vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
96 vWhlVelVec(eZ) = 0.00;
98 vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
99 vLocalForce(eX) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX);
100 vLocalForce(eY) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY);
102 vForce = State->GetTl2b() * vLocalForce ;
103 vMoment = vWhlBodyVec * vForce;
109 vMoment.InitMatrix();
116 /******************************************************************************/