1
0
Fork 0

YASIM: method name clarification (and indention)

This commit is contained in:
Henning Stahlke 2017-11-19 16:11:57 +01:00
parent 0e6552cddf
commit fb6f965db7
4 changed files with 33 additions and 28 deletions

View file

@ -787,35 +787,35 @@ void Airplane::applyDragFactor(float factor)
float applied = Math::pow(factor, SOLVE_TWEAK); float applied = Math::pow(factor, SOLVE_TWEAK);
_dragFactor *= applied; _dragFactor *= applied;
if(_wing) if(_wing)
_wing->setDragScale(_wing->getDragScale() * applied); _wing->multiplyDragCoefficient(applied);
if(_tail) if(_tail)
_tail->setDragScale(_tail->getDragScale() * applied); _tail->multiplyDragCoefficient(applied);
int i; int i;
for(i=0; i<_vstabs.size(); i++) { for(i=0; i<_vstabs.size(); i++) {
Wing* w = (Wing*)_vstabs.get(i); Wing* w = (Wing*)_vstabs.get(i);
w->setDragScale(w->getDragScale() * applied); w->multiplyDragCoefficient(applied);
} }
for(i=0; i<_fuselages.size(); i++) { for(i=0; i<_fuselages.size(); i++) {
Fuselage* f = (Fuselage*)_fuselages.get(i); Fuselage* f = (Fuselage*)_fuselages.get(i);
int j; int j;
for(j=0; j<f->surfs.size(); j++) { for(j=0; j<f->surfs.size(); j++) {
Surface* s = (Surface*)f->surfs.get(j); Surface* s = (Surface*)f->surfs.get(j);
if( isVersionOrNewer( YASIM_VERSION_32 ) ) { if( isVersionOrNewer( YASIM_VERSION_32 ) ) {
// For new YASim, the solver drag factor is only applied to // For new YASim, the solver drag factor is only applied to
// the X axis for Fuselage Surfaces. // the X axis for Fuselage Surfaces.
// The solver is tuning the coefficient for longitudinal drag, // The solver is tuning the coefficient for longitudinal drag,
// along the direction of flight. A fuselage's lateral drag // along the direction of flight. A fuselage's lateral drag
// is completely independent and is normally much higher; // is completely independent and is normally much higher;
// it won't be affected by the streamlining done to reduce // it won't be affected by the streamlining done to reduce
// longitudinal drag. So the solver should only adjust the // longitudinal drag. So the solver should only adjust the
// fuselage's longitudinal (X axis) drag coefficient. // fuselage's longitudinal (X axis) drag coefficient.
s->setXDrag(s->getXDrag() * applied); s->setXDrag(s->getXDrag() * applied);
} else { } else {
// Originally YASim applied the drag factor to all axes // Originally YASim applied the drag factor to all axes
// for Fuselage Surfaces. // for Fuselage Surfaces.
s->setDragCoefficient(s->getDragCoefficient() * applied); s->setDragCoefficient(s->getDragCoefficient() * applied);
} }
} }
} }
for(i=0; i<_weights.size(); i++) { for(i=0; i<_weights.size(); i++) {
WeightRec* wr = (WeightRec*)_weights.get(i); WeightRec* wr = (WeightRec*)_weights.get(i);

View file

@ -853,7 +853,7 @@ Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
w->setInducedDrag(0.7*attrf(a, "idrag", 1)); w->setInducedDrag(0.7*attrf(a, "idrag", 1));
float effect = attrf(a, "effectiveness", 1); float effect = attrf(a, "effectiveness", 1);
w->setDragScale(w->getDragScale()*effect); w->multiplyDragCoefficient(effect);
_currObj = w; _currObj = w;
return w; return w;

View file

@ -253,7 +253,7 @@ void Wing::addSurface(Surface* s, float weight, float twist)
_surfs.add(sr); _surfs.add(sr);
} }
void Wing::setDragScale(float scale) void Wing::setDragCoefficient(float scale)
{ {
_dragScale = scale; _dragScale = scale;
for(int i=0; i<_surfs.size(); i++) { for(int i=0; i<_surfs.size(); i++) {
@ -262,6 +262,11 @@ void Wing::setDragScale(float scale)
} }
} }
void Wing::multiplyDragCoefficient(float factor)
{
setDragCoefficient(_dragScale * factor);
}
void Wing::setLiftRatio(float ratio) void Wing::setLiftRatio(float ratio)
{ {
_liftRatio = ratio; _liftRatio = ratio;

View file

@ -90,8 +90,8 @@ public:
// The overall drag coefficient for the wing as a whole. Units are // The overall drag coefficient for the wing as a whole. Units are
// arbitrary. // arbitrary.
void setDragScale(float scale); void setDragCoefficient(float scale);
float getDragScale() const { return _dragScale; } void multiplyDragCoefficient(float factor);
// The ratio of force along the Z (lift) direction of each wing // The ratio of force along the Z (lift) direction of each wing
// segment to that along the X (drag) direction. // segment to that along the X (drag) direction.