]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Gear.hpp
latest updates from JSBSim
[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         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     float getGroundFrictionFactor() { return (float)_ground_frictionFactor; }
71
72     // Takes a velocity of the aircraft relative to ground, a rotation
73     // vector, and a ground plane (all specified in local coordinates)
74     // and make a force and point of application (i.e. ground contact)
75     // available via getForce().
76     void calcForce(RigidBody* body, State* s, float* v, float* rot);
77
78     // Computed values: total force, weight-on-wheels (force normal to
79     // ground) and compression fraction.
80     void getForce(float* force, float* contact);
81     float getWoW();
82     float getCompressFraction();
83     float getCompressDist() { return _compressDist; }
84     bool getSubmergable() {return (!_ground_isSolid)&&(!_isContactPoint); }
85     bool getIgnoreWhileSolving() {return _ignoreWhileSolving; }
86     void setContactPoint(bool c);
87
88 private:
89     float calcFriction(float wgt, float v);
90     float calcFrictionFluid(float wgt, float v);
91
92     bool _castering;
93     float _pos[3];
94     float _cmpr[3];
95     float _spring;
96     float _damp;
97     float _sfric;
98     float _dfric;
99     float _brake;
100     float _rot;
101     float _extension;
102     float _force[3];
103     float _contact[3];
104     float _wow;
105     float _frac;
106     float _initialLoad;
107     float _compressDist;
108     double _global_ground[4];
109     float _global_vel[3];
110     float _casterAngle;
111     float _rollSpeed;
112     bool _isContactPoint;
113     bool _onWater;
114     bool _onSolid;
115     float _spring_factor_not_planing;
116     float _speed_planing;
117     float _reduceFrictionByExtension;
118     bool _ignoreWhileSolving;
119
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