Rope connects two RigidBodys and limits the distance between the two attachment points on the bodies. A Rope can either be flexible so that the limit only occurs when it reaches its full length, or it can be a rigid inextensible rod. A Rope generates collisions or contact when the rope becomes tight. A flexible rope becomes tight when its length is close to or exceeds its rest length. A rigid rod is always tight and so is always generating collisions and contacts, similar to a Joint.

Ropes are immutable: they cannot be changed after they are constructed.

Rope uses 'curved edge physics' for calculating contact forces. See the paper Curved Edge Physics by Erik Neumann. The objects attached to a rope move in circles around each other, and so some extra contact force is needed to prevent the rope from being stretched beyond its length. The same analysis as used for curved edges applies here, except that we have the equivalent of two concave edges, so the radius used is negative.

align()

If this is an inextensible rod, then align() moves the bodies so that their attachment points are exactly rest length apart. If this is a flexible rope, then align() moves the bodies only if the distance is more than the rope's rest length (minus half of the contact distance tolerance). Moves the second body to align with the first body, maintaining the angle between them if possible.

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • body1: RigidBody

      the first body; can be an immoveable object like Scrim or an infinite mass Polygon

    • attach1_body: Vector

      attachment point in body coords for body1

    • body2: RigidBody

      the second body; must be moveable with finite mass

    • attach2: Vector

      attachment point in body coords for body2

    • length: number

      the maximum length of the rope (or fixed length of rod)

    • ropeType: number

      1 means rope, 2 means rod.

    Returns Rope

Properties

body2_: RigidBody

second body

distTol_: number

One of the bodies can be a Scrim which has zero distance tolerance, so find the max distance tolerance of the bodies.

veloTol_: number

One of the bodies can be a Scrim which has zero velocity tolerance, so find the max velocity tolerance of the bodies.

ID: number = 1

Counter used for naming SimObjects.

ropeNum: number = 0

For naming objects.

Methods

  • Adds RigidBodyCollisions for this Connector to an array of collisions.

    Parameters

    • collisions: RigidBodyCollision[]

      the array of collisions to which to add the RigidBodyCollision for this Connector.

    • time: number

      simulation time when this collision is detected

    • _accuracy: number

      distance accuracy: how close we must be to the point of collision in order to be able to handle it.

    Returns void

  • Aligns the RigidBodys connected by this Connector. See the documentation for the particular Connector for how the alignment is done.

    Returns void

  • Returns the distance between end points of this spring

    Returns number

    the distance between end points of this spring

  • 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 distance between attachment points of the bodies in the direction of the normal vector. This is equal to the dot product of the normal vector and the vector between the two attachment points.

    Returns number

    normal distance between attachment points of the bodies

  • Returns the maximum length of the rope (or fixed length of rod)

    Returns number

    the maximum length of the rope (or fixed length of rod)

  • Positive stretch means the rope is expanded, negative stretch means compressed.

    Returns number

    the amount that this line is stretched from its rest length

  • Returns true if the rope is tight, meaning its length is equal to its rest length.

    Returns boolean

    true if the rope is tight

  • 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