Game Development Reference
In-Depth Information
public double getDensity() {
return density;
}
public double getTemperature() {
return temperature;
}
// This method computes atmospheric density,
// pressure, and temperature based on the U.S.
// Standard Atmosphere 1976 model.
public void updateConditions(double altitude) {
double slope; // Slope of the temperature line
double T0; // Reference temperature value
double p0; // Reference pressure value
double h0; // Reference altitude
double geoAltitude; // Geopotential altitude
double grp; // Temporary variable
double grp2; // Temporary variable
// The 1976 U.S. Standard Atmosphere model equations
// are functions of geopotential altitude, so we
// need to compute it. Geopotential altitude is an
// equivalent altitude assuming gravity is constant
// with altitude.
geoAltitude = altitude*RE/(altitude + RE);
// Assign values to the reference temperature,
// pressure, and altitude based on the current
// altitude.
if (geoAltitude <= 11000.0) {
slope = -0.0065;
T0 = 288.15;
p0 = 101325.0;
h0 = 0.0;
}
else if (geoAltitude < 20000.0) {
slope = 0.0;
T0 = 216.65;
p0 = 22631.9;
h0 = 11000.0;
}
Search WWH ::




Custom Search