예제 #1
0
 /**
  * Calculates the trajectory of a falling particle and plots the position as a function of time.
  */
 public void calculate() {
   plotFrame.setAutoclear(false); // data not cleared at beginning of each calculation
   // gets initial conditions
   double y0 = control.getDouble("Initial y");
   double v0 = control.getDouble("Initial v");
   // sets initial conditions
   Particle ball = new FallingParticle(y0, v0);
   // gets parameters
   ball.dt = control.getDouble("dt");
   while (ball.y > 0) {
     ball.step();
     plotFrame.append(0, ball.t, ball.y);
     plotFrame.append(1, ball.t, ball.analyticPosition());
   }
 }