Game Development Reference
In-Depth Information
else {
temperature = T0 + slope*(geoAltitude - h0);
grp = T0/temperature;
grp2 = G/(slope*R);
pressure = p0*Math.pow(grp,grp2);
}
density = pressure/(R*temperature);
return;
}
}
The USatm76 class computes the pressure, density, and temperature for a given altitude
by curve fit relations between seven known data points. An exponential equation is used to
compute the pressure. Temperature is calculated by drawing straight lines between the known
data point temperature values. The code contained in the USatm76 class can be useful for other
game programming situations as well. You could, for example, make use of the USatm76 class in
a high-altitude airplane flight simulator.
Gravity
For the other physical models we have created in earlier chapters of this topic, gravitational
acceleration has been a nice, dependable constant. It could be assumed to be constant because
the altitude changes of the projectiles, balls, cars, boats, and planes were small relative to the
radius of the earth. This situation is not necessarily the case when dealing with rockets, as they
can travel hundreds, thousands, or even millions of kilometers away from the earth.
The gravitational acceleration due to the earth is proportional to the square of the distance
from the center of the earth. The acceleration at a given altitude above the surface of the earth
is equal to the acceleration at the surface multiplied by the ratio of the square of the distances.
2
r
g
=
9.81
e
(11.13)
(
)
2
rh
+
e
The quantity h is the altitude above the surface of the earth. The radius of the earth, r e , is
equal to 6356.8 km . Figure 11-4 shows the change in gravitational acceleration with increasing
altitude from the surface of the earth. For the range of altitudes shown in Figure 11-4, the grav-
itational acceleration curve as a function of altitude is nearly a straight line. At an altitude of
100 km , the acceleration is 9.51 m/s 2 . At an altitude of 400 km , the gravitational acceleration has
decreased to 8.68 m/s 2 .
Search WWH ::




Custom Search