Box2D. 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, anchoropt, collideopt)

Create a revolute joint

Parameters:
NameTypeAttributesDefaultDescription
objectABox2dObject
objectBBox2dObject
anchorVector2<optional>

World position, objectB's position if not given

collideboolean<optional>
false

Extends

  • Box2dJoint

Methods

enableLimit(enableopt)

Enable/disable the joint limit

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

enableMotor(enableopt)

Enable/disable the joint motor

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

getJointAngle() → {number}

Get the current joint angle, clockwise like angle

Returns:
Type: 
number

getJointSpeed() → {number}

Get the current joint angle speed in radians per second, clockwise like angle

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, clockwise like angle

Returns:
Type: 
number

getMaxMotorTorque() → {number}

Get the max motor torque

Returns:
Type: 
number

getMotorSpeed() → {number}

Get the motor speed, clockwise like angle

Returns:
Type: 
number

getMotorTorque(timeopt) → {number}

Get the motor torque over the last step, clockwise like angle

Parameters:
NameTypeAttributesDescription
timenumber<optional>

The step length in seconds, the world steps by timeDelta

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, clockwise like angle

Returns:
Type: 
number

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, clockwise like angle

Parameters:
NameTypeDescription
minnumber
maxnumber

setMaxMotorTorque(torque)

Set the max motor torque, a magnitude

Parameters:
NameTypeDescription
torquenumber

setMotorSpeed(speed)

Set the motor speed, clockwise like angle

Parameters:
NameTypeDescription
speednumber