lib/joint/WeldJoint.js
function WeldJoint(def, bodyA, bodyB, anchor) {
  if (!(this instanceof WeldJoint)) {
    return new WeldJoint(def, bodyA, bodyB, anchor);
  }

  def = options(def, DEFAULTS);
  Joint.call(this, def, bodyA, bodyB);
  bodyA = this.m_bodyA;
  bodyB = this.m_bodyB;

  this.m_type = WeldJoint.TYPE;

  this.m_localAnchorA = anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero();
  this.m_localAnchorB = anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero();
  this.m_referenceAngle = Math.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();

  this.m_frequencyHz = def.frequencyHz;
  this.m_dampingRatio = def.dampingRatio;

  this.m_impulse = Vec3();

  this.m_bias = 0.0;
  this.m_gamma = 0.0;

  // Solver temp
  this.m_rA; // Vec2
  this.m_rB; // Vec2
  this.m_localCenterA; // Vec2
  this.m_localCenterB; // Vec2
  this.m_invMassA; // float
  this.m_invMassB; // float
  this.m_invIA; // float
  this.m_invIB; // float
  this.m_mass = new Mat33();

  // Point-to-point constraint
  // C = p2 - p1
  // Cdot = v2 - v1
  // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)
  // J = [-I -r1_skew I r2_skew ]
  // Identity used:
  // w k % (rx i + ry j) = w * (-ry i + rx j)

  // Angle constraint
  // C = angle2 - angle1 - referenceAngle
  // Cdot = w2 - w1
  // J = [0 0 -1 0 0 1]
  // K = invI1 + invI2
}
function WeldJoint(def, bodyA, bodyB, anchor) {
  if (!(this instanceof WeldJoint)) {
    return new WeldJoint(def, bodyA, bodyB, anchor);
  }

  def = options(def, DEFAULTS);
  Joint.call(this, def, bodyA, bodyB);
  bodyA = this.m_bodyA;
  bodyB = this.m_bodyB;

  this.m_type = WeldJoint.TYPE;

  this.m_localAnchorA = anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero();
  this.m_localAnchorB = anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero();
  this.m_referenceAngle = Math.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();

  this.m_frequencyHz = def.frequencyHz;
  this.m_dampingRatio = def.dampingRatio;

  this.m_impulse = Vec3();

  this.m_bias = 0.0;
  this.m_gamma = 0.0;

  // Solver temp
  this.m_rA; // Vec2
  this.m_rB; // Vec2
  this.m_localCenterA; // Vec2
  this.m_localCenterB; // Vec2
  this.m_invMassA; // float
  this.m_invMassB; // float
  this.m_invIA; // float
  this.m_invIB; // float
  this.m_mass = new Mat33();

  // Point-to-point constraint
  // C = p2 - p1
  // Cdot = v2 - v1
  // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)
  // J = [-I -r1_skew I r2_skew ]
  // Identity used:
  // w k % (rx i + ry j) = w * (-ry i + rx j)

  // Angle constraint
  // C = angle2 - angle1 - referenceAngle
  // Cdot = w2 - w1
  // J = [0 0 -1 0 0 1]
  // K = invI1 + invI2
}
function WeldJoint ( def , bodyA , bodyB , anchor ) { if ( ! ( this instanceof WeldJoint ) ) { return new WeldJoint ( def , bodyA , bodyB , anchor ) ; } def = options ( def , DEFAULTS ) ; Joint . call ( this , def , bodyA , bodyB ) ; bodyA = this . m_bodyA ; bodyB = this . m_bodyB ; this . m_type = WeldJoint . TYPE ; this . m_localAnchorA = anchor ? bodyA . getLocalPoint ( anchor ) : def . localAnchorA || Vec2 . zero ( ) ; this . m_localAnchorB = anchor ? bodyB . getLocalPoint ( anchor ) : def . localAnchorB || Vec2 . zero ( ) ; this . m_referenceAngle = Math . isFinite ( def . referenceAngle ) ? def . referenceAngle : bodyB . getAngle ( ) - bodyA . getAngle ( ) ; this . m_frequencyHz = def . frequencyHz ; this . m_dampingRatio = def . dampingRatio ; this . m_impulse = Vec3 ( ) ; this . m_bias = 0.0 ; this . m_gamma = 0.0 ; // Solver temp this . m_rA ; // Vec2 this . m_rB ; // Vec2 this . m_localCenterA ; // Vec2 this . m_localCenterB ; // Vec2 this . m_invMassA ; // float this . m_invMassB ; // float this . m_invIA ; // float this . m_invIB ; // float this . m_mass = new Mat33 ( ) ; // Point-to-point constraint // C = p2 - p1 // Cdot = v2 - v1 // / = v2 + cross(w2, r2) - v1 - cross(w1, r1) // J = [-I -r1_skew I r2_skew ] // Identity used: // w k % (rx i + ry j) = w * (-ry i + rx j) // Angle constraint // C = angle2 - angle1 - referenceAngle // Cdot = w2 - w1 // J = [0 0 -1 0 0 1] // K = invI1 + invI2 }
A weld joint essentially glues two bodies together. A weld joint may distort
somewhat because the island constraint solver is approximate.

@param {WeldJointDef} def
@param {Body} bodyA
@param {Body} bodyB
A weld joint essentially glues two bodies together . A weld joint may distort somewhat because the island constraint solver is approximate .