Box2D 3.2.0
A 2D physics engine for games
Loading...
Searching...
No Matches
Revolute Joint

A revolute joint allows for relative rotation in the 2D plane with no relative translation. More...

Data Structures

struct  b2RevoluteJointDef
 Revolute joint definition A point on body B is fixed to a point on body A. More...

Functions

b2JointId b2CreateRevoluteJoint (b2WorldId worldId, const b2RevoluteJointDef *def)
 Create a revolute joint.
void b2RevoluteJoint_EnableSpring (b2JointId jointId, bool enableSpring)
 Enable/disable the revolute joint spring.
bool b2RevoluteJoint_IsSpringEnabled (b2JointId jointId)
 Is the revolute angular spring enabled?
void b2RevoluteJoint_SetSpringHertz (b2JointId jointId, float hertz)
 Set the revolute joint spring stiffness in Hertz.
float b2RevoluteJoint_GetSpringHertz (b2JointId jointId)
 Get the revolute joint spring stiffness in Hertz.
void b2RevoluteJoint_SetSpringDampingRatio (b2JointId jointId, float dampingRatio)
 Set the revolute joint spring damping ratio, non-dimensional.
float b2RevoluteJoint_GetSpringDampingRatio (b2JointId jointId)
 Get the revolute joint spring damping ratio, non-dimensional.
void b2RevoluteJoint_SetTargetAngle (b2JointId jointId, float angle)
 Set the revolute joint spring target angle, radians.
float b2RevoluteJoint_GetTargetAngle (b2JointId jointId)
 Get the revolute joint spring target angle, radians.
void b2RevoluteJoint_EnableLimit (b2JointId jointId, bool enableLimit)
 Enable/disable the revolute joint limit.
bool b2RevoluteJoint_IsLimitEnabled (b2JointId jointId)
 Is the revolute joint limit enabled?
float b2RevoluteJoint_GetLowerLimit (b2JointId jointId)
 Get the revolute joint lower limit in radians.
float b2RevoluteJoint_GetUpperLimit (b2JointId jointId)
 Get the revolute joint upper limit in radians.
void b2RevoluteJoint_SetLimits (b2JointId jointId, float lower, float upper)
 Set the revolute joint limits in radians.
void b2RevoluteJoint_EnableMotor (b2JointId jointId, bool enableMotor)
 Enable/disable a revolute joint motor.
bool b2RevoluteJoint_IsMotorEnabled (b2JointId jointId)
 Is the revolute joint motor enabled?
void b2RevoluteJoint_SetTargetMotorSpeed (b2JointId jointId, float motorSpeed)
 Set the revolute joint motor speed in radians per second.
float b2RevoluteJoint_GetTargetMotorSpeed (b2JointId jointId)
 Get the revolute joint motor speed in radians per second.
void b2RevoluteJoint_SetMaxMotorTorque (b2JointId jointId, float torque)
 Set the revolute joint maximum motor torque, usually in newton-meters.
float b2RevoluteJoint_GetMaxMotorTorque (b2JointId jointId)
 Get the revolute joint maximum motor torque, usually in newton-meters.
float b2RevoluteJoint_GetCurrentAngle (b2JointId jointId)
 Get the revolute joint current angle in radians.
float b2RevoluteJoint_GetCurrentSpeed (b2JointId jointId)
 Get the current revolute joint motor speed in radians per second.
float b2RevoluteJoint_GetCurrentMotorTorque (b2JointId jointId)
 Get the revolute joint current motor torque, usually in newton-meters.
b2RevoluteJointDef b2DefaultRevoluteJointDef (void)
 Use this to initialize your joint definition.

Detailed Description

A revolute joint allows for relative rotation in the 2D plane with no relative translation.

Also called a hinge or pin joint.


Data Structure Documentation

◆ b2RevoluteJointDef

struct b2RevoluteJointDef

Revolute joint definition A point on body B is fixed to a point on body A.

Allows relative rotation.

Data Fields
b2JointDef base Base joint definition.
float dampingRatio The spring damping ratio, non-dimensional.
bool enableLimit A flag to enable joint limits.
bool enableMotor A flag to enable the joint motor.
bool enableSpring Enable a rotational spring on the revolute hinge axis.
float hertz The spring stiffness Hertz, cycles per second.
int internalValue Used internally to detect a valid definition. DO NOT SET.
float lowerAngle The lower angle for the joint limit in radians. Minimum of -0.99*pi radians.
float maxMotorTorque The maximum motor torque, typically in newton-meters.
float motorSpeed The desired motor speed in radians per second.
float targetAngle The target angle for the joint in radians. The spring-damper will drive to this angle.
float upperAngle The upper angle for the joint limit in radians. Maximum of 0.99*pi radians.

Function Documentation

◆ b2CreateRevoluteJoint()

b2JointId b2CreateRevoluteJoint ( b2WorldId worldId,
const b2RevoluteJointDef * def )

Create a revolute joint.

See also
b2RevoluteJointDef for details

◆ b2RevoluteJoint_GetCurrentAngle()

float b2RevoluteJoint_GetCurrentAngle ( b2JointId jointId)

Get the revolute joint current angle in radians.

This is the relative rotation of the joint frames.

◆ b2RevoluteJoint_SetLimits()

void b2RevoluteJoint_SetLimits ( b2JointId jointId,
float lower,
float upper )

Set the revolute joint limits in radians.

It is expected that lower <= upper and that -0.99 * B2_PI <= lower && upper <= 0.99 * B2_PI.