Game Development Reference
In-Depth Information
// Calculate propellant mass per engine.
double propellantMass = massFlowRate*burnTime;
// Estimate rocket structural mass;
double structureMass = 20000.0 + numEngines*4000.0;
// Compute initial mass of rocket.
double initialMass = numEngines*(engineMass + propellantMass) +
payloadMass + structureMass;
Initial values are set for the drag coefficient and the pitch angle. The rate of change of pitch
angle is set such that at the end of the engine burn time the pitch angle of the rocket will be 10
degrees.
// Set values for drag coefficient and pitch angle.
// The pitch angle is in radians.
double cd = 0.5;
double theta = 0.5*Math.PI;
// Set the change in pitch angle in rad/s so that at the end
// of the burn time the rocket will be at a pitch angle of 10 deg.
double omega = -80*Math.PI/(180.0*burnTime);
When all of the input parameters have been determined, a SimpleRocket object is created.
The start method is called on a Timer object to start the simulation.
// Create a SimpleRocket object.
rocket = new SimpleRocket(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
initialMass, massFlowRate, numEngines,
seaLevelThrustPerEngine, vacuumThrustPerEngine,
rocketDiameter, cd, theta, omega, burnTime);
// Launch the rocket using a Timer object.
gameTimer.start();
}
When you play around with the Rocket Simulator, you will notice that the rocket lifts off
very slowly and then gains speed as it continues to ascend. Figure 11-8 displays typical velocity
and altitude profiles of a rocket as a function of time. At liftoff the rocket propellant tanks are
full, so the mass of the rocket is at its greatest. The acceleration of the rocket is at a minimum,
and the velocity increases gradually. As the rocket continues its ascent, propellant is continu-
ally being burned, so the mass of the rocket is decreasing. As the altitude increases, the thrust
generated by the engines increases because the atmospheric pressure is decreasing. The
combination of increasing thrust and decreasing mass causes the acceleration of the rocket to
increase. The slope of the velocity profile becomes steeper and steeper throughout the ascent.
Search WWH ::




Custom Search