the first body of the Joint
the attachment point on the first body in body coordinates
the second body of the Joint
the attachment point on the second body
whether the normal is in world coordinates or body coordinates
of rigidBody2
this Joint's normal vector in world coordinates or body coordinates
of rigidBody2
Private
attach1_attachment point in body coords for body1
Private
attach2_attachment point in body coords for body2
Private
body1_first body of the joint
Private
body2_second body of the joint
Private
normalwhether the normal is in body coords and moves with the body, or is in fixed world coords
Private
normal_the normal direction.
Static
IDCounter used for naming SimObjects.
Adds RigidBodyCollisions for this Connector to an array of collisions.
the array of collisions to which to add the RigidBodyCollision for this Connector.
simulation time when this collision is detected
distance accuracy: how close we must be to the point of collision in order to be able to handle it.
Returns a rectangle that contains this SimObject in world coordinates.
rectangle that contains this SimObject in world coordinates
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.
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.
Optional
opt_localized: booleantrue
means return the localized version of the name;
default is false
which means return the language independent name.
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.
normal distance between attachment points of the bodies
Whether this implements the MassObject interface.
Whether this implements the MassObject interface.
Whether this SimObject has the given name, adjusting for transformation to the language-independent form of the name, as is done by Util.toName.
the English or language-independent version of the name
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.
the expiration time, in time frame of the Simulation clock
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.
the SimObject to compare to
Optional
_opt_tolerance: numberthe amount the object components can differ by
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'}}
a minimal string representation of this object.
Updates the collision to reflect current state (position, velocity, etc.) of bodies involved.
the RigidBodyCollision to update
Generated using TypeDoc
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 areimpact, impact2, R
andR2
. We figure the impact point on each body according to where the attachment point is on that body, by doing abodyToWorld
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 theR2
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 ofbody1
to define where the joint is onbody2
.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.