A Force acts on a given MassObject at a defined location and with a defined direction and magnitude.

The method getStartPoint gives the location in world coordinates where the Force is applied. The method getVector gives the direction and magnitude of the Force in world coordinates.

The location and direction can be passed to the constructor either in fixed world coordinates, or in relative body coordinates. When given in body coordinates, the location and/or direction are calculated relative to the body's current position. See CoordType.

In RigidBodySim the torque affects the angular acceleration like this:

angular_acceleration += torque / RigidBody.momentAboutCM()

TO DO: move contactDistance and distanceTol to a sub-class called ContactForce?

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • name: string

      string indicating the type of force, e.g. 'gravity'

    • body: MassObject

      the MassObject that the Force is applied to

    • location: Vector

      the location on the body where the force is applied, in either body or world coordinates

    • locationCoordType: CoordType

      whether the location is in body or world coords

    • direction: Vector

      a Vector giving the direction and magnitude of the Force, in either body or world coordinates

    • directionCoordType: CoordType

      whether the direction is in body or world coords

    • Optional opt_torque: number

      torque to change angular acceleration of body

    Returns Force

Properties

body_: MassObject

which body the force is applied to

contactDistance: number = 0

gap between objects for contact force (optional info)

contactTolerance: number = 0

distance tolerance for contact force (optional info)

directionCoordType_: CoordType

whether direction is in body or world coords

direction_: Vector

direction & magnitude of force, in body or world coords

locationCoordType_: CoordType

whether location is in body or world coords

location_: Vector

where the force is applied, in body or world coords

torque_: number

torque to change angular acceleration of body

ID: number = 1

Counter used for naming SimObjects.

Methods

  • 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

  • Returns the torque which affects the angular acceleration.

    Returns number

    the torque which affects the angular acceleration.

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

      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