A Joint connects two RigidBodys by generating RigidBodyCollisions which are used to find contact forces or collision impulses so that the attachment points on the two RigidBodys are kept aligned together.

The addCollision method is where the collisions are generated; that method is called from ContactSim.findCollisions. The RigidBodyCollision generated for a Joint functions as both a collision and a contact.

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

When two RigidBodys are connected by a Joint, the two bodies are set to not collide with each other via RigidBody.addNonCollide.

The order of the bodies in the Joint is important because align moves the second body to align with first body (unless the second body is immoveable because it has infinite mass).

The normal vector provided when making a Joint specifies the direction along which the Joint operates. ContactSim calculates forces to keep the acceleration in the normal direction at zero between the two attachment points of the Joint.

A single joint by itself will give a 'sliding track' type of connection. The attachment points must have zero distance between them as measured in the direction of the normal for the Joint, but in the direction perpendicular to the normal the attachment points are free to move. See CartPendulum2 for an example.

A double joint consists of two Joints at the same location (same attachment points) with perpendicular normal directions. A double joint is needed to keep the attachment points aligned together.

Over time slippage of a Joint can occur, especially when there is fast rotation of the bodies. The tightness of a Joint is measured by how close to zero is the distance between the two attachment points. See getNormalDistance.

To attach to a fixed position in space use the Scrim object. Or attach to an immoveable (infinite mass) Polygon.

The two attachment points can be widely separated in 'single joints', see CartPendulum2 for an example.

Another name for a joint is a bilateral contact point meaning that it can both push and pull. This is different from ordinary contact points between bodies which can only push against each other.

Specifying a Joint's Normal Vector

When specifying a normal, we also specify the CoordType, which is either world coordinates or body coordinates. There are two cases:

  • CoordType.WORLD the normal is in world coordinates and is fixed.

  • CoordType.BODY The normal is calculated in the body coordinates of the second RigidBody of the Joint, and rotates along with that body.

(need to convert from Java) TO BE DONE To make a Joint with a NumericalPath use PathJoint. In that case it is the NumericalPath that determines the normal.

Aligning Joints

The align method aligns the RigidBodys connected by this Joint. Moves the second body to align with the first body (unless the second body has infinite mass, in which case the first body is aligned to the second). The second body is moved so that its attach point is at same position as the first body's attach point. The angle of the second body is not changed.

Implementation Note: Separate Impact Points

Each side of the Joint has its own impact point and R vector; these are impact, impact2, R and R2. We figure the impact point on each body according to where the attachment point is on that body, by doing a bodyToWorld translation to find the current location.

Previously we calculated the impact point only for body1 of the joint and then used that world location to calculate the R2 for the normal body. It seems that gives worse results, as shown by the 'two-connected-blocks' test where two blocks are connected rigidly by 2 double joints. When the two-connected-blocks is spun quickly, the joints slip significantly if we use the impact point of body1 to define where the joint is on body2.

TO DO should there be an option to have the normal attached to body1 instead of body2? It is confusing now because the 'body coords normal' is attached to body2 if it exists, otherwise it is attached to body1. This probably is because of how RigidBodyCollision follows this policy.

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • rigidBody1: RigidBody

      the first body of the Joint

    • attach1_body: Vector

      the attachment point on the first body in body coordinates

    • rigidBody2: RigidBody

      the second body of the Joint

    • attach2_body: Vector

      the attachment point on the second body

    • normalType: CoordType

      whether the normal is in world coordinates or body coordinates of rigidBody2

    • normal: Vector

      this Joint's normal vector in world coordinates or body coordinates of rigidBody2

    Returns Joint

Properties

attach1_body_: Vector

attachment point in body coords for body1

attach2_body_: Vector

attachment point in body coords for body2

body1_: RigidBody

first body of the joint

body2_: RigidBody

second body of the joint

normalType_: CoordType

whether the normal is in body coords and moves with the body, or is in fixed world coords

normal_: Vector

the normal direction.

ID: number = 1

Counter used for naming SimObjects.

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 attachment point on the first body in body coordinates.

    Returns Vector

    the attachment point on the first body in body coordinates

  • Returns the attachment point on the second body in body coordinates.

    Returns Vector

    the attachment point on the second body in body coordinates

  • 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 this Joint's unit normal vector, in body or world coordinates according to getNormalType. If in body coordinates it is relative to body2.

    Returns Vector

    this Joint's normal vector, in body or world coordinates

  • 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 this Joint's unit normal vector in world coordinates.

    Returns Vector

    this Joint's normal vector, in world coordinates

  • 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