Debian Codegraph @

src/FDM/JSBSim/models/FGSurface.cpp

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGSurface.cpp
4 Author: Erik Hofman
5 Date started: 01/15/14
6 Purpose: Base class for all surface properties
7 Called by: GroundReactions
8
9 ------------- Copyright (C) 2014 Jon S. Berndt ([email protected]) -------------
10
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU Lesser 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 Lesser General Public License for more
19 details.
20
21 You should have received a copy of the GNU Lesser 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 Lesser General Public License can also be found on
26 the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This base class for the GroundReactions class defines methoed and holds data
31 for all surface types.
32
33 HISTORY
34 --------------------------------------------------------------------------------
35 01/15/14 EMH Created
36
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "input_output/FGPropertyManager.h"
42 #include "models/FGSurface.h"
43
44 using namespace std;
45
46 namespace JSBSim {
47
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 CLASS IMPLEMENTATION
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52 FGSurface::FGSurface(FGFDMExec* fdmex)
53 {
54 resetValues();
55 }
56
57 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58
59 void FGSurface::resetValues(void)
60 {
61 staticFFactor = 1.0;
62 rollingFFactor = 1.0;
63 maximumForce = DBL_MAX;
64 bumpiness = 0.0;
65 isSolid = true;
66 pos[0] = 0.0;
67 pos[1] = 0.0;
68 pos[2] = 0.0;
69 }
70
71 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
73 void FGSurface::bind(FGPropertyManager* PropertyManager)
74 {
75 string base_property_name = "ground";
76 string property_name;
77
78 property_name = base_property_name + "/solid";
79 PropertyManager->Tie( property_name.c_str(), &isSolid);
80 property_name = base_property_name + "/bumpiness";
81 PropertyManager->Tie( property_name.c_str(), &bumpiness);
82 property_name = base_property_name + "/maximum-force-lbs";
83 PropertyManager->Tie( property_name.c_str(), &maximumForce);
84 property_name = base_property_name + "/rolling_friction-factor";
85 PropertyManager->Tie( property_name.c_str(), &rollingFFactor);
86 property_name = base_property_name + "/static-friction-factor";
87 PropertyManager->Tie( property_name.c_str(), &staticFFactor);
88 }
89
90 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91
92 float FGSurface::GetBumpHeight()
93 {
94 if (bumpiness < 0.001) return 0.0f;
95
96 double x = pos[0]*0.1;
97 double y = pos[1]*0.1;
98 x -= floor(x);
99 y -= floor(y);
100 x *= 2*M_PI;
101 y *= 2*M_PI;
102 //now x and y are in the range of 0..2pi
103 //we need a function, that is periodically on 2pi and gives some
104 //height. This is not very fast, but for a beginning.
105 //maybe this should be done by interpolating between some precalculated
106 //values
107 static const float maxGroundBumpAmplitude=0.4;
108 float h = sin(x)+sin(7*x)+sin(8*x)+sin(13*x);
109 h += sin(2*y)+sin(5*y)+sin(9*y*x)+sin(17*y);
110
111 return h*(1/8.)*bumpiness*maxGroundBumpAmplitude;
112 }
113
114 } // namespace JSBSim