]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Surface.hpp
GUI ‘restore defaults’ support.
[flightgear.git] / src / FDM / YASim / Surface.hpp
1 #ifndef _SURFACE_HPP
2 #define _SURFACE_HPP
3
4 #include "Version.hpp"
5
6 namespace yasim {
7
8 // FIXME: need a "chord" member for calculating moments.  Generic
9 // forces act at the center, but "pre-stall" lift acts towards the
10 // front, and flaps act (in both lift and drag) toward the back.
11 class Surface
12 {
13 public:
14     Surface( Version * version );
15
16     // Position of this surface in local coords
17     void setPosition(float* p);
18     void getPosition(float* out);
19
20     // Distance scale along the X axis
21     void setChord(float chord);
22
23     // Slats act to move the stall peak by the specified angle, and
24     // increase drag by the multiplier specified.
25     void setSlatParams(float stallDelta, float dragPenalty);
26
27     // Flaps add to lift coefficient, and multiply drag.
28     void setFlapParams(float liftAdd, float dragPenalty);
29
30     // Spoilers reduce the pre-stall lift, and multiply drag.
31     void setSpoilerParams(float liftPenalty, float dragPenalty);
32
33     // Positions for the controls, in the range [0:1].  [-1:1] for
34     // flaps, with positive meaning "force goes towards positive Z"
35     void setFlap(float pos);
36     void setSlat(float pos);
37     void setSpoiler(float pos);
38
39     // Modifier for flap lift coefficient, useful for simulating flap blowing etc.
40     void setFlapEffectiveness(float effectiveness);
41         double getFlapEffectiveness();
42
43     // local -> Surface coords
44     void setOrientation(float* o);
45
46     // For variable-incidence control surfaces.  The angle is a
47     // negative rotation about the surface's Y axis, in radians, so
48     // positive is "up" (i.e. "positive AoA")
49     void setIncidence(float angle);
50
51     // The offset from base incidence for this surface.
52     void setTwist(float angle);
53
54     void setTotalDrag(float c0);
55     float getTotalDrag();
56
57     void setXDrag(float cx);
58     void setYDrag(float cy);
59     void setZDrag(float cz);
60     float getXDrag();
61
62     // zero-alpha Z drag ("camber") specified as a fraction of cz
63     void setBaseZDrag(float cz0);
64
65     // i: 0 == forward, 1 == backwards
66     void setStallPeak(int i, float peak);
67
68     // i: 0 == fwd/+z, 1 == fwd/-z, 2 == rev/+z, 3 == rev/-z
69     void setStall(int i, float alpha);
70     void setStallWidth(int i, float width);
71
72     // Induced drag multiplier
73     void setInducedDrag(float mul) { _inducedDrag = mul; }
74
75     void calcForce(float* v, float rho, float* forceOut, float* torqueOut);
76
77 private:
78     float stallFunc(float* v);
79     float flapLift(float alpha);
80     float controlDrag(float lift, float drag);
81
82     float _chord;     // X-axis size
83     float _c0;        // total force coefficient
84     float _cx;        // X-axis force coefficient
85     float _cy;        // Y-axis force coefficient
86     float _cz;        // Z-axis force coefficient
87     float _cz0;       // Z-axis force offset
88     float _peaks[2];  // Stall peak coefficients (fwd, back)
89     float _stalls[4]; // Stall angles (fwd/back, pos/neg)
90     float _widths[4]; // Stall widths  " "
91     float _pos[3];    // position in local coords
92     float _orient[9]; // local->surface orthonormal matrix
93
94     float _slatAlpha;
95     float _slatDrag;
96     float _flapLift;
97     float _flapDrag;
98     float _flapEffectiveness;
99     float _spoilerLift;
100     float _spoilerDrag;
101
102     float _slatPos;
103     float _flapPos;
104     float _spoilerPos;
105     float _incidence;
106     float _twist;
107     float _inducedDrag;
108
109     Version * _version;
110 };
111
112 }; // namespace yasim
113 #endif // _SURFACE_HPP