Game Development Reference
In-Depth Information
// Calculate the vector normal (perpendicular) to each lifting surface.
// This is required when you are calculating the relative air velocity for
// lift and drag calculations.
for (i = 0; i< 8; i++)
{
in = DegreesToRadians(Element[i].fIncidence);
di = DegreesToRadians(Element[i].fDihedral);
Element[i].vNormal = Vector((float)sin(in), (float)(cos(in)*sin(di)),
(float)(cos(in)*cos(di)));
Element[i].vNormal.Normalize();
}
// Calculate total mass
mass = 0;
for (i = 0; i< 8; i++)
mass += Element[i].fMass;
// Calculate combined center of gravity location
vMoment = Vector(0.0f, 0.0f, 0.0f);
for (i = 0; i< 8; i++)
{
vMoment += Element[i].fMass*Element[i].vDCoords;
}
CG = vMoment/mass;
// Calculate coordinates of each element with respect to the combined CG
for (i = 0; i< 8; i++)
{
Element[i].vCGCoords = Element[i].vDCoords − CG;
}
// Now calculate the moments and products of inertia for the
// combined elements.
// (This inertia matrix (tensor) is in body coordinates)
Ixx = 0; Iyy = 0; Izz = 0;
Ixy = 0; Ixz = 0; Iyz = 0;
for (i = 0; i< 8; i++)
{
Ixx += Element[i].vLocalInertia.x + Element[i].fMass *
(Element[i].vCGCoords.y*Element[i].vCGCoords.y +
Element[i].vCGCoords.z*Element[i].vCGCoords.z);
Iyy += Element[i].vLocalInertia.y + Element[i].fMass *
(Element[i].vCGCoords.z*Element[i].vCGCoords.z +
Element[i].vCGCoords.x*Element[i].vCGCoords.x);
Izz += Element[i].vLocalInertia.z + Element[i].fMass *
(Element[i].vCGCoords.x*Element[i].vCGCoords.x +
Element[i].vCGCoords.y*Element[i].vCGCoords.y);
Ixy += Element[i].fMass * (Element[i].vCGCoords.x *
Element[i].vCGCoords.y);
Ixz += Element[i].fMass * (Element[i].vCGCoords.x *
Element[i].vCGCoords.z);
Search Nedrilad ::




Custom Search