File:addBox2D\Dynamics\Joints\b2RevoluteJointDef.js
//################################################################################################//
//################################################################################################//
// //
// ██████ ██ ██ ██ ██ ██ █████ ████ //
// ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ █████ ██ ██ █████ ██ ██ ██ █████ █████ ██ █████ ██ █████ █████ ██ ██ █████ ██ //
// ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ //
// ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ //
// ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ █████ ███ █████ ██ █████ ████ █████ █████ █████ ██ ██ ██ ████ █████ █████ ██ //
// //
//################################################################################################//
//################################################################################################//
// CLASS CONSTRUCTOR
/**
* Revolute joint definition. This requires defining an anchor
* point where the bodies are joined. The definition uses local
* anchor points so that the initial configuration can violate
* the constraint slightly. You also need to specify the initial
* relative angle for joint limits. This helps when saving and
* loading a game.
*
* The local anchor points are measured from the body's origin
* rather than the center of mass because:
* 1. you might not know where the center of mass will be.
* 2. if you add/remove shapes from a body and recompute the
* mass, the joints will be broken.
*
* @class b2RevoluteJointDef
* @constructor
* @extends {b2JointDef}
* @module Joints
*/
function b2RevoluteJointDef() {
/**
*Invoke parent class constructor function reference.
*/
this.constructor( b2Joint.e_revoluteJoint );
////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ██████ ██ ██ //
// ██ ██ ██ //
// ██ ██ ████ █████ █████ █████ ████ █████ ██ █████ █████ //
// ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ █████ █████ //
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ █████ █████ █████ ██ ████ ██ █████ █████ //
// ██ //
// ██ //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
// property DECLARATIONS
/**
* The local anchor point relative to bodyA's origin.
*
* @public
* @property localAnchorA
* @type {b2Vec2}
*/
this.localAnchorA = new b2Vec2;
/**
* The local anchor point relative to bodyB's origin.
*
* @public
* @property localAnchorB
* @type {b2Vec2}
*/
this.localAnchorB = new b2Vec2;
// property INITIALISATIONS
/**
* @public
* @property type
* @type {int}
*/
// @this.constructor( b2Joint.e_revoluteJoint ) above
/**
* The bodyB angle minus bodyA angle in the reference state
* (radians).
*
* @public
* @property referenceAngle
* @type {float}
* @default 0.0
*/
this.referenceAngle = 0.0;
/**
* A flag to enable joint limits.
*
* @public
* @property lowerAngle
* @type {boolean}
* @default false
*/
this.enableLimit = false;
/**
* A flag to enable the joint motor.
*
* @public
* @property enableMotor
* @type {boolean}
* @default false
*/
this.enableMotor = false;
/**
* The lower angle for the joint limit (radians).
*
* @public
* @property lowerAngle
* @type {float}
* @default 0.0
*/
this.lowerAngle = 0.0;
/**
* The upper angle for the joint limit (radians).
*
* @public
* @property upperAngle
* @type {float}
* @default 0.0
*/
this.upperAngle = 0.0;
/**
* The maximum motor torque used to achieve the desired motor
* speed. Usually in N-m.
*
* @public
* @property maxMotorTorque
* @type {float}
* @default 0.0
*/
this.maxMotorTorque = 0.0;
/**
* The desired motor speed. Usually in radians per second.
*
* @public
* @property motorSpeed
* @type {float}
* @default 0.0
*/
this.motorSpeed = 0.0;
////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ██ ██ ██ ██ //
// ██ ██ ██ //
// ██ █████ █████ █████ ████ ██ █████ █████ █████ █████ █████ //
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ ██ ██ ██ █████ ██ ██ ██ █████ ██ ██ ██ █████ //
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ ██ ██ ██ █████ ██ ██ ████ █████ ██ ██ █████ █████ //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
} b2RevoluteJointDef.prototype = p = new b2JointDef; Box2D.b2RevoluteJointDef = b2RevoluteJointDef;
////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ██ ██ ██ ██ ██ //
// ███ ███ ██ ██ ██ //
// ███████ █████ █████ █████ █████ █████ █████ //
// ██ █ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ █████ //
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ //
// ██ ██ █████ ████ ██ ██ █████ █████ █████ //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
// INSTANCE METHODS
/**
* @public
* @method initialize
* @param {b2Body} bodyA
* @param {b2Body} bodyB
* @param {b2Vec2} anchor
* @return {void}
*/
p.initialize = function ( bodyA, bodyB, anchor ) {
this.bodyA = bodyA;
this.bodyB = bodyB;
this.bodyA.getLocalPoint( anchor, this.localAnchorA );
this.bodyB.getLocalPoint( anchor, this.localAnchorB );
this.referenceAngle = this.bodyB.getAngle() - this.bodyA.getAngle();
};