]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Surface.cpp
Add support for a turbo prop condition lever.
[flightgear.git] / src / FDM / YASim / Surface.cpp
index e03fb047cff987a6fa1b58efd18b8359c9db58af..77349b7683d562432e4d95c7e74cdb037898d782 100644 (file)
@@ -20,6 +20,7 @@ Surface::Surface()
     
     _chord = 0;
     _incidence = 0;
+    _twist = 0;
     _slatPos = _spoilerPos = _flapPos = 0;
     _slatDrag = _spoilerDrag = _flapDrag = 1;
 
@@ -103,6 +104,11 @@ void Surface::setIncidence(float angle)
     _incidence = angle;
 }
 
+void Surface::setTwist(float angle)
+{
+    _twist = angle;
+}
+
 void Surface::setSlatParams(float stallDelta, float dragPenalty)
 {
     _slatAlpha = stallDelta;
@@ -160,7 +166,8 @@ void Surface::calcForce(float* v, float rho, float* out, float* torque)
     // "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.
@@ -195,13 +202,12 @@ void Surface::calcForce(float* v, float rho, float* out, float* torque)
     out[1] *= _cy;
 
     // Diddle the induced drag
-    float IDMUL = 0.5;
     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);