_chord = 0;
_incidence = 0;
+ _twist = 0;
_slatPos = _spoilerPos = _flapPos = 0;
_slatDrag = _spoilerDrag = _flapDrag = 1;
_flapLift = 0;
_slatAlpha = 0;
_spoilerLift = 1;
+ _inducedDrag = 1;
}
void Surface::setPosition(float* p)
_incidence = angle;
}
+void Surface::setTwist(float angle)
+{
+ _twist = angle;
+}
+
void Surface::setSlatParams(float stallDelta, float dragPenalty)
{
_slatAlpha = stallDelta;
// Handle the blowup condition. Zero velocity means zero force by
// definition.
if(vel == 0) {
- int i;
+ int i;
for(i=0; i<3; i++) out[i] = torque[i] = 0;
return;
}
// "Rotate" by the incidence angle. Assume small angles, so we
// need to diddle only the Z component, X is relatively unchanged
// by small rotations.
- out[2] += _incidence * out[0]; // z' = z + incidence * x
+ float incidence = _incidence + _twist;
+ out[2] += incidence * out[0]; // z' = z + incidence * x
+ // Hold onto the local wind vector so we can multiply the induced
+ // drag at the end.
+ float lwind[3];
+ Math::set3(out, lwind);
+
// Diddle the Z force according to our configuration
float stallMul = stallFunc(out);
stallMul *= 1 + _spoilerPos * (_spoilerLift - 1);
// Add in any specific Y (side force) coefficient.
out[1] *= _cy;
+ // Diddle the induced drag
+ Math::mul3(-1*_inducedDrag*out[2]*lwind[2], lwind, lwind);
+ Math::add3(lwind, out, out);
+
// Reverse the incidence rotation to get back to surface
// coordinates.
- out[2] -= _incidence * out[0];
+ out[2] -= incidence * out[0];
// Convert back to external coordinates
Math::tmul33(_orient, out, out);