org.opensourcephysics.sip.ch04
Class Pendulum

java.lang.Object
  extended by org.opensourcephysics.sip.ch04.Pendulum
All Implemented Interfaces:
Drawable, ODE

public class Pendulum
extends java.lang.Object
implements Drawable, ODE

Pendulum models the dynamics of a pendulum.


Constructor Summary
Pendulum()
           
 
Method Summary
 void draw(DrawingPanel drawingPanel, java.awt.Graphics g)
          Draws the pendulum.
 void getRate(double[] state, double[] rate)
          Gets the rate.
 double[] getState()
          Gets the state.
 void setState(double theta, double thetaDot)
          Sets the state.
 void setStepSize(double dt)
          Sets the ODESolver's time step.
 void step()
          Steps (advances) the time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pendulum

public Pendulum()
Method Detail

setStepSize

public void setStepSize(double dt)
Sets the ODESolver's time step.

Parameters:
dt - double

step

public void step()
Steps (advances) the time.

Parameters:
dt - the time step.

setState

public void setState(double theta,
                     double thetaDot)
Sets the state.

Parameters:
theta -
dtheta/dt -

getState

public double[] getState()
Gets the state. Required for ODE interface.

Specified by:
getState in interface ODE
Returns:
double[] the state

getRate

public void getRate(double[] state,
                    double[] rate)
Gets the rate. Required for ODE inteface

Specified by:
getRate in interface ODE
Parameters:
state - double[] the state
rate - double[] the computed rate

draw

public void draw(DrawingPanel drawingPanel,
                 java.awt.Graphics g)
Draws the pendulum. Required for Drawable interface.

Specified by:
draw in interface Drawable
Parameters:
drawingPanel -
g -