public class DistanceJointDef

  1. Object
  2. JointDef
  3. DistanceJointDef
Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game.
Warning. Do not use a zero or short length.

Fields

public final Vec2 localAnchorAThe local anchor point relative to body1’s origin.
public final Vec2 localAnchorBThe local anchor point relative to body2’s origin.
public float lengthThe equilibrium length between the anchor points.
public float frequencyHzThe mass-spring-damper frequency in Hertz.
public float dampingRatioThe damping ratio.

Constructors

public DistanceJointDef()

Methods

public void initialize(Body b1, Body b2, Vec2 anchor1, Vec2 anchor2)Initialize the bodies, anchors, and length using the world anchors.

Inherited fields

Inherited methods

Field details

localAnchorA

public final Vec2 localAnchorA
The local anchor point relative to body1’s origin.

localAnchorB

public final Vec2 localAnchorB
The local anchor point relative to body2’s origin.

length

public float length
The equilibrium length between the anchor points.

frequencyHz

public float frequencyHz
The mass-spring-damper frequency in Hertz.

dampingRatio

public float dampingRatio
The damping ratio. 0 = no damping, 1 = critical damping.

Constructor details

DistanceJointDef

public DistanceJointDef()

Method details

initialize

public void initialize(Body b1, Body b2, Vec2 anchor1, Vec2 anchor2)
Initialize the bodies, anchors, and length using the world anchors.

Parameters

b1 Body
First body
b2 Body
Second body
anchor1 Vec2
World anchor on first body
anchor2 Vec2
World anchor on second body