Game Development Reference
In-Depth Information
// SpringODE constructor.
public SpringODE(double mass, double mu, double k,
double x0) {
// Call the ODE constructor indicating that there
// will be two coupled first-order ODEs.
super(2);
// Initialize fields declared in the class.
this.mass = mass;
this.mu = mu;
this.k = k;
this.x0 = x0;
time = 0.0;
// Set the initial conditions of the dependent
// variables.
// q[0] = vx
// q[1] = x;
setQ(0.0, 0);
setQ(x0, 1);
}
The SpringODE class declares a series of get/set methods to return or change the value of
the fields declared in the class. Not all of the get/set methods are shown here.
// These methods return field values
public double getMass() {
return mass;
}
// Other get methods not shown…
// These methods change field values
public void setMass(double value) {
mass = value;
return;
}
// Other set methods not shown …
Methods are declared that return the location and velocity of the spring as computed by
the ODE solver, as well as the current time value.
// These methods return the spring location
// and velocity as computed by the ODE solver.
public double getVx() {
return getQ(0);
}
Search WWH ::




Custom Search