Represents an object in a Simulation. The purpose of a SimObject is two-fold:

  1. To give the outside world a view of what is going on in the Simulation.

  2. A SimObject might be used in a Simulation's internal calculations.

A set of SimObjects are stored in a SimList. The SimObjects represent the current state of the Simulation.

For an ODESim the current state is dictated by the variables in its VarsList and the SimObjects reflect that state in their positions and velocities.

A SimObject can give additional information that is not in the VarsList, such as size, shape, and mass of objects. A SimObject can represent forces or anchor objects which are not available in the VarsList.

SimObjects are updated to reflect the current state when Simulation.modifyObjects is called.

See DisplayObject for a discussion of how SimObjects are made visible to the user.

A SimObject has an expiration time so that we can add temporary objects, representing things like forces or collision impact, and set the time at which they should be removed from the simulation display. Permanent SimObjects have infinite expiration time. See getExpireTime.

interface SimObject {
    getBoundsWorld(): DoubleRect;
    getChanged(): boolean;
    getExpireTime(): number;
    getName(opt_localized?): string;
    isMassObject(): boolean;
    nameEquals(name): boolean;
    setChanged(): void;
    setExpireTime(time): void;
    similar(obj, opt_tolerance?): boolean;
    toStringShort(): string;
}

Hierarchy (view full)

Implemented by

Methods

  • Returns whether this SimObject has changed, and sets the state to "unchanged".

    Returns boolean

    whether this SimObject has changed

  • Returns the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.

    Returns number

    the expiration time, in time frame of the Simulation clock

  • Name of this SimObject, either the language-independent name for scripting purposes or the localized name for display to user.

    The language-independent name should be the same as the English version but capitalized and with spaces and dashes replaced by underscore, see Util.toName, nameEquals.

    The name should give an idea of the role of the SimObject in the simulation. This allows us to to treat an object in a special way depending on its name. For example, we might use the name to decide what type of DisplayObject to create to represent the SimObject.

    Parameters

    • Optional opt_localized: boolean

      true means return the localized version of the name; default is false which means return the language independent name.

    Returns string

    name of this SimObject

  • Whether this SimObject has the given name, adjusting for transformation to the language-independent form of the name, as is done by Util.toName.

    Parameters

    • name: string

      the English or language-independent version of the name

    Returns boolean

    whether this SimObject has the given name (adjusted to language-independent form)

  • Sets the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.

    Parameters

    Returns void

  • Returns true if the given SimObject is similar to this SimObject for display purposes. SimObjects are similar when they are the same type and nearly the same size and location. Mainly used when showing forces - to avoid adding too many objects to the display. See SimList.getSimilar.

    Parameters

    • obj: SimObject

      the SimObject to compare to

    • Optional opt_tolerance: number

      the amount the object components can differ by

    Returns boolean

    true if this SimObject is similar to obj for display purposes

  • 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