Game Development Reference
In-Depth Information
int i;
Vector vtmp;
Stalling = false;
for(i=0; i<7; i++) // loop through the seven lifting elements
// skipping the fuselage
if (i == 6) // The tail/rudder is a special case since it can rotate;
{ // thus, you have to recalculate the normal vector.
float in, di;
in = DegreesToRadians(Element[i].fIncidence); // incidence angle
di = DegreesToRadians(Element[i].fDihedral); // dihedral angle
Element[i].vNormal = Vector( (float)sin(in),
// Calculate local velocity at element
// The local velocity includes the velocity due to linear
// motion of the airplane,
// plus the velocity at each element due to the
// rotation of the airplane.
// Here's the rotational part
vtmp = Airplane.vAngularVelocity^Element[i].vCGCoords;
vLocalVelocity = Airplane.vVelocityBody + vtmp;
// Calculate local air speed
fLocalSpeed = vLocalVelocity.Magnitude();
// Find the direction in which drag will act.
// Drag always acts inline with the relative
// velocity but in the opposing direction
if(fLocalSpeed > 1.)
vDragVector = -vLocalVelocity/fLocalSpeed;
// Find the direction in which lift will act.
// Lift is always perpendicular to the drag vector
vLiftVector = (vDragVector^Element[i].vNormal)^vDragVector;
tmp = vLiftVector.Magnitude();
// Find the angle of attack.
// The attack angle is the angle between the lift vector and the
// element normal vector. Note, the sine of the attack angle
// is equal to the cosine of the angle between the drag vector and
// the normal vector.
tmp = vDragVector*Element[i].vNormal;
if(tmp > 1.) tmp = 1;
Search Nedrilad ::

Custom Search