An interface that allows us to add a circle or line to the display from anywhere in the engine2D code. This interface solves some problems with circular dependencies. The calling code can access the functions via UtilEngine.debugEngine2D, without referring to RigidBodySim (which is what actually implements the functions).

To control the color of the objects that are created: Find the place where the DisplayObjects are created (e.g. DisplayLine, DisplayShape) such as RigidBodyObserver; add code there that looks for objects with particular names, and apply desired color.

interface DebugEngine2D {
    debugCircle(name, center, radius, expireTime?): void;
    debugLine(name, pa, pb, expireTime?): void;
    getTime(): number;
    myPrint(message, ...colors): void;
}

Implemented by

Methods

  • Creates a PointMass which is displayed as a circle, and adds it to the SimList, for debugging only. The expiration time on temporary SimObjects is set to 'now', so that they are removed right away during the next call to advance().

    Parameters

    • name: string

      name of the SimObject that is created

    • center: GenericVector

      center of the circle

    • radius: number

      radius of the circle

    • Optional expireTime: number

      the time when the DisplayObject will be removed; the default expireTime is 'now'.

    Returns void

  • Creates a ConcreteLine and adds it to the SimList, for debugging only. The expiration time on temporary SimObjects is set to 'now', so that they are removed right away during the next call to advance().

    Parameters

    • name: string

      name of the SimObject that is created

    • pa: Vector

      starting point of the line

    • pb: Vector

      ending point of the line

    • Optional expireTime: number

      the time when the DisplayObject will be removed; the default expireTime is 'now'.

    Returns void

  • Prints the message to console, preceded by the current simulation time. Draws the time in green, the message in black; you can add colors in the message by adding more '%c' symbols in the message string and pass additional colors.

    Parameters

    • message: string

      message to print, optionally with '%c' where color changes are desired

    • Rest ...colors: string[]

      CSS color or background strings, to change the color in the message at points in the message marked by the string '%c'

    Returns void

Generated using TypeDoc