Game Development Reference
In-Depth Information
// Initialize variables declared in the SpinProjectile class.
this.rx = rx;
this.ry = ry;
this.rz = rz;
this.omega = omega;
this.radius = radius;
}
A series of get methods are declared to return the values of the fields declared in the
SpinProjectile class. The updateLocationAndPosition method is exactly the same as it was
before. It simply invokes the Runge-Kutta ODE solver to solve the equations of motion.
// These methods return the value of the fields
// declared in this class.
public double getRx() {
return rx;
}
public double getRy() {
return ry;
}
public double getRz() {
return rz;
}
public double getOmega() {
return omega;
}
public double getRadius() {
return radius;
}
// This method updates the velocity and location
// of the projectile using a 4th order Runge-Kutta
// solver to integrate the equations of motion.
public void updateLocationAndVelocity(double dt) {
ODESolver.rungeKutta4(this, dt);
}
The getRightHandSide method declared in the SpinProjectile class includes the equations to
compute the Magnus force terms. The first part of the method is the same. Intermediate values
of the location and velocity components are computed as apparent velocity seen by the projectile.
Search WWH ::




Custom Search