vmm.ode
Class ODE_3D

java.lang.Object
  extended by vmm.core.Exhibit
      extended by vmm.core3D.Exhibit3D
          extended by vmm.ode.ODE_3D
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ChangeListener, Decorateable, Parameterizable
Direct Known Subclasses:
ChargedParticles, ODE1stOrder3D, ODE1stOrder3DNonAutonomous, ODE2ndOrder3D, ODE2ndOrder3DNonAutonomous

public abstract class ODE_3D
extends Exhibit3D

Represents an ODE exhibit that will be displayed in three dimensions.


Nested Class Summary
 class ODE_3D.ODEView
          Represents the default view for an ODEFirstOrder2D.
 
Field Summary
protected  boolean addAnimateCheckBoxontrolPanel
          If set to false in the constructor of a subclass, then the check box for turning animatino of orbit drawing will not be added to the control pandl (although the command will still be in the Action menu).
protected  boolean addLinesCheckBoxontrolPanel
          If set to false in the constructor of a subclass, then the check box for controling whether orbits are drawn as solid lines will not be added to the control pandl (although the command will still be in the Action menu).
protected  boolean addOrbitTypesToControlPanel
          If set to true in the constructor of a subclass, then the radio buttons for selecting RungeKutta/Euler/Both will be added to the control pandl.
protected  boolean anaglyphIsDefault
          If this is set to true in a subclass's constructor, then the view will be put in anaglyph mode when it is created.
protected  boolean canShowVectorField
          Tells whether it is possible to draw a vector field for the exhibit.
protected  double dtDefault
          The value of this variable is used as the initial value of dt in the Control Panel of any view of this exhbit.
protected  double[] initialDataDefault
          Contains the initial conditions that are placed in the control panel when the exhibit is first created.
protected  java.lang.String[] inputLabelNames
          The names used for the input boxes where the user can type in the initial values for an integeral curves.
protected  boolean isAutonomous
          Tells whether the ODE is autonomous (i.e.
static int ORBIT_TYPE_BOTH
           
static int ORBIT_TYPE_EULER
           
static int ORBIT_TYPE_RUNGE_KUTTA
           
protected  boolean showAxes
          If this is set to true in a subclass's constructor, then the view will be set to show axes when it is created.
protected  double timeSpanDefault
          The value of this variable is used as the initial value of Time Span in the Control Panel of any view of this exhbit.
 
Fields inherited from class vmm.core3D.Exhibit3D
defaultViewpoint, defaultViewUp, previousTransform3D
 
Fields inherited from class vmm.core.Exhibit
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform
 
Constructor Summary
protected ODE_3D(boolean canShowVectorField, boolean isAutonomous, java.lang.String... inputLabelName)
          Constructor sets the default background to be black, and sets the value of the final "isAutonomous" property and the lables to be used for the input boxes for initial conditions.
 
Method Summary
protected  void doDraw(java.awt.Graphics2D g, View view, Transform transform)
          Draws a direction field, but only for an exhbit in which the canShowVectorField property is true and then only if the exhibit is being displayed in an ODEView whose showDirectionField property is turned on (or in the unlikely event that it is being displayed in some other type of View).
protected  Vector3D extractPointFromData(double[] pointData)
          Extract from the data for a point on the integral curve the actual point that is to be displayed on the screen.
 TimerAnimation getCreateAnimation(View view)
          For an ODE view, returns the animation that redraws the current orbit, if there is one, or draws the default orbit as defined by initialDataDefault, if the value of that variable is non-null.
 View getDefaultView()
          Returns a view of type ODE_3D.ODEView.
protected  MouseTask makeDefaultMouseTask(ODE_3D.ODEView view)
          Should construct and return a mouse task appropriate for this exhibit, to be used in the specified view.
protected abstract  void nextEulerPoint(double[] pointData, double dt)
          Computes the next point on an integral curve, using Euler's method.
protected abstract  void nextRungeKuttaPoint(double[] pointData, double dt)
          Computes the next point on an integral curve, using the Runge-Kutta method.
protected  Vector3D screenPointTo3DPoint(View3D view, int x, int y)
          Transform a point on the screen to a point in 3D space.
protected  double vectorField_x(double x, double y, double z, double t)
          Returns the x-component of the vector field at point (x,y,z) and time t.
protected  double vectorField_y(double x, double y, double z, double t)
          Returns the x-component of the vector field at point (x,y,z) and time t.
 
Methods inherited from class vmm.core3D.Exhibit3D
computeDrawData3D, computeDrawDataHook, doDraw3D, doDrawHook, getDefaultTransform, getDefaultViewpoint, getDefaultViewUp, setDefaultViewpoint, setDefaultViewUp
 
Methods inherited from class vmm.core.Exhibit
addChangeListener, addDecoration, addExtraXML, addParameter, addView, clearDecorations, computeDrawData, fireExhibitChangeEvent, forceRedraw, getActionsForView, getAdditionalAnimationsForView, getAlternativeViews, getBuildAnimation, getDecorations, getDefaultBackground, getDefaultForeground, getDefaultWindow, getFramesForMorphing, getMorphingAnimation, getName, getParameterByName, getParameters, getSettingsCommandsForView, getTitle, getUseFilmstripForMorphing, getViews, parameterChanged, readExtraXML, removeChangeListener, removeDecoration, removeParameter, removeView, render, setDefaultBackground, setDefaultForeground, setDefaultWindow, setDefaultWindow, setFramesForMorphing, setName, setUseFilmstripForMorphing, stateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORBIT_TYPE_RUNGE_KUTTA

public static final int ORBIT_TYPE_RUNGE_KUTTA
See Also:
Constant Field Values

ORBIT_TYPE_BOTH

public static final int ORBIT_TYPE_BOTH
See Also:
Constant Field Values

ORBIT_TYPE_EULER

public static final int ORBIT_TYPE_EULER
See Also:
Constant Field Values

isAutonomous

protected final boolean isAutonomous
Tells whether the ODE is autonomous (i.e. independent of time). This final variable is set by the constructor ODE_3D(boolean, boolean, String[]), with the actual value coming from the constructor of each subclass. Autonomous and non-autonomous vector fields have different behaviors.


showAxes

protected boolean showAxes
If this is set to true in a subclass's constructor, then the view will be set to show axes when it is created. The default is for the axes to be hidden.


anaglyphIsDefault

protected boolean anaglyphIsDefault
If this is set to true in a subclass's constructor, then the view will be put in anaglyph mode when it is created. The default is a monocular view.


addOrbitTypesToControlPanel

protected boolean addOrbitTypesToControlPanel
If set to true in the constructor of a subclass, then the radio buttons for selecting RungeKutta/Euler/Both will be added to the control pandl. (Even when not added to the control panel, they will still be in the Action menu).


addAnimateCheckBoxontrolPanel

protected boolean addAnimateCheckBoxontrolPanel
If set to false in the constructor of a subclass, then the check box for turning animatino of orbit drawing will not be added to the control pandl (although the command will still be in the Action menu).


addLinesCheckBoxontrolPanel

protected boolean addLinesCheckBoxontrolPanel
If set to false in the constructor of a subclass, then the check box for controling whether orbits are drawn as solid lines will not be added to the control pandl (although the command will still be in the Action menu).


canShowVectorField

protected final boolean canShowVectorField
Tells whether it is possible to draw a vector field for the exhibit. This is set in the contructor ODE_3D(boolean, boolean, String[]), with the actual value coming from the contructor of each subclass. If the value is false, then the methods vectorField_x(double, double, double, double) and vectorField_y(double, double, double,double) are never called. If the value is true, then these methods must be overridden to return the correct values. For an autonomous ODE, the display of the vector field is under control of the user. For a non-autonomous ODE, the vector field is shown only when an integral curve is being constructed. (Actually, a direction field rather than a vector field is drawn.)


inputLabelNames

protected final java.lang.String[] inputLabelNames
The names used for the input boxes where the user can type in the initial values for an integeral curves. This array is set from the String parameters to the constructor ODE_3D(boolean, boolean, String[]). There must be exactly as many strings as there are data items in the pointData array that is passed to nextEulerPoint(double[], double), nextRungeKuttaPoint(double[], double) and extractPointFromData(double[]).


dtDefault

protected double dtDefault
The value of this variable is used as the initial value of dt in the Control Panel of any view of this exhbit. The default is 0.05, but it can be reset in the constructor of a subclass.


timeSpanDefault

protected double timeSpanDefault
The value of this variable is used as the initial value of Time Span in the Control Panel of any view of this exhbit. The default is 10.0, but it can be reset in the constructor of a subclass.


initialDataDefault

protected double[] initialDataDefault
Contains the initial conditions that are placed in the control panel when the exhibit is first created. The value in this class is null, which means that the initial condition input boxed in the control panel will be empty when it first appears. Subclasses can set a different value. The value should be an array of doubles, where the first several items have the same meaning as the parameter in such methods as nextEulerPoint(double[], double) and extractPointFromData(double[]). In addition there can be up to two additional items. The first additional item, if present and greater than zero, specifies a dt for the initial orbit. The second additional item, if present and greater than zero, specifies a timeSpan for the initial orbit. If these values are not present or are less than or equal to zero, then the default dt/TimeSpan of the exhbit is used.

Constructor Detail

ODE_3D

protected ODE_3D(boolean canShowVectorField,
                 boolean isAutonomous,
                 java.lang.String... inputLabelName)
Constructor sets the default background to be black, and sets the value of the final "isAutonomous" property and the lables to be used for the input boxes for initial conditions. For a non-autonomous ODE, the first lable should be the label for the initial time input, generally just "t". Also sets the default viewpoint to 10, 10, 5

Method Detail

nextEulerPoint

protected abstract void nextEulerPoint(double[] pointData,
                                       double dt)
Computes the next point on an integral curve, using Euler's method. The pointData parameter array contains the data for the current point. This data should be replaced with the data for the next point. The size of the array and the meaning of the data that it contains will vary from one subclass to another. However, for non-autonomous ODEs, the time should always be the first parameter in the array. The second parameter, dt, gives the time step from the current point to the next point.


nextRungeKuttaPoint

protected abstract void nextRungeKuttaPoint(double[] pointData,
                                            double dt)
Computes the next point on an integral curve, using the Runge-Kutta method. The pointData parameter array contains the data for the current point. This data should be replaced with the data for the next point. The size of the array and the meaning of the data that it contains will vary from one subclass to another. But for the non-autonmous case, the time should always be the first value in the array. The second parameter, dt, gives the time step from the current point to the next point.


extractPointFromData

protected Vector3D extractPointFromData(double[] pointData)
Extract from the data for a point on the integral curve the actual point that is to be displayed on the screen. The default implementation in this class takes the point from the first three components of the array for an autonomous ODE and from the second, third, and fourth components for a non-autonomous ODE, allowing the first spot for the current time. Note that for non-autonomous ODEs, the time must be in the first spot in the array.


vectorField_x

protected double vectorField_x(double x,
                               double y,
                               double z,
                               double t)
Returns the x-component of the vector field at point (x,y,z) and time t. For autonomous ODEs, the result should be independent of t. The default implementation here simply returns 0. An exhibit that sets the canShowVectorField propery to true should override this method to compute the correct value.


vectorField_y

protected double vectorField_y(double x,
                               double y,
                               double z,
                               double t)
Returns the x-component of the vector field at point (x,y,z) and time t. For autonomous ODEs, the result should be independent of t. The default implementation here simply returns 0. An exhibit that sets the canShowVectorField propery to true should override this method to compute the correct value.


makeDefaultMouseTask

protected MouseTask makeDefaultMouseTask(ODE_3D.ODEView view)
Should construct and return a mouse task appropriate for this exhibit, to be used in the specified view. The default return value is a standard BasicMouseTask3D; subclasses can redefine this to add the ability to input the initial conditions with the mouse.


getCreateAnimation

public TimerAnimation getCreateAnimation(View view)
For an ODE view, returns the animation that redraws the current orbit, if there is one, or draws the default orbit as defined by initialDataDefault, if the value of that variable is non-null. Otherwise, the return value is null.

Overrides:
getCreateAnimation in class Exhibit
Parameters:
view - A View that is displaying this Exhibit. The animation, if any, that is returned by this method will be installed in the View's display. If the view is null, than a creation animation that can run independently of a view could be returned.
Returns:
A creation animation for the given View of this Exhibit. The return value can be null to indicate that no creation animation is to be run.

screenPointTo3DPoint

protected Vector3D screenPointTo3DPoint(View3D view,
                                        int x,
                                        int y)
Transform a point on the screen to a point in 3D space. (The inverse transformation that is used here to get from 3D viewing coords to 3D object coords is valid only for a point that lies in the plane of the screen (or for an orthographic projection).

For cross-eye and stereograph view, where (x,y) might not lie in one of the view rects, the return value is null when (x,y) is outside the view rects.


doDraw

protected void doDraw(java.awt.Graphics2D g,
                      View view,
                      Transform transform)
Draws a direction field, but only for an exhbit in which the canShowVectorField property is true and then only if the exhibit is being displayed in an ODEView whose showDirectionField property is turned on (or in the unlikely event that it is being displayed in some other type of View).

Overrides:
doDraw in class Exhibit
Parameters:
g - The graphics context where the Exhibit is being drawn. It has already been cleared to the background color (assuming that drawing is being done in the usual way, as defined in the top-level View class).
view - The View that is drawing the Exhibit; this object contains other information that might be of use, such as the Display, if any, associated with the View.
transform - Contains information about the rectangular area in the xy-plane that is being drawn and about the rectangle of pixels in the graphics context where it is drawn. Note that at least for the top-level View class, transform.getX() and transform.getY() can be assumed to be zero.
See Also:
ODE_3D.ODEView.setShowDirectionField(boolean)

getDefaultView

public View getDefaultView()
Returns a view of type ODE_3D.ODEView.

Overrides:
getDefaultView in class Exhibit3D