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