DistanceJointDef class
class DistanceJointDef extends JointDef { /** The local anchor point relative to body1's origin. */ final Vector2 localAnchorA; /** The local anchor point relative to body2's origin. */ final Vector2 localAnchorB; /** The equilibrium length between the anchor points. */ double length; /** * The mass-spring-damper frequency in Hertz. */ double frequencyHz; /** * The damping ratio. 0 = no damping, 1 = critical damping. */ double dampingRatio; DistanceJointDef() : super(), localAnchorA = new Vector2(0.0, 0.0), localAnchorB = new Vector2(0.0, 0.0), length = 1.0, frequencyHz = 0.0, dampingRatio = 0.0 { type = JointType.DISTANCE; } /** * Initialize the bodies, anchors, and length using the world * anchors. * b1: First body * b2: Second body * anchor1: World anchor on first body * anchor2: World anchor on second body */ void initialize(Body b1, Body b2, Vector2 anchor1, Vector2 anchor2) { bodyA = b1; bodyB = b2; localAnchorA.setFrom(bodyA.getLocalPoint(anchor1)); localAnchorB.setFrom(bodyB.getLocalPoint(anchor2)); Vector2 d = new Vector2.copy(anchor2); d.sub(anchor1); length = d.length; } }
Extends
JointDef > DistanceJointDef
Constructors
new DistanceJointDef() #
DistanceJointDef() : super(), localAnchorA = new Vector2(0.0, 0.0), localAnchorB = new Vector2(0.0, 0.0), length = 1.0, frequencyHz = 0.0, dampingRatio = 0.0 { type = JointType.DISTANCE; }
Properties
bool collideConnected #
inherited from JointDef
Set this flag to true if the attached bodies should collide.
bool collideConnected
final Vector2 localAnchorA #
The local anchor point relative to body1's origin.
final Vector2 localAnchorA
final Vector2 localAnchorB #
The local anchor point relative to body2's origin.
final Vector2 localAnchorB
Methods
void initialize(Body b1, Body b2, Vector2 anchor1, Vector2 anchor2) #
Initialize the bodies, anchors, and length using the world anchors. b1: First body b2: Second body anchor1: World anchor on first body anchor2: World anchor on second body
void initialize(Body b1, Body b2, Vector2 anchor1, Vector2 anchor2) { bodyA = b1; bodyB = b2; localAnchorA.setFrom(bodyA.getLocalPoint(anchor1)); localAnchorB.setFrom(bodyB.getLocalPoint(anchor2)); Vector2 d = new Vector2.copy(anchor2); d.sub(anchor1); length = d.length; }