Game Development Reference
In-Depth Information
After calculating the thrust vector, the function loops over the model elements to cal‐
culate the lift and drag forces on each element. We've skipped the fuselage in this model;
however, if you want to account for its drag in your model, this is the place to add the
drag calculation.
Going into the loop, the first thing the function does is check to see if the current element
is element number six, the tail rudder. If it is, then the rudder's normal vector is recal‐
culated based on the current incidence angle. The incidence angle for the rudder is
altered when you press the X or C keys to apply rudder action.
The next calculation is to determine the relative velocity between the air and the element
under consideration. As we stated earlier, this relative velocity consists of the linear
velocity as the airplane moves through the air plus the velocity of each element due to
the airplane's rotation. Once you've obtained this vector, you calculate the relative air
speed by taking the magnitude of the relative velocity vector.
The next step is to determine the direction in which drag will act. Since drag opposes
motion, it acts inline with, but opposite to, the relative velocity vector; thus, all you need
to do is take the negative of the relative velocity vector and normalize the result (divide
it by its magnitude) to obtain the drag direction vector. Since this vector was normalized,
its length is equal to 1 (unity), so you can multiply it by the drag force that will be
calculated later to get the drag force vector.
After obtaining the drag direction vector, this function uses it to determine the lift
direction vector. The lift force vector is always perpendicular to the drag force vector,
so to calculate its direction you first take the cross product of the drag direction vector
with the element normal vector and then cross the result with the drag direction vector
again. Here again, the function normalizes the lift direction vector.
Now that the lift and drag direction vectors have been obtained, the function proceeds
to calculate the angle of attack for the current element. The attack angle is the angle
between the lift vector and the element normal. You can calculate the angle by taking
the inverse cosine of the vector dot product of the lift direction vector with the element
normal vector. Since the drag vector is perpendicular to the lift vector, you can get the
same result by taking the inverse sine of the vector dot product of the drag direction
vector with the element normal vector.
Now with all the lift and drag vector stuff out of the way, the function goes on to calculate
the resultant force acting on the element. The resultant force vector is simply the vector
sum of the lift and drag force vectors. Notice that this is where the lift and drag coefficient
functions are called and where the empirical lift and drag formulas previously discussed
are applied.
After calculating the resultant force, the function checks to see if the calculated lift
coefficient is 0. If it is, then the stall flag is set to warn us that the plane is in a stalled
situation.
Search Nedrilad ::




Custom Search