Class DistanceJoint

java.lang.Object
org.jbox2d.dynamics.joints.Joint
org.jbox2d.dynamics.joints.DistanceJoint

public class DistanceJoint extends Joint
A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.

One of the simplest joint is a distance joint which says that the distance between two points on two bodies must be constant. When you specify a distance joint the two bodies should already be in place. Then you specify the two anchor points in world coordinates. The first anchor point is connected to body 1, and the second anchor point is connected to body 2. These points imply the length of the distance constraint.

distance joint

Here is an example of a distance joint definition. In this case we decide to allow the bodies to collide.

The distance joint can also be made soft, like a spring-damper connection.

Softness is achieved by tuning two constants in the definition: stiffness and damping. It can be non-intuitive setting these values directly since they have units in terms on Newtons.

Think of the frequency as the frequency of a harmonic oscillator (like a guitar string). The frequency is specified in Hertz. Typically the frequency should be less than a half the frequency of the time step. So if you are using a 60Hz time step, the frequency of the distance joint should be less than 30Hz. The reason is related to the Nyquist frequency.

The damping ratio is non-dimensional and is typically between 0 and 1, but can be larger. At 1, the damping is critical (all oscillations should vanish).

It is also possible to define a minimum and maximum length for the distance joint.

Author:
Daniel Murphy
Repolink:
Github: erincatto/box2d src/dynamics/b2_distance_joint.cpp