1
0
Fork 0

YASim: code dedup in class Wing.

This commit is contained in:
Henning Stahlke 2017-05-04 15:18:48 +02:00
parent 6817292e73
commit caf2100b5e
2 changed files with 14 additions and 12 deletions

View file

@ -251,27 +251,19 @@ void Wing::compile()
interp(_base, _tip, frac, pos); interp(_base, _tip, frac, pos);
float chord = _chord * (1 - (1-_taper)*frac); float chord = _chord * (1 - (1-_taper)*frac);
float weight = chord * segWid;
float twist = _twist * frac;
Surface *s = newSurface(pos, _orient, chord, Surface *s = newSurface(pos, _orient, chord,
hasFlap0, hasFlap1, hasSlat, hasSpoiler); hasFlap0, hasFlap1, hasSlat, hasSpoiler);
SurfRec *sr = new SurfRec(); addSurface(s, weight, twist);
sr->surface = s;
sr->weight = chord * segWid;
s->setTotalDrag(sr->weight);
s->setTwist(_twist * frac);
_surfs.add(sr);
if(_mirror) { if(_mirror) {
pos[1] = -pos[1]; pos[1] = -pos[1];
s = newSurface(pos, _rightOrient, chord, s = newSurface(pos, _rightOrient, chord,
hasFlap0, hasFlap1, hasSlat, hasSpoiler); hasFlap0, hasFlap1, hasSlat, hasSpoiler);
sr = new SurfRec(); addSurface(s, weight, twist);
sr->surface = s;
sr->weight = chord * segWid;
s->setTotalDrag(sr->weight);
s->setTwist(_twist * frac);
_surfs.add(sr);
} }
} }
} }
@ -280,6 +272,15 @@ void Wing::compile()
setIncidence(_incidence); setIncidence(_incidence);
} }
void Wing::addSurface(Surface* s, float weight, float twist)
{
SurfRec *sr = new SurfRec();
sr->surface = s;
sr->weight = weight;
s->setTotalDrag(sr->weight);
s->setTwist(twist);
_surfs.add(sr);
}
void Wing::setDragScale(float scale) void Wing::setDragScale(float scale)
{ {

View file

@ -96,6 +96,7 @@ private:
void calculateTip(); void calculateTip();
void calculateSpan(); void calculateSpan();
void calculateMAC(); void calculateMAC();
void addSurface(Surface* s, float weight, float twist);
struct SurfRec { Surface * surface; float weight; }; struct SurfRec { Surface * surface; float weight; };