Class DynamicParticle
java.lang.Object
org.opensourcephysics.display.OSPRuntime.Supported
org.opensourcephysics.cabrillo.tracker.TTrack
org.opensourcephysics.cabrillo.tracker.PointMass
org.opensourcephysics.cabrillo.tracker.ParticleModel
org.opensourcephysics.cabrillo.tracker.DynamicParticle
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,Drawable
,Interactive
,Measurable
,Trackable
,ODE
- Direct Known Subclasses:
DynamicParticlePolar
DynamicParticle models a particle using Newton's 2nd law.
- Version:
- 1.0
- Author:
- W. Christian, D. Brown
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
PointMass.FrameData
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.NameDialog, TTrack.StepArray, TTrack.TextLineLabel, TTrack.TrackDecimalField, TTrack.TrackNumberField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected static final String[]
protected NumberField
protected double[]
protected boolean
protected int
protected org.opensourcephysics.cabrillo.tracker.DynamicParticle.ModelBooster
protected ODESolver
protected double[]
protected DynamicSystem
protected double[]
Fields inherited from class org.opensourcephysics.cabrillo.tracker.ParticleModel
dt, endFrame, functionEditor, functionPanel, inspectorH, inspectorX, inspectorY, invalidWarningShown, loading, massParamListener, modelBuilder, modelBuilderItem, myPoint, nan, nCalc, points, prevX, prevY, refreshDerivsLater, refreshing, refreshStepsLater, showModelBuilder, stampItem, startFrame, startFrameUndefined, t0, time, timeFormat, timeParamListener, tracePt, tracePtsPerStep, traceX, traceY, useDefaultReferenceFrame, useDefaultRefFrameItem, xLimit, yLimit
Fields inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
aAtOrigin, accelerationMenu, aColorItem, aDeriv, aDerivSpill, aFootprint, aFootprintMenu, aFootprints, algorithm, allVariables, aTailsToOriginItem, aTailsToPositionItem, autotrackItem, aVisibleItem, aVisibleOnAll, BOUNCE_DETECT, bounceDerivs, bounceDerivsSpill, dataVariables, derivData, drawsTrace, fieldVariables, FINITE_DIFF, FINITE_DIFF_VSPILL2, footprintNames, formatDescriptionMap, formatMap, formatVariables, isAutofill, isAutoKeyDown, labelsVisible, mass, massField, massLabel, MINIMUM_MASS, mSeparator, params, showfilledSteps, skippedSteps, trace, traceStroke, traceVisible, validData, vAtOrigin, vColorItem, vDeriv, vDerivSpill, vectorFields, velocityMenu, vFootprint, vFootprintMenu, vFootprints, vTailsToOriginItem, vTailsToPositionItem, vVisibleItem, vVisibleOnAll, xData, xVisibleOnAll, yData
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
angleField, angleLabel, angleSeparator, attachmentNames, attachments, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, customNumberFormats, dataBuilderItem, dataDescriptions, dataFrames, dataProp, datasetManager, dataValid, defaultColors, defaultFootprint, deleteStepItem, deleteTrackItem, description, descriptionItem, enabled, fieldBorder, fixedItem, footprint, footprintListener, footprintMenu, footprints, formatAngleMouseListener, formatMouseListener, hint, HINT_STEP_ADDED_OR_REMOVED, HINT_STEPS_SELECTED, initialized, isMarking, keyFrames, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, name, nameDialog, nameItem, nextID, NOMAP, NOMAPS, NOVARA, NOVARS, numberFields, partName, positionFields, preferredColumnOrder, properties, PROPERTY_TTRACK_COLOR, PROPERTY_TTRACK_DATA, PROPERTY_TTRACK_FOOTPRINT, PROPERTY_TTRACK_FORMAT, PROPERTY_TTRACK_LOCKED, PROPERTY_TTRACK_MASS, PROPERTY_TTRACK_MODELEND, PROPERTY_TTRACK_MODELSTART, PROPERTY_TTRACK_NAME, PROPERTY_TTRACK_STEP, PROPERTY_TTRACK_STEPS, PROPERTY_TTRACK_TEXTCOLUMN, PROPERTY_TTRACK_VISIBLE, refreshDataLater, skippedStepWarningCheckbox, skippedStepWarningDialog, skippedStepWarningOn, skippedStepWarningTextpane, stepLabel, steps, stepSeparator, stepSizeWhenFirstMarked, stepValueLabel, targetIndex, textColumnEntries, textColumnNames, tField, tframe, tLabel, toolbarPointComponents, toolbarTrackComponents, tp, trailLength, trailVisible, trailVisibleItem, tSeparator, ttype, tValueLabel, TYPE_CALIBRATION, TYPE_CIRCLEFITTER, TYPE_COORDAXES, TYPE_LINEPROFILE, TYPE_OFFSETORIGIN, TYPE_PERSPECTIVE, TYPE_POINTMASS, TYPE_PROTRACTOR, TYPE_RGBREGION, TYPE_TAPEMEASURE, TYPE_UNKNOWN, TYPE_VECTOR, viewable, visible, visibleItem, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
Fields inherited from interface org.opensourcephysics.media.core.Trackable
PROPERTY_ADJUSTING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
boost()
Sets the initial conditions to those of the booster at the current start frame.void
delete()
Deletes this particle.void
dispose()
Disposes of resources when this track is deleted or cleared.void
draw
(DrawingPanel panel, Graphics _g) Overrides ParticleModel draw method.protected PointMass
Gets the booster point mass.protected double[]
getBoostState
(PointMass target, int frameNumber) Gets the cartesian state {x, vx, y, vy, t} of a PointMass at a specified frame number.protected String[]
Gets a display name for this model.int
Gets the end frame for this model.double[]
Gets the initial state {x, vx, y, vy, t}.static XML.ObjectLoader
Returns an ObjectLoader to save and load data for this class.protected boolean
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
Gets the start frame for this model.double[]
getState()
Gets the current state {x, vx, y, vy, t}.protected void
getXYForces
(double[] cartesianState, double[] ret) Gets the x- and y-forces based on a specified cartesian state {x, vx, y, vy, t}.protected void
Creates and initializes the ModelFunctionPanel.protected void
Creates the initial position and velocity parameters.protected boolean
isBoostedBy
(PointMass target) Determines if a specified point mass is a booster of this particle (or a booster of a booster, etc).void
Responds to property change events.protected void
refreshSteps
(String why) Refreshes step positions.void
reset()
Resets parameters, initializes solver and sets position(s) for start frame or first clip frame following.protected void
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.protected void
setBooster
(PointMass booster) Sets the booster point mass.void
setEndFrame
(int n) Sets the end frame for this model.void
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
createMassAndTimeParameters, createPositionStep, doStamp, drawMe, findInteractive, fireStepsChanged, getFunctionEditor, getInitEditor, getInitialValues, getLastValidFrame, getMass, getMenu, getModelBuilder, getModels, getParamEditor, getToolbarPointComponents, holdPainting, isAutoTrackable, isDependent, isModelsVisible, isStepComplete, isUseDefaultReferenceFrame, newTimeParam, refreshDerivsIfNeeded, refreshInitialTime, setAnglesInRadians, setLastValidFrame, setLocked, setMass, setName, setTrackerPanel, setUseDefaultReferenceFrame, trimSteps
Methods inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
autoMarkAt, createGUI, createMenuIfNecessary, createStep, deleteAutoTrackerStep, deleteStep, erase, erase, getAArray, getAcceleration, getAccelerationFootprint, getAccelerationFootprints, getAccelerations, getBaseType, getFootprint, getFootprintLength, getFootprints, getFormatDescMap, getFormatMap, getFormatVariables, getNextVisibleStep, getNumberFields, getNumberFieldsForStep, getPreviousVisibleStep, getRotationData, getRotationData, getStep, getStepLength, getTargetDescription, getToolbarTrackComponents, getUnfilledGapCount, getVarDimsImpl, getVArray, getVelocities, getVelocity, getVelocityFootprint, getVelocityFootprints, getWorldAcceleration, getWorldPosition, getWorldVelocity, hasGaps, isAcceleration, isAutofill, isAVisible, isLabelsVisible, isPosition, isPositionVisible, isStepVisible, isTraceVisible, isVelocity, isVVisible, markAllInterpolatedSteps, markInterpolatedSteps, markInterpolatedSteps, refreshData, remark, remark, setAccelerationColor, setAccelerationFootprint, setAccelerationFootprints, setAlgorithm, setAutoFill, setAVisible, setAVisibleOnAll, setColor, setFontLevel, setFootprint, setLabelsVisible, setMarking, setPositionVisible, setPositionVisibleOnAll, setTraceVisible, setVelocityColor, setVelocityFootprint, setVelocityFootprints, setVisible, setVVisible, setVVisibleOnAll, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFixedItem, addFootprint, addListener, addListenerNCF, addPanelEvents, addStepListener, addTextColumn, assembleMenu, clearColumns, convertTextToDataColumn, createAllVariables, createWarningDialog, delete, finalize, getAllVariables, getAttachmentDescription, getAttachmentLength, getAttachments, getBaseTrackName, getBaseTypeInt, getColor, getCustomFormatPatterns, getData, getData, getDataDescription, getDataName, getDefaultFormatPatterns, getDefaultFormatPatterns, getDescription, getFootprint, getFootprintName, getFootprints, getFormatPatterns, getFrameForData, getIcon, getID, getMarkedPoint, getMarkingCursor, getMenuItems, getMessage, getName, getName, getNameDialog, getPlotViews, getPreferredDataOrder, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTableViews, getTargetIndex, getTextColumnEntry, getTextColumnNames, getTrack, getTrailLength, getValues, getVarFormatPattern, getVariableDimensions, getVariablesFromFormatterDisplayName, getX, getXMax, getXMin, getY, getYMax, getYMin, initialize, invalidateData, isAttached, isAutoAdvance, isAutoTrackable, isDataValid, isEmpty, isEnabled, isFullyAttached, isLocked, isMarkByDefault, isMarking, isMeasured, isTrailVisible, isViewable, isVisible, loadAttachmentsFromNames, refreshAttachments, refreshAttachmentsLater, refreshData, refreshDecimalSeparators, removeActiveTrack, removeDeleteTrackItem, removeListener, removeListenerNCF, removePanelEvents, removeStepListener, removeTextColumn, renameTextColumn, repaint, repaint, repaintAll, repaintStep, restorePatterns, savePatterns, setActive, setAutoAdvance, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFixedPosition, setFootprint, setFootprints, setFootprints, setFormatPattern, setInitialFormatPatterns, setMarkByDefault, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTextColumnEntry, setTrailLength, setTrailVisible, setViewable, setX, setXY, setY, showAnglePopup, showFormatPopup, toString, updateListenerVisible
Methods inherited from class org.opensourcephysics.display.OSPRuntime.Supported
addListeners, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListenerSafely, dispose, firePropertyChange, firePropertyChange, removeListeners, removePropertyChangeListener, removePropertyChangeListener
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Interactive
isInteractive
-
Field Details
-
modelBooster
protected org.opensourcephysics.cabrillo.tracker.DynamicParticle.ModelBooster modelBooster -
cellNumberField
-
inSystem
protected boolean inSystem -
boosterName
-
cartVars
-
state
protected double[] state -
initialState
protected double[] initialState -
solver
-
iterationsPerStep
protected int iterationsPerStep -
system
-
frameStates
-
temp
protected double[] temp
-
-
Constructor Details
-
DynamicParticle
public DynamicParticle()Constructor
-
-
Method Details
-
getBoostVars
-
draw
Overrides ParticleModel draw method.- Specified by:
draw
in interfaceDrawable
- Overrides:
draw
in classParticleModel
- Parameters:
panel
- the drawing panel requesting the drawing_g
- the graphics context on which to draw
-
getDisplayName
Gets a display name for this model.- Overrides:
getDisplayName
in classParticleModel
- 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 classParticleModel
-
refreshSteps
Refreshes step positions.- Overrides:
refreshSteps
in classParticleModel
-
reset
public void reset()Resets parameters, initializes solver and sets position(s) for start frame or first clip frame following.- Specified by:
reset
in classParticleModel
-
getState
public double[] getState()Gets the current state {x, vx, y, vy, t}. -
saveState
protected void saveState(int frameNumber) Saves the current state.- Overrides:
saveState
in classParticleModel
- Parameters:
frameNumber
- the frame number
-
restoreState
protected boolean restoreState(int frameNumber) Restores the state to a previously saved state, if any.- Overrides:
restoreState
in classParticleModel
- 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}. -
setSolver
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 classParticleModel
- Returns:
- the start frame
-
setStartFrame
public void setStartFrame(int n) Sets the start frame for this model. Overrides ParticleModel method.- Overrides:
setStartFrame
in classParticleModel
- Parameters:
n
- the desired start frame
-
getEndFrame
public int getEndFrame()Gets the end frame for this model. Overrides ParticleModel method.- Overrides:
getEndFrame
in classParticleModel
- Returns:
- the end frame
-
setEndFrame
public void setEndFrame(int n) Sets the end frame for this model. Overrides ParticleModel method.- Overrides:
setEndFrame
in classParticleModel
- Parameters:
n
- the desired end frame
-
propertyChange
Description copied from class:ParticleModel
Responds to property change events.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Overrides:
propertyChange
in classParticleModel
- Parameters:
e
- the property change event
-
getXYForces
protected void getXYForces(double[] cartesianState, double[] ret) Gets the x- and y-forces based on a specified cartesian state {x, vx, y, vy, t}.- Parameters:
cartesianState
- the stateret
- the forces [fx, fy]
-
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.- Specified by:
initializeFunctionPanel
in classParticleModel
-
getNextTracePositions
protected boolean 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
-
getBoostState
Gets the cartesian state {x, vx, y, vy, t} of a PointMass at a specified frame number.- Parameters:
target
- the PointMassframeNumber
- the frame number- Returns:
- the state, or null if the point mass is not marked at the frame number
-
getBooster
Gets the booster point mass.- Returns:
- the booster
-
setBooster
Sets the booster point mass.- Parameters:
booster
- the new booster (may be null)
-
isBoostedBy
Determines if a specified point mass is a booster of this particle (or a booster of a booster, etc).- Parameters:
target
- a point mass- Returns:
- true if the target is a booster
-
boost
protected void boost()Sets the initial conditions to those of the booster at the current start frame. -
getLoader
Returns an ObjectLoader to save and load data for this class.- Returns:
- the object loader
-
dispose
public void dispose()Description copied from class:TTrack
Disposes of resources when this track is deleted or cleared.- Overrides:
dispose
in classParticleModel
-