]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Gear.hpp
Initial revision of Andy Ross's YASim code. This is (Y)et (A)nother Flight
[flightgear.git] / src / FDM / YASim / Gear.hpp
1 #ifndef _GEAR_HPP
2 #define _GEAR_HPP
3
4 namespace yasim {
5
6 class RigidBody;
7
8 // A landing gear has the following parameters:
9 //
10 // position: a point in the aircraft's local coordinate system where the
11 //     fully-extended wheel will be found.
12 // compression: a vector from position where a fully-compressed wheel
13 //     will be, also in aircraft-local coordinates.
14 // spring coefficient: force coefficient along the compression axis, in
15 //     Newtons per meter.
16 // damping coefficient: force per compression speed, in Ns/m
17 // static coefficient of friction: force along the ground plane exerted
18 //     by a motionless wheel.  A unitless scalar.
19 // dynamic coefficient of friction: force along the ground plane exerted
20 //     by a sliding/skidding wheel.
21 // braking fraction: fraction of the dynamic friction that will be
22 //     actually exerted by a rolling wheel
23 // rotation: the angle from "forward" by which the wheel is rotated
24 //     around its compression axis.  In radians.
25 //
26 class Gear {
27 public:
28     Gear();
29
30     // Externally set values
31     void setPosition(float* position);
32     void setCompression(float* compression);
33     void setSpring(float spring);
34     void setDamping(float damping);
35     void setStaticFriction(float sfric);
36     void setDynamicFriction(float dfric);
37     void setBrake(float brake);
38     void setRotation(float rotation);
39     void setExtension(float extension);
40     
41     void getPosition(float* out);
42     void getCompression(float* out);
43     float getSpring();
44     float getDamping();
45     float getStaticFriction();
46     float getDynamicFriction();
47     float getBrake();
48     float getRotation();
49     float getExtension();
50
51     // Takes a velocity of the aircraft relative to ground, a rotation
52     // vector, and a ground plane (all specified in local coordinates)
53     // and make a force and point of application (i.e. ground contact)
54     // available via getForce().
55     void calcForce(RigidBody* body, float* v, float* rot, float* ground);
56
57     // Computed values: total force, weight-on-wheels (force normal to
58     // ground) and compression fraction.
59     void getForce(float* force, float* contact);
60     float getWoW();
61     float getCompressFraction();
62
63 private:
64     float calcFriction(float wgt, float v);
65
66     float _pos[3];
67     float _cmpr[3];
68     float _spring;
69     float _damp;
70     float _sfric;
71     float _dfric;
72     float _brake;
73     float _rot;
74     float _extension;
75     float _force[3];
76     float _contact[3];
77     float _wow;
78     float _frac;
79 };
80
81 }; // namespace yasim
82 #endif // _GEAR_HPP