Game Development Reference
In-Depth Information
double cosP; // Climb angle
double sinP; // Climb angle
double cosT; // Heading angle
double sinT; // Heading angle
if ( vtotal == 0.0 ) {
cosP = 1.0;
sinP = 0.0;
}
else {
cosP = vh/vtotal;
sinP = vz/vtotal;
}
if ( vh == 0.0 ) {
cosT = 1.0;
sinT = 0.0;
}
else {
cosT = vx/vh;
sinT = vy/vh;
}
// Convert the thrust, drag, and lift forces into
// x-, y-, and z-components using the rotation matrix.
double Fx = cosT*cosP*(thrust - drag) +
(sinT*sinW - cosT*sinP*cosW)*lift;
double Fy = sinT*cosP*(thrust - drag) +
(-cosT*sinW - sinT*sinP*cosW)*lift;
double Fz = sinP*(thrust - drag) + cosP*cosW*lift;
// Add the gravity force to the z-direction force.
Fz = Fz + mass*G;
Once the x-, y-, and z-components of force are determined, the right-hand sides of the
ODEs that describe the motion of the airplane can be filled.
// Load the right-hand sides of the ODEs
dQ[0] = ds*(Fx/mass);
dQ[1] = ds*vx;
dQ[2] = ds*(Fy/mass);
dQ[3] = ds*vy;
dQ[4] = ds*(Fz/mass);
dQ[5] = ds*vz;
return dQ;
}
}
Search WWH ::




Custom Search