Utility functions for making the 'pile of blocks' simulation.

Methods

  • Returns a random 'somewhat bright' color. Avoids near-white colors.

    Parameters

    Returns string

    a random color

  • Makes two blocks that are rigidly connected by two double joints, so that the blocks cannot move relative to each other. This is for testing that situations with redundant joints can be handled correctly.

    Parameters

    • sim: ContactSim

      the ContactSim to add the bodies

    • x: number

      the horizontal location to move the first block

    • y: number

      the vertical location to move the first block

    • angle: number

      the angle to set the blocks

    Returns Polygon[]

    array containing the two blocks

  • Makes two 'pits' for the blocks to fall into.

    Parameters

    • sim: ContactSim
    • Optional opt_offset: number

      vertical offset for position of walls

    Returns number

    suggested zero energy level for blocks

  • Make several blocks of random sizes (and default colors), position the first one at the given location and position the others to the right of that first block. The sizes of the blocks range from 0.2 to 1.2 on each side.

    Parameters

    • sim: ContactSim

      the ContactSim to add the bodies

    • n: number

      the number of blocks to create

    • x: number

      the location for the first block

    • y: number

      the location for the first block

    • random: Random

      the random number generator to use for building blocks

    • Optional rightAngle: boolean

      whether to make right-angle blocks

    Returns Polygon[]

    the blocks that were created

  • Makes a rectangular array of same-sized square blocks or circular balls that fill the given rectangle.

    Parameters

    • sim: ContactSim

      the ContactSim to add the blocks to

    • rect: DoubleRect

      rectangle to fill with blocks

    • circular: boolean

      whether to make circular balls or square blocks

    • size: number

      the radius of circular balls or half-width of square blocks

    • buffer: number

      distance between each block

    • limit: number

      maximum number of blocks to make

    Returns void

  • Makes a single V-shaped 'pit' for blocks to fall into.

    Parameters

    • sim: ContactSim
    • Optional opt_offset: number

      vertical offset for position of walls

    Returns number

    suggested zero energy level for blocks

Generated using TypeDoc