Class DistanceJointDef

java.lang.Object
org.jbox2d.dynamics.joints.JointDef
org.jbox2d.dynamics.joints.DistanceJointDef

public class DistanceJointDef extends JointDef
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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The damping ratio.
    float
    The mass-spring-damper frequency in Hertz.
    float
    The equilibrium length between the anchor points.
    final Vec2
    The local anchor point relative to body1's origin.
    final Vec2
    The local anchor point relative to body2's origin.

    Fields inherited from class org.jbox2d.dynamics.joints.JointDef

    bodyA, bodyB, collideConnected, type, userData
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - First body
      b2 - Second body
      anchor1 - World anchor on first body
      anchor2 - World anchor on second body