]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGLGear.cpp
5/26/2000 updated from Jon and Tony.
[flightgear.git] / src / FDM / JSBSim / FGLGear.cpp
1 /*******************************************************************************
2
3  Module:       FGLGear.cpp
4  Author:       Jon S. Berndt
5  Date started: 11/18/99
6  Purpose:      Encapsulates the landing gear elements
7  Called by:    FGAircraft
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
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
14  version.
15
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
19  details.
20
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.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30
31 HISTORY
32 --------------------------------------------------------------------------------
33 11/18/99   JSB   Created
34
35 ********************************************************************************
36 INCLUDES
37 *******************************************************************************/
38
39 #include "FGLGear.h"
40 #include <algorithm>
41
42 /*******************************************************************************
43 ************************************ CODE **************************************
44 *******************************************************************************/
45
46
47 FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
48                                                            vMoment(3),
49                                                            Exec(fdmex)
50 {
51   string tmp;
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();
58   
59   WOW = false;
60 }
61
62
63 /******************************************************************************/
64
65 FGLGear::~FGLGear(void)
66 {
67 }
68
69 /******************************************************************************/
70
71 FGColumnVector FGLGear::Force(void)
72 {
73   static FGColumnVector vForce(3);
74   static FGColumnVector vLocalForce(3);
75   static FGColumnVector vLocalGear(3);
76   static FGColumnVector vWhlBodyVec(3);
77   static FGColumnVector vWhlVelVec(3);
78
79   vWhlBodyVec     = vXYZ - Aircraft->GetXYZcg();
80   vWhlBodyVec(eX) = -vWhlBodyVec(eX);
81   vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
82   vWhlBodyVec     = vWhlBodyVec/12.0;
83
84   vLocalGear = State->GetTb2l() * vWhlBodyVec;
85
86   compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
87
88   if (compressLength > 0.00) {
89
90     WOW = true;
91
92     vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
93     compressSpeed = vWhlVelVec(eZ) + Position->GetVd();
94
95     vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
96
97     vForce = State->GetTl2b() * vLocalForce ;
98
99     // currently only aircraft body axis Z-force modeled
100     vMoment(eX) = vForce(eZ) * vWhlBodyVec(eY);
101     vMoment(eY) = -vForce(eZ) * vWhlBodyVec(eX);
102     vMoment(eZ) = 0.0;
103
104   } else {
105
106     WOW = false;
107     vForce.InitMatrix();
108     vMoment.InitMatrix();
109   }
110
111
112   return vForce;
113 }
114
115 /******************************************************************************/
116