the CollisionSim to advance in time
Optional
opt_diffEqSolver: DiffEqSolverthe DiffEqSolver to use, default is RungeKutta
Private
backuphow many times we had to backup
Private
binarywhether searching for collision using binary search algorithm
Private
binaryduring binary search, number of consecutive same-size steps; should never exceed 2
Private
collisionhow many collisions occurred
Private
collisionlong term count of number of collisions, backups, ode steps taken, etc.
Private
collisions_the current set of collisions; includes joints, contacts, imminent collisions
Private
currenthow much time currently trying to advance
Private
debugfunction to paint canvases, for debugging. If defined, this will be called within
do_advance_sim()
, so you can see the simulation state after each
collision is handled (you will need to arrange your debugger to pause after
each invocation of debugPaint_ to see the state).
Private
detectedduring binary search, remembers time when earliest collision was detected
Private
jointWhether to apply small impacts to joints to keep them aligned.
Private
nextthe estimated time when the next collision will happen.
Private
odehow many ODE (ordinary diff eq) steps were taken
Private
printFor debugging, when we last printed a debug message.
Private
removedset of collisions that were 'not close enough' to be handled. These are kept to find the estimated time of next collision after handling current collisions.
Private
stats_statistics about the current set of collisions
Private
stuckfor detecting 'stuck' condition
Private
timehow much time simulation has advanced
Private
timeDefault amount of time to advance the simulation, in seconds.
Private
totaltotal length of time requested to advance
Private
waySet of waypoints at which to print debug messages
Static
Readonly
MAX_The maximum number of times to go thru the loop in advance()
without a successful
step that advances the simulation time; when this limit is exceeded then advance()
returns false
to indicate it was unable to advance the simulation.
Adds a group of WayPoints to show debug messages to the existing set of WayPoints.
array of WayPoints to add
Advances the Simulation state by the specified amount of time.
the amount of time to advance in seconds
Optional
opt_memoList: MemoListoptional MemoList to call whenever the simulation state is advanced
when unable to advance the simulation
Private
allReturns the velocities of the collisions.
minimum velocities
Private
calc_Private
checkPrivate
do_Private
do_Private
do_Private
do_Returns the CollisionTotals object giving collision statistics.
the CollisionTotals object giving collision statistics.
Returns the DiffEqSolver used to solve the differential equations
the DiffEqSolver used to solve the differential equations
Returns the current simulation time. There are no explicit units for the time, so you can regard a time unit as seconds or years as desired. See About Units Of Measurement.
the current simulation time.
Private
jointReturns the joint flags of collisions
joint flags
Private
maxReturns the maximum impulse applied to any of the collisions.
maximum impulse applied
Private
minReturns the smallest (most negative) velocity of the collisions.
minimum velocity
Private
myPrivate
printPrint the debug message corresponding to the given WayPoint.
the way point to print debug information for
Private
printPrints a collision to console using color to highlight collisions that are colliding or close enough to handle. *
current simulation time *
message to print before the collision *
the Collision to print
Private
printPrivate
printPrivate
removeRemoves from the current set of collisions, those contacts that are not touching, because they cannot participate in the chain of impulses that are passed between objects during serial collision handling. The removed collisions are added to the removed collisions array.
regard as close enough collisions that have smaller distance than distance accuracy would normally allow
true if any collisions were removed
Save the initial conditions, which can be returned to with reset.
Sets how much debugging information to show, see DebugLevel.
specifies the groups of debug messages to show
For debugging, specify a function that will paint canvases, so that you can see the simulation state while stepping thru with debugger.
Using 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 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 RigidBodySim for
an example and more information.
Here is example code where simRun.paintAll
is the method
SimRunner.paintAll
which paints all the LabCanvas's.
advance.setDebugPaint( () => simRun.paintAll() );
function that will paint canvases
Sets the DiffEqSolver used to solve the differential equations
the DiffEqSolver used to solve the differential equations of this simulation.
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 test/TestViewerApp.TestViewerApp produces the same results as running a test. This is a convenient way for a test to make known the time step to use.
the default time step, in seconds.
Specifies the group of WayPoints to show debug messages at.
array of WayPoints to show debug messages for
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 example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Generated using TypeDoc
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. The DiffEqSolver 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.
A WayPoint is a step of the AdvanceStrategy process where debug info can be printed. See the methods addWayPoints, setWayPoints. The method setDebugLevel selects a pre-defined group of WayPoints.
Here is an example of how to turn on debugging.
See Observing The Collision Handling Process in 2D Physics Engine Overview, and DebugLevel.