Provides a ParameterNumber for setting the elasticity of all RigidBodys in an RigidBodySim.

ElasticitySetter remembers the last value it had even when there are no RigidBodys. This is useful in situations where an application makes a new configuration of RigidBodys and wants to find the user's desired value for elasticity.

WARNING The elasticity reported here is only accurate if all modifications to elasticity of RigidBodys are done thru this class or via RigidBodySim.setElasticity.

Parameters Created

Hierarchy (view full)

Implements

Properties

lastValue_: number = 0

last value that was reported to an outside entity.

Methods

  • Returns the minimum elasticity among all RigidBodys in the simulation. If there are no RigidBodys, then the last value set or calculated is returned. Elasticity is used when calculating collisions; a value of 1.0 means perfect elasticity where the kinetic energy after collision is the same as before (extremely bouncy), while a value of 0 means no elasticity (no bounce).

    Returns number

    elasticity used when calculating collisions, a number from 0 to 1.

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

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

    Parameters

    • value: boolean

      whether this Subject should broadcast events

    Returns boolean

    the previous value

  • Sets the elasticity of all RigidBodys in the simulation. If there are no RigidBodys, then stores the value internally. Elasticity is used when calculating collisions; a value of 1.0 means perfect elasticity where the kinetic energy after collision is the same as before (extremely bouncy), while a value of 0 means no elasticity (no bounce).

    Parameters

    • value: number

      elasticity used when calculating collisions, a number from 0 to 1.

    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:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc