com.speckled.specksim.imp.motion
Class CacheingMovementModel

java.lang.Object
  extended by com.speckled.specksim.imp.motion.CacheingMovementModel
All Implemented Interfaces:
Configurable, MovementModel
Direct Known Subclasses:
GridMovementModel, SpeckledBodyModel, StaticMovementModel, WaypointMovementModel

public abstract class CacheingMovementModel
extends java.lang.Object
implements MovementModel

Override this class to add cacheing behaviour to your movement model. MovementModels are often asked to locate the same speck at the same time more than once. Cacheing the results will obviously improve performance

Author:
ryanm

Constructor Summary
CacheingMovementModel()
           
 
Method Summary
protected  void clearCache()
          Clears the cache.
protected abstract  SpeckPosition computeLocation(Speck speck, float time)
          Override this to compute a speck's location
protected abstract  Vector3d computeVelocity(Speck speck, float time)
          Override this to compute a speck's velocity
 SpeckPosition getSpeckOrientation(Speck speck, float time)
          Works out the position of a given speck at a given time.
 Vector3d getSpeckVelocity(Speck speck, float time)
          Works out the velocity of a given speck at a given time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.speckled.specksim.MovementModel
deInit, getMaxSpeed, getName, getState, init, removeSpeck
 
Methods inherited from interface com.ryanm.config.Configurable
getConfigurator
 

Constructor Detail

CacheingMovementModel

public CacheingMovementModel()
Method Detail

clearCache

protected void clearCache()
Clears the cache. This should be called anytime the MovementModel is changed


getSpeckOrientation

public final SpeckPosition getSpeckOrientation(Speck speck,
                                               float time)
Description copied from interface: MovementModel
Works out the position of a given speck at a given time. It can be assumed that, for a given speck, successive calls to the methods getSpeckOrientation() and getVelocity() method will be made with strictly increasing or equals values for time between simulator resets. If you need to maintain any state for each speck, this is the place to initialise it whenever you encounter a new speck

Specified by:
getSpeckOrientation in interface MovementModel
Parameters:
speck - The speck to locate
time - The time at which to locate
Returns:
The position and orientation of the speck at the time.

getSpeckVelocity

public final Vector3d getSpeckVelocity(Speck speck,
                                       float time)
Description copied from interface: MovementModel
Works out the velocity of a given speck at a given time

Specified by:
getSpeckVelocity in interface MovementModel
Parameters:
speck - The speck to calculate velocity for
time - The time at which to calculate
Returns:
The velocity of the speck, in units per second

computeLocation

protected abstract SpeckPosition computeLocation(Speck speck,
                                                 float time)
Override this to compute a speck's location

Parameters:
speck - The speck to locate
time - The time to locate at
Returns:
The location of the speck at the given time

computeVelocity

protected abstract Vector3d computeVelocity(Speck speck,
                                            float time)
Override this to compute a speck's velocity

Parameters:
speck - The speck to compute for
time - The time to compute at
Returns:
The velocity of the speck at the given time