Box2dRevoluteJoint

Box2D Revolute Joint

  • Constrains two objects to share a point while they are free to rotate around the point
  • The relative rotation about the shared point is the joint angle
  • You can limit the relative rotation with a joint limit
  • You can use a motor to drive the relative rotation about the shared point
  • A maximum motor torque is provided so that infinite forces are not generated

Constructor

new Box2dRevoluteJoint(objectA, objectB, anchor, collideopt)

Create a revolute joint

Parameters:
NameTypeAttributesDefaultDescription
objectABox2dObject
objectBBox2dObject
anchorVector2
collideboolean<optional>
false

Extends

Methods

destroy()

Destroy this joint

enableLimit(enableopt)

Enable/disable the joint limit

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

enableMotor(enableopt)

Enable/disable the joint motor

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

getAnchorA() → {Vector2}

Get the first anchor for this joint in world coordinates

Returns:
Type: 
Vector2

getAnchorB() → {Vector2}

Get the second anchor for this joint in world coordinates

Returns:
Type: 
Vector2

getCollideConnected() → {boolean}

Check if the connected bodies should collide

Returns:
Type: 
boolean

getJointAngle() → {number}

Get the current joint angle

Returns:
Type: 
number

getJointSpeed() → {number}

Get the current joint angle speed in radians per second

Returns:
Type: 
number

getLocalAnchorA() → {Vector2}

Get the local anchor point relative to objectA's origin

Returns:
Type: 
Vector2

getLocalAnchorB() → {Vector2}

Get the local anchor point relative to objectB's origin

Returns:
Type: 
Vector2

getLowerLimit() → {number}

Get the lower joint limit

Returns:
Type: 
number

getMaxMotorTorque() → {number}

Get the max motor torque

Returns:
Type: 
number

getMotorSpeed() → {number}

Get the motor speed

Returns:
Type: 
number

getMotorTorque(time) → {number}

Get the motor torque given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
number

getObjectA() → {Box2dObject}

Get the first object attached to this joint

Returns:
Type: 
Box2dObject

getObjectB() → {Box2dObject}

Get the second object attached to this joint

Returns:
Type: 
Box2dObject

getReactionForce(time) → {Vector2}

Get the reaction force on bodyB at the joint anchor given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
Vector2

getReactionTorque(time) → {number}

Get the reaction torque on bodyB in N*m given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
number

getReferenceAngle() → {number}

Get the reference angle, objectB angle minus objectA angle in the reference state

Returns:
Type: 
number

getUpperLimit() → {number}

Get the upper joint limit

Returns:
Type: 
number

isActive() → {boolean}

Check if either connected body is active

Returns:
Type: 
boolean

isLimitEnabled() → {boolean}

Is the joint limit enabled?

Returns:
Type: 
boolean

isMotorEnabled() → {boolean}

Is the joint motor enabled?

Returns:
Type: 
boolean

setLimits(min, max)

Set the joint limits

Parameters:
NameTypeDescription
minnumber
maxnumber

setMaxMotorTorque(torque)

Set the motor torque

Parameters:
NameTypeDescription
torquenumber

setMotorSpeed(speed)

Set the motor speed

Parameters:
NameTypeDescription
speednumber