]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Gear.hpp
Maik JUSTUS: (OK'ed by Andy)
[flightgear.git] / src / FDM / YASim / Gear.hpp
1 #ifndef _GEAR_HPP
2 #define _GEAR_HPP
3
4 class SGMaterial;
5
6 namespace yasim {
7
8 class RigidBody;
9 struct State;
10
11 // A landing gear has the following parameters:
12 //
13 // position: a point in the aircraft's local coordinate system where the
14 //     fully-extended wheel will be found.
15 // compression: a vector from position where a fully-compressed wheel
16 //     will be, also in aircraft-local coordinates.
17 // spring coefficient: force coefficient along the compression axis, in
18 //     Newtons per meter.
19 // damping coefficient: force per compression speed, in Ns/m
20 // static coefficient of friction: force along the ground plane exerted
21 //     by a motionless wheel.  A unitless scalar.
22 // dynamic coefficient of friction: force along the ground plane exerted
23 //     by a sliding/skidding wheel.
24 // braking fraction: fraction of the dynamic friction that will be
25 //     actually exerted by a rolling wheel
26 // rotation: the angle from "forward" by which the wheel is rotated
27 //     around its compression axis.  In radians.
28 //
29 class Gear {
30 public:
31     Gear();
32
33     // Externally set values
34     void setPosition(float* position);
35     void setCompression(float* compression);
36     void setSpring(float spring);
37     void setDamping(float damping);
38     void setStaticFriction(float sfric);
39     void setDynamicFriction(float dfric);
40     void setBrake(float brake);
41     void setRotation(float rotation);
42     void setExtension(float extension);
43     void setCastering(bool castering);
44     void setOnWater(bool c);
45     void setOnSolid(bool c);
46     void setSpringFactorNotPlaning(float f);
47     void setSpeedPlaning(float s);
48     void setReduceFrictionByExtension(float s);
49     void setInitialLoad(float l);
50     void setIgnoreWhileSolving(bool c);
51     void setGlobalGround(double* global_ground, float* global_vel,
52         double globalX, double globalY,
53         int type, const SGMaterial *material);
54     void getPosition(float* out);
55     void getCompression(float* out);
56     void getGlobalGround(double* global_ground);
57     float getSpring();
58     float getDamping();
59     float getStaticFriction();
60     float getDynamicFriction();
61     float getBrake();
62     float getRotation();
63     float getExtension();
64     float getInitialLoad() {return _initialLoad; }
65     bool getCastering();
66     float getCasterAngle() { return _casterAngle; }
67     float getRollSpeed() { return _rollSpeed; }
68     float getBumpAltitude();
69     bool getGroundIsSolid();
70
71     // Takes a velocity of the aircraft relative to ground, a rotation
72     // vector, and a ground plane (all specified in local coordinates)
73     // and make a force and point of application (i.e. ground contact)
74     // available via getForce().
75     void calcForce(RigidBody* body, State* s, float* v, float* rot);
76
77     // Computed values: total force, weight-on-wheels (force normal to
78     // ground) and compression fraction.
79     void getForce(float* force, float* contact);
80     float getWoW();
81     float getCompressFraction();
82     float getCompressDist() { return _compressDist; }
83     bool getSubmergable() {return (!_ground_isSolid)&&(!_isContactPoint); }
84     bool getIgnoreWhileSolving() {return _ignoreWhileSolving; }
85     void setContactPoint(bool c);
86
87 private:
88     float calcFriction(float wgt, float v);
89     float calcFrictionFluid(float wgt, float v);
90
91     bool _castering;
92     float _pos[3];
93     float _cmpr[3];
94     float _spring;
95     float _damp;
96     float _sfric;
97     float _dfric;
98     float _brake;
99     float _rot;
100     float _extension;
101     float _force[3];
102     float _contact[3];
103     float _wow;
104     float _frac;
105     float _initialLoad;
106     float _compressDist;
107     double _global_ground[4];
108     float _global_vel[3];
109     float _casterAngle;
110     float _rollSpeed;
111     bool _isContactPoint;
112     bool _onWater;
113     bool _onSolid;
114     float _spring_factor_not_planing;
115     float _speed_planing;
116     float _reduceFrictionByExtension;
117     bool _ignoreWhileSolving;
118
119     int _ground_type;
120     double _ground_frictionFactor;
121     double _ground_rollingFriction;
122     double _ground_loadCapacity;
123     double _ground_loadResistance;
124     double _ground_bumpiness;
125     bool _ground_isSolid;
126     double _global_x;
127     double _global_y;
128 };
129
130 }; // namespace yasim
131 #endif // _GEAR_HPP