Creates a pile of randomly shaped blocks that fall onto a V shaped wall. The user can add 6 blocks at a time to the pile by clicking a button. This is a stress test to find how many blocks it takes before the simulation engine bogs down and cannot keep up with real time.

Wiggling Blocks

Note that the blocks in the pile will wiggle unrealistically in the end resting state when there is not enough accuracy in the simulation. It is most noticeable when highly zoomed in on the blocks, so that the gaps between them are obvious. The three main factors are: gravity, time step, and diff eq solver. Stronger gravity means that objects move more between time steps and so will wiggle more. Longer time step gives objects more time to wiggle between adjustments from the collision handler. Using the Runge Kutta solver is like halving the time step, compared to using the Modified Euler solver (because RK is average of 4 sub-steps, two of which are mid-step).

Specifically here are some settings and their effects:

  • Wiggles: Gravity=10, TimeStep=0.025, Modified Euler
  • No Wiggle: Gravity=10, TimeStep=0.01, Modified Euler
  • No Wiggle: Gravity=10, TimeStep=0.025, Runge Kutta
  • No Wiggle: Gravity=3, TimeStep=0.025, Modified Euler

Update Nov 2011: The fix to ContactSim.calculate_b_vector which "adjusts acceleration to eliminate velocity at contacts" has eliminated the wiggling in the above cases. One case that is still problematic is when using inverse square gravity: with gravity=10 you need to reduce the timeStep to 0.01 to stop endless collisions.

TO DO remove the 'endless loop' checkbox, and instead just have the 'loop time' numeric control. To make the UI simpler by having one less UI item.

This app has a config() method which looks at a set of options and rebuilds the simulation accordingly. UI controls are created to change the options.

Hierarchy (view full)




  • Adds the given Observer to this Subject's list of Observers, so that the Observer will be notified of changes in this Subject. An Observer may call Subject.addObserver during its observe method.


    Returns void

  • Define short-cut name replacement rules. For example 'sim' is replaced by 'myApp.sim' when myName is 'myApp'.


    • myName: string

      the name of this object, valid in global Javascript context.

    Returns void

  • Parameters

    • script: string
    • output: boolean = true

      whether to print the result to the output text area and add the script to session history; default is true

    Returns any

    the result of evaluating the string

  • Returns the seed of the random number generator used to determine sizes of blocks.

    Returns number

  • Sets whether this Subject will broadcast events, typically used to temporarily disable broadcasting. Intended to be used in situations where a subclass overrides a method that broadcasts an event. This allows the subclass to prevent the superclass broadcasting that event, so that the subclass can broadcast the event when the method is completed.


    • value: boolean

      whether this Subject should broadcast events

    Returns boolean

    the previous value

  • Sets the seed of the random number generator used to determine sizes of blocks


    • value: number

    Returns void

  • 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:


    Returns string

    a minimal string representation of this object.

Generated using TypeDoc