Dart Documentationbox2dDistanceJointDef

DistanceJointDef class

class DistanceJointDef extends JointDef {
 /** The local anchor point relative to body1's origin. */
 final vec2 localAnchorA;

 /** The local anchor point relative to body2's origin. */
 final vec2 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 vec2.zero(),
   localAnchorB = new vec2.zero(),
   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, vec2 anchor1, vec2 anchor2) {
   bodyA = b1;
   bodyB = b2;
   localAnchorA.copyFrom(bodyA.getLocalPoint(anchor1));
   localAnchorB.copyFrom(bodyB.getLocalPoint(anchor2));
   length = (anchor2 - anchor1).length;
 }
}

Extends

JointDef > DistanceJointDef

Constructors

new DistanceJointDef() #

DistanceJointDef() :
 super(),
 localAnchorA = new vec2.zero(),
 localAnchorB = new vec2.zero(),
 length = 1.0,
 frequencyHz = 0.0,
 dampingRatio = 0.0 {
 type = JointType.DISTANCE;
}

Properties

Body bodyA #

inherited from JointDef
bodyA

Body bodyB #

inherited from JointDef
bodyB

bool collideConnected #

inherited from JointDef
collideConnected

num dampingRatio #

dampingRatio

num frequencyHz #

frequencyHz

num length #

length

final vec2 localAnchorA #

localAnchorA

final vec2 localAnchorB #

localAnchorB

int type #

inherited from JointDef
type

Object userData #

inherited from JointDef
userData

Methods

void initialize(Body b1, Body b2, vec2 anchor1, vec2 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, vec2 anchor1, vec2 anchor2) {
 bodyA = b1;
 bodyB = b2;
 localAnchorA.copyFrom(bodyA.getLocalPoint(anchor1));
 localAnchorB.copyFrom(bodyB.getLocalPoint(anchor2));
 length = (anchor2 - anchor1).length;
}