Game Development Reference
In-Depth Information
The SimpleRocket class declares a getRightHandSide method to compute the right-hand
sides of the 10 ODEs that define the equations of motion for the rocket. The first part of the
method proceeds as all of the other versions do, namely that intermediate values of the depen-
dent variables are computed and some convenience variables are declared.
public double[] getRightHandSide(double s, double q[],
double deltaQ[], double ds,
double qScale) {
double dQ[] = new double[10];
double newQ[] = new double[10];
// Compute the intermediate values of the
// location and velocity components.
for(int i=0; i<10; ++i) {
newQ[i] = q[i] + qScale*deltaQ[i];
}
// Assign convenenience variables to the intermediate
// values of the locations and velocities.
double vx = newQ[0];
double vy = newQ[2];
double vz = newQ[4];
double vtotal = Math.sqrt(vx*vx + vy*vy + vz*vz);
double x = newQ[1];
double y = newQ[3];
double z = newQ[5];
double massFlowRate = newQ[6];
double mass = newQ[7];
double omega = newQ[8];
double theta = newQ[9];
The USatm76 object is used to compute the pressure and density at the current altitude.
// Update the values of pressure, density, and
// temperature based on the current altitude.
air.updateConditions(z);
double pressure = air.getPressure();
double density = air.getDensity();
The thrust force for the rocket is determined according to Equation (11.12). The total thrust
generated by the rocket is equal to the thrust generated by each engine multiplied by the
number of engines.
// Compute the thrust per engine and total thrust.
double pressureRatio = pressure/101325.0;
double thrustPerEngine = vacuumThrustPerEngine -
(vacuumThrustPerEngine - seaLevelThrustPerEngine)*pressureRatio;
double thrust = numberOfEngines*thrustPerEngine;
The drag force is computed based on the frontal area of the rocket and Equation (11.14).
Search WWH ::




Custom Search