org.opensourcephysics.cabrillo.tracker
Class DynamicParticle

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.TTrack
      extended by org.opensourcephysics.cabrillo.tracker.PointMass
          extended by org.opensourcephysics.cabrillo.tracker.ParticleModel
              extended by org.opensourcephysics.cabrillo.tracker.DynamicParticle
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Drawable, Interactive, Measurable, Trackable, ODE
Direct Known Subclasses:
DynamicParticleConvertible, DynamicParticlePolar

public class DynamicParticle
extends ParticleModel
implements ODE

DynamicParticle models a particle using Newton'w 2nd law.

Version:
1.0
Author:
W. Christian, D. Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  java.util.HashMap<java.lang.Integer,double[]> frameStates
           
protected  double[] initialState
           
protected  int iterationsPerStep
           
protected  java.awt.geom.Point2D[] points
           
protected  ODESolver solver
           
protected  double[] state
           
protected  DynamicSystem system
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.ParticleModel
dt, endFrame, functionEditor, functionPanel, inspector, inspectorH, inspectorX, inspectorY, invalidWarningShown, lastValidFrame, loading, nan, prevX, prevY, refreshDerivsLater, refreshing, refreshStepsLater, showInspector, startFrame, startFrameUndefined, t0, time, timeFormat, tracePt, tracePtsPerStep, traceX, traceY, xLimit, yLimit
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
aAtOrigin, accelerationMenu, accelFootprintMenu, aDeriv, aDerivSpill, aFootprint, aFootprints, aMap, aTailsToOriginItem, aTailsToPositionItem, autotrackItem, aVisibleItem, aVisibleOnAll, aVisMap, dataDescriptions, derivData, mass, massField, massLabel, mSeparator, params, positionFootprintMenu, trace, traceStroke, traceVisible, validData, vAtOrigin, vDeriv, vDerivSpill, velocFootprintMenu, velocityMenu, vFootprint, vFootprints, vMap, vTailsToOriginItem, vTailsToPositionItem, vVisibleItem, vVisibleOnAll, vVisMap, xData, xVisibleOnAll, xVisMap, yData
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
alphabet, angleField, angleLabel, angleSeparator, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, data, dataBuilderItem, dataFrames, dataProp, dataValid, defaultColors, defaultFootprint, deleteItem, description, descriptionItem, enabled, fieldBorder, footprint, footprintListener, footprintMenu, footprints, frc, hint, isMarking, keyFrames, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, menu, name, nameAction, nameDialog, nameField, nameItem, panels, partName, point, preferredColumnOrder, properties, refreshDataLater, skippedStepWarningCheckbox, skippedStepWarningDialog, skippedStepWarningOn, skippedStepWarningTextpane, stepLabel, steps, stepSeparator, stepSizeWhenFirstMarked, stepValueLabel, support, targetIndex, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, tValueLabel, viewable, visible, visibleItem, worldBounds, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
 
Constructor Summary
DynamicParticle()
          Constructor
 
Method Summary
 void delete()
          Deletes this particle.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides ParticleModel draw method.
 java.lang.String getDisplayName()
          Gets a display name for this model.
 int getEndFrame()
          Gets the end frame for this model.
 double[] getInitialState()
          Gets the initial state {x, vx, y, vy, t}.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
protected  java.awt.geom.Point2D[] getNextTracePositions()
          Gets the next trace positions.
 void getRate(double[] state, double[] rate)
          Gets the rate {vx, ax, vy, ay, 1} based on a specified state {x, vx, y, vy, t}.
 int getStartFrame()
          Gets the start frame for this model.
 double[] getState()
          Gets the current state {x, vx, y, vy, t}.
protected  double[] getXYForces(double[] cartesianState)
          Gets the x- and y-forces based on a specified cartesian state {x, vx, y, vy, t}.
protected  void initializeFunctionPanel()
          Creates and initializes the ModelFunctionPanel.
protected  void initializeInitEditor()
          Creates the initial position and velocity parameters.
protected  void refreshSteps()
          Refreshes step positions.
 void reset()
          Resets parameters, initializes solver and sets position(s) for start frame or first clip frame following.
protected  void resetState()
          Resets the state variables {x, vx, y, vy, t}.
protected  boolean restoreState(int frameNumber)
          Restores the state to a previously saved state, if any.
protected  void saveState(int frameNumber)
          Saves the current state.
 void setEndFrame(int n)
          Sets the end frame for this model.
 void setSolver(java.lang.Class<?> solverClass)
          Sets the ODESolver type.
 void setStartFrame(int n)
          Sets the start frame for this model.
protected  void setTracePositions(double[] state)
          Sets the positions of the trace points based on a specified state.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.ParticleModel
cleanup, createMassAndTimeParameters, drawMe, findInteractive, getFunctionEditor, getInitEditor, getInitialValues, getInspector, getMass, getMenu, getModels, getParamEditor, getToolbarPointComponents, isAutoTrackable, isDependent, isModelsVisible, isStepComplete, propertyChange, refreshDerivsIfNeeded, refreshInitialTime, setAnglesInRadians, setLocked, setMass, setName, setTrackerPanel, trimSteps
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
createGUI, createStep, deleteStep, erase, erase, getAArray, getAcceleration, getAccelerationFootprint, getAccelerationFootprints, getAccelerations, getDataDescription, getDefaultAutoTrackerIndex, getFootprint, getFootprintLength, getFootprints, getNextVisibleStep, getPreviousVisibleStep, getRotationData, getRotationData, getStep, getStepLength, getTargetDescription, getToolbarTrackComponents, getVArray, getVelocities, getVelocity, getVelocityFootprint, getVelocityFootprints, getWorldAcceleration, getWorldPosition, getWorldVelocity, isAcceleration, isAVisible, isLabelsVisible, isPosition, isPositionVisible, isStepVisible, isTraceVisible, isVelocity, isVVisible, refreshData, remark, remark, setAccelerationFootprint, setAccelerationFootprints, setAVisible, setAVisibleOnAll, setColor, setFootprint, setLabelsVisible, setPositionVisible, setPositionVisibleOnAll, setTraceVisible, setVelocityFootprint, setVelocityFootprints, setVVisible, setVVisibleOnAll, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, createWarningDialog, firePropertyChange, getColor, getData, getDataName, getDescription, getFootprint, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getPreferredDataOrder, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTargetIndex, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isTrailVisible, isViewable, isVisible, refreshData, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAutoAdvance, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrailLength, setTrailVisible, setViewable, setVisible, setX, setXY, setY, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

state

protected double[] state

initialState

protected double[] initialState

solver

protected ODESolver solver

iterationsPerStep

protected int iterationsPerStep

system

protected DynamicSystem system

points

protected java.awt.geom.Point2D[] points

frameStates

protected java.util.HashMap<java.lang.Integer,double[]> frameStates
Constructor Detail

DynamicParticle

public DynamicParticle()
Constructor

Method Detail

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics _g)
Overrides ParticleModel draw method.

Specified by:
draw in interface Drawable
Overrides:
draw in class ParticleModel
Parameters:
panel - the drawing panel requesting the drawing
_g - the graphics context on which to draw

getDisplayName

public java.lang.String getDisplayName()
Gets a display name for this model.

Overrides:
getDisplayName in class ParticleModel
Returns:
the display name

delete

public void delete()
Deletes this particle. Overrides ParticleModel method to warn user if this is part of a DynamicSystem.

Overrides:
delete in class ParticleModel

refreshSteps

protected void refreshSteps()
Refreshes step positions.

Overrides:
refreshSteps in class ParticleModel

reset

public void reset()
Resets parameters, initializes solver and sets position(s) for start frame or first clip frame following.

Overrides:
reset in class ParticleModel

getState

public double[] getState()
Gets the current state {x, vx, y, vy, t}.

Specified by:
getState in interface ODE
Returns:
the state

saveState

protected void saveState(int frameNumber)
Saves the current state.

Overrides:
saveState in class ParticleModel
Parameters:
frameNumber - the frame number

restoreState

protected boolean restoreState(int frameNumber)
Restores the state to a previously saved state, if any.

Overrides:
restoreState in class ParticleModel
Parameters:
frameNumber - the frame number
Returns:
true if state successfully restored

getRate

public void getRate(double[] state,
                    double[] rate)
Gets the rate {vx, ax, vy, ay, 1} based on a specified state {x, vx, y, vy, t}.

Specified by:
getRate in interface ODE
Parameters:
state - the state
rate - the rate of change of the state

setSolver

public void setSolver(java.lang.Class<?> solverClass)
Sets the ODESolver type.

Parameters:
solverClass - the solver class

getInitialState

public double[] getInitialState()
Gets the initial state {x, vx, y, vy, t}.

Returns:
the initial state

getStartFrame

public int getStartFrame()
Gets the start frame for this model. Overrides ParticleModel method.

Overrides:
getStartFrame in class ParticleModel
Returns:
the start frame

setStartFrame

public void setStartFrame(int n)
Sets the start frame for this model. Overrides ParticleModel method.

Overrides:
setStartFrame in class ParticleModel
Parameters:
n - the desired start frame

getEndFrame

public int getEndFrame()
Gets the end frame for this model. Overrides ParticleModel method.

Overrides:
getEndFrame in class ParticleModel
Returns:
the end frame

setEndFrame

public void setEndFrame(int n)
Sets the end frame for this model. Overrides ParticleModel method.

Overrides:
setEndFrame in class ParticleModel
Parameters:
n - the desired end frame

getXYForces

protected double[] getXYForces(double[] cartesianState)
Gets the x- and y-forces based on a specified cartesian state {x, vx, y, vy, t}.

Parameters:
cartesianState - the state
Returns:
the forces

resetState

protected void resetState()
Resets the state variables {x, vx, y, vy, t}.


initializeInitEditor

protected void initializeInitEditor()
Creates the initial position and velocity parameters.


initializeFunctionPanel

protected void initializeFunctionPanel()
Creates and initializes the ModelFunctionPanel.

Overrides:
initializeFunctionPanel in class ParticleModel

getNextTracePositions

protected java.awt.geom.Point2D[] getNextTracePositions()
Gets the next trace positions.

Returns:
an array of points at the trace positions

setTracePositions

protected void setTracePositions(double[] state)
Sets the positions of the trace points based on a specified state.

Parameters:
state - the state

getLoader

public static XML.ObjectLoader getLoader()
Returns an ObjectLoader to save and load data for this class.

Returns:
the object loader