DistanceJointDef class
class DistanceJointDef extends JointDef { /** The local anchor point relative to body1's origin. */ final Vector localAnchorA; /** The local anchor point relative to body2's origin. */ final Vector localAnchorB; /** The equilibrium length between the anchor points. */ num length; /** * The mass-spring-damper frequency in Hertz. */ num frequencyHz; /** * The damping ratio. 0 = no damping, 1 = critical damping. */ num dampingRatio; DistanceJointDef() : super(), localAnchorA = new Vector(0.0, 0.0), localAnchorB = new Vector(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, Vector anchor1, Vector anchor2) { bodyA = b1; bodyB = b2; localAnchorA.setFrom(bodyA.getLocalPoint(anchor1)); localAnchorB.setFrom(bodyB.getLocalPoint(anchor2)); Vector d = new Vector.copy(anchor2); d.subLocal(anchor1); length = d.length; } }
Extends
JointDef > DistanceJointDef
Constructors
new DistanceJointDef() #
DistanceJointDef() : super(), localAnchorA = new Vector(0.0, 0.0), localAnchorB = new Vector(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;
num dampingRatio #
The damping ratio. 0 = no damping, 1 = critical damping.
num dampingRatio;
num frequencyHz #
The mass-spring-damper frequency in Hertz.
num frequencyHz;
num length #
The equilibrium length between the anchor points.
num length;
final Vector localAnchorA #
The local anchor point relative to body1's origin.
final Vector localAnchorA;
final Vector localAnchorB #
The local anchor point relative to body2's origin.
final Vector localAnchorB;
Methods
void initialize(Body b1, Body b2, Vector anchor1, Vector 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, Vector anchor1, Vector anchor2) { bodyA = b1; bodyB = b2; localAnchorA.setFrom(bodyA.getLocalPoint(anchor1)); localAnchorB.setFrom(bodyB.getLocalPoint(anchor2)); Vector d = new Vector.copy(anchor2); d.subLocal(anchor1); length = d.length; }