Game Development Reference
In-Depth Information
this.cdp = cdp;
this.eff = eff;
this.mass = mass;
this.enginePower = enginePower;
this.engineRps = engineRps;
this.propDiameter = propDiameter;
this.a = a;
this.b = b;
// Initially, set bank, angle of attack,
// and throttle to zero.
bank = 0.0;
alpha = 0.0;
throttle = 0.0;
flap = "0";
}
The PropPlane class declares a collection of get/set methods to access or change the value
of the fields declared in the class. Not all of the get/set methods are shown here.
// These methods access or change the value of the
// fields declared in the PropPlane class.
public double getBank() {
return bank;
}
public double getAlpha() {
return alpha;
}
// Other get/set methods not shown …
The heart of the PropPlane class is the getRightHandSide method that defines the right-hand
sides of the equations of motion that will be solved using the ODE solver. The method begins
by computing intermediate values of the location and velocity of the plane and declaring a
series of convenience variables.
public double[] getRightHandSide(double s, double q[],
double deltaQ[], double ds,
double qScale) {
double dQ[] = new double[6];
double newQ[] = new double[6];
// Compute the intermediate values of the
// location and velocity components.
for(int i=0; i<6; ++i) {
newQ[i] = q[i] + qScale*deltaQ[i];
}
Search WWH ::




Custom Search