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