]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Wing.hpp
b448f83fa018d3426b6e761bc945ab965592c665
[flightgear.git] / src / FDM / YASim / Wing.hpp
1 #ifndef _WING_HPP
2 #define _WING_HPP
3
4 #include "util/Vector.hpp"
5
6 namespace yasim {
7
8 class Surface;
9
10 // FIXME: need to handle "inverted" controls for mirrored wings.
11 class Wing {
12 public:
13     Wing();
14     ~Wing();
15
16     // Do we mirror ourselves about the XZ plane?
17     void setMirror(bool mirror);
18
19     // Wing geometry:
20     void setBase(float* base);        // in local coordinates
21     void setLength(float length);     // dist. ALONG wing (not span!)     
22     void setChord(float chord);       // at base, measured along X axis
23     void setTaper(float taper);       // fraction, 0-1
24     void setSweep(float sweep);       // radians
25     void setDihedral(float dihedral); // radians, positive is "up"
26
27     void setStall(float aoa);
28     void setStallWidth(float angle);
29     void setStallPeak(float fraction);
30     void setCamber(float camber);
31     void setIncidence(float incidence);
32     
33     void setFlap0(float start, float end, float lift, float drag);
34     void setFlap1(float start, float end, float lift, float drag);
35     void setSpoiler(float start, float end, float lift, float drag);
36     void setSlat(float start, float end, float aoa, float drag);
37
38     // Set the control axes for the sub-surfaces
39     void setFlap0(float lval, float rval);
40     void setFlap1(float lval, float rval);
41     void setSpoiler(float lval, float rval);
42     void setSlat(float val);
43
44     // Compile the thing into a bunch of Surface objects
45     void compile();
46
47     // Ground effect information
48     float getGroundEffect(float* posOut);
49     
50     // Query the list of Surface objects
51     int numSurfaces();
52     Surface* getSurface(int n);
53     float getSurfaceWeight(int n);
54
55     // The overall drag coefficient for the wing as a whole.  Units are
56     // arbitrary.
57     void setDragScale(float scale);
58     float getDragScale();
59
60     // The ratio of force along the Z (lift) direction of each wing
61     // segment to that along the X (drag) direction.
62     void setLiftRatio(float ratio);
63     float getLiftRatio();
64
65 private:
66     void interp(float* v1, float* v2, float frac, float* out);
67     Surface* newSurface(float* pos, float* orient, float chord,
68                         bool flap0, bool flap1, bool slat, bool spoiler);
69
70     struct SurfRec { Surface * surface; float weight; };
71
72     Vector _surfs;
73     Vector _flap0Surfs;
74     Vector _flap1Surfs;
75     Vector _slatSurfs;
76     Vector _spoilerSurfs;
77
78     bool _mirror;
79
80     float _base[3];
81     float _length;
82     float _chord;
83     float _taper;
84     float _sweep;
85     float _dihedral;
86
87     float _stall;
88     float _stallWidth;
89     float _stallPeak;
90     float _camber;
91     float _incidence;
92
93     float _dragScale;
94     float _liftRatio;
95
96     float _flap0Start;
97     float _flap0End;
98     float _flap0Lift;
99     float _flap0Drag;
100
101     float _flap1Start;
102     float _flap1End;
103     float _flap1Lift;
104     float _flap1Drag;
105
106     float _spoilerStart;
107     float _spoilerEnd;
108     float _spoilerLift;
109     float _spoilerDrag;
110
111     float _slatStart;
112     float _slatEnd;
113     float _slatAoA;
114     float _slatDrag;
115 };
116
117 }; // namespace yasim
118 #endif // _WING_HPP