]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Wing.hpp
Wire up a "gear-ratio" attribute for geared propeller aircraft
[flightgear.git] / src / FDM / YASim / Wing.hpp
1 #ifndef _WING_HPP
2 #define _WING_HPP
3
4 #include "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 setTwist(float angle);
31     void setCamber(float camber);
32     void setIncidence(float incidence);
33     void setInducedDrag(float drag) { _inducedDrag = drag; }
34     
35     void setFlap0(float start, float end, float lift, float drag);
36     void setFlap1(float start, float end, float lift, float drag);
37     void setSpoiler(float start, float end, float lift, float drag);
38     void setSlat(float start, float end, float aoa, float drag);
39
40     // Set the control axes for the sub-surfaces
41     void setFlap0(float lval, float rval);
42     void setFlap1(float lval, float rval);
43     void setSpoiler(float lval, float rval);
44     void setSlat(float val);
45
46     // Compile the thing into a bunch of Surface objects
47     void compile();
48
49     void getTip(float* tip);
50
51     bool isMirrored();
52
53     // Ground effect information
54     float getGroundEffect(float* posOut);
55     
56     // Query the list of Surface objects
57     int numSurfaces();
58     Surface* getSurface(int n);
59     float getSurfaceWeight(int n);
60
61     // The overall drag coefficient for the wing as a whole.  Units are
62     // arbitrary.
63     void setDragScale(float scale);
64     float getDragScale();
65
66     // The ratio of force along the Z (lift) direction of each wing
67     // segment to that along the X (drag) direction.
68     void setLiftRatio(float ratio);
69     float getLiftRatio();
70
71 private:
72     void interp(float* v1, float* v2, float frac, float* out);
73     Surface* newSurface(float* pos, float* orient, float chord,
74                         bool flap0, bool flap1, bool slat, bool spoiler);
75
76     struct SurfRec { Surface * surface; float weight; };
77
78     Vector _surfs;
79     Vector _flap0Surfs;
80     Vector _flap1Surfs;
81     Vector _slatSurfs;
82     Vector _spoilerSurfs;
83
84     bool _mirror;
85
86     float _base[3];
87     float _length;
88     float _chord;
89     float _taper;
90     float _sweep;
91     float _dihedral;
92
93     float _stall;
94     float _stallWidth;
95     float _stallPeak;
96     float _twist;
97     float _camber;
98     float _incidence;
99     float _inducedDrag;
100
101     float _dragScale;
102     float _liftRatio;
103
104     float _flap0Start;
105     float _flap0End;
106     float _flap0Lift;
107     float _flap0Drag;
108
109     float _flap1Start;
110     float _flap1End;
111     float _flap1Lift;
112     float _flap1Drag;
113
114     float _spoilerStart;
115     float _spoilerEnd;
116     float _spoilerLift;
117     float _spoilerDrag;
118
119     float _slatStart;
120     float _slatEnd;
121     float _slatAoA;
122     float _slatDrag;
123 };
124
125 }; // namespace yasim
126 #endif // _WING_HPP