|All Implemented Interfaces|
Handles collisions by backing up in time with binary search algorithm. For better performance uses collision time estimates and handles imminent collisions.
When a collision is encountered,
#advance backs up to just before the time of
collision, handles the collision, then continues to advance to the end of the time step.
(This process can happen many times during a single call to
advance). Uses a binary
search algorithm to get to the time just before the collision.
is used to move the simulation forward in time.
Debugging with WayPoints
CollisonAdvance can be very tricky to debug because the set of Collisions found drive the process, yet they come and go as we move backward and forward in time. Specifying WayPoints lets you focus on only the relevant aspects of the process, greatly reducing the volume of debug messages to sort thru.
new CollisionAdvance( sim, opt_diffEqSolver )
this.addWayPoints( wayPoints ) →
this.advance( timeStep, opt_memoList ) →
Advances the Simulation state by the specified amount of time.
this.setDebugLevel( debugLevel ) →
Sets how much debugging information to show,
this.setDebugPaint( fn ) →
For debugging, specify a function that will paint canvases, so that you can see the simulation state while stepping thru with debugger.
Why to use setDebugPaint()
setDebugPaint() allows you to see the sub-steps involved in calculating the next
simulation state, such as each collision happening over a time step, or the sub-steps
calculated by a
myphysicslab.lab.model.DiffEqSolver. Normally you only see the
result after the next state is calculated, because the frame is painted after the
simulation has advanced by a certain time step. By setting the
paintAll function and
setting a debugger break point you will be able to see the situation whenever
moveObjects() is called. See
an example and more information.
Here is example code where
simRun.paintAll is the SimRunner method
myphysicslab.lab.app.SimRunner#paintAll which paints all the LabCanvas's.
this.setDiffEqSolver( diffEqSolver ) →
this.setJointSmallImpacts( value ) →
this.setTimeStep( timeStep ) →
Sets the default time step, the small increment of time by which to advance the simulation's state.
The reason for storing the time step in AdvanceStrategy is so that
myphysicslab.test.TestViewerApp produces same results as running a test.
This is a convenient way for a test to make known the time step to use.
this.setWayPoints( wayPoints ) →
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling
toStringShort on that other object. For
toStringShort() on a DisplayShape might return something like