]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Wing.hpp
Initial revision of Andy Ross's YASim code. This is (Y)et (A)nother Flight
[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     // Query the list of Surface objects
48     int numSurfaces();
49     Surface* getSurface(int n);
50     float getSurfaceWeight(int n);
51
52     // The overall drag coefficient for the wing as a whole.  Units are
53     // arbitrary.
54     void setDragScale(float scale);
55     float getDragScale();
56
57     // The ratio of force along the Z (lift) direction of each wing
58     // segment to that along the X (drag) direction.
59     void setLiftRatio(float ratio);
60     float getLiftRatio();
61
62 private:
63     void interp(float* v1, float* v2, float frac, float* out);
64     Surface* newSurface(float* pos, float* orient, float chord,
65                         bool flap0, bool flap1, bool slat, bool spoiler);
66
67     struct SurfRec { Surface * surface; float weight; };
68
69     Vector _surfs;
70     Vector _flap0Surfs;
71     Vector _flap1Surfs;
72     Vector _slatSurfs;
73     Vector _spoilerSurfs;
74
75     bool _mirror;
76
77     float _base[3];
78     float _length;
79     float _chord;
80     float _taper;
81     float _sweep;
82     float _dihedral;
83
84     float _stall;
85     float _stallWidth;
86     float _stallPeak;
87     float _camber;
88     float _incidence;
89
90     float _dragScale;
91     float _liftRatio;
92
93     float _flap0Start;
94     float _flap0End;
95     float _flap0Lift;
96     float _flap0Drag;
97
98     float _flap1Start;
99     float _flap1End;
100     float _flap1Lift;
101     float _flap1Drag;
102
103     float _spoilerStart;
104     float _spoilerEnd;
105     float _spoilerLift;
106     float _spoilerDrag;
107
108     float _slatStart;
109     float _slatEnd;
110     float _slatAoA;
111     float _slatDrag;
112 };
113
114 }; // namespace yasim
115 #endif // _WING_HPP