lib/joint/FrictionJoint.js
function FrictionJoint(def, bodyA, bodyB, anchor) {
  if (!(this instanceof FrictionJoint)) {
    return new FrictionJoint(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 = FrictionJoint.TYPE;

  this.m_localAnchorA = anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero();
  this.m_localAnchorB = anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero();

  // Solver shared
  this.m_linearImpulse = Vec2.zero();
  this.m_angularImpulse = 0.0;
  this.m_maxForce = def.maxForce;
  this.m_maxTorque = def.maxTorque;

  // 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_linearMass; // Mat22
  this.m_angularMass; // float

  // Point-to-point constraint
  // 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
  // Cdot = w2 - w1
  // J = [0 0 -1 0 0 1]
  // K = invI1 + invI2
}
function FrictionJoint(def, bodyA, bodyB, anchor) {
  if (!(this instanceof FrictionJoint)) {
    return new FrictionJoint(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 = FrictionJoint.TYPE;

  this.m_localAnchorA = anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero();
  this.m_localAnchorB = anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero();

  // Solver shared
  this.m_linearImpulse = Vec2.zero();
  this.m_angularImpulse = 0.0;
  this.m_maxForce = def.maxForce;
  this.m_maxTorque = def.maxTorque;

  // 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_linearMass; // Mat22
  this.m_angularMass; // float

  // Point-to-point constraint
  // 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
  // Cdot = w2 - w1
  // J = [0 0 -1 0 0 1]
  // K = invI1 + invI2
}
function FrictionJoint ( def , bodyA , bodyB , anchor ) { if ( ! ( this instanceof FrictionJoint ) ) { return new FrictionJoint ( 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 = FrictionJoint . TYPE ; this . m_localAnchorA = anchor ? bodyA . getLocalPoint ( anchor ) : def . localAnchorA || Vec2 . zero ( ) ; this . m_localAnchorB = anchor ? bodyB . getLocalPoint ( anchor ) : def . localAnchorB || Vec2 . zero ( ) ; // Solver shared this . m_linearImpulse = Vec2 . zero ( ) ; this . m_angularImpulse = 0.0 ; this . m_maxForce = def . maxForce ; this . m_maxTorque = def . maxTorque ; // 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_linearMass ; // Mat22 this . m_angularMass ; // float // Point-to-point constraint // 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 // Cdot = w2 - w1 // J = [0 0 -1 0 0 1] // K = invI1 + invI2 }
Friction joint. This is used for top-down friction. It provides 2D
translational friction and angular friction.

@param {FrictionJointDef} def
@param {Body} bodyA
@param {Body} bodyB
@param {Vec2} anchor Anchor in global coordination.
Friction joint . This is used for top - down friction . It provides 2D translational friction and angular friction .