A revolute joint allows for relative rotation in the 2D plane with no relative translation. More...
Data Structures | |
struct | b2RevoluteJointDef |
Revolute joint definition. More... | |
Functions | |
B2_API b2JointId | b2CreateRevoluteJoint (b2WorldId worldId, const b2RevoluteJointDef *def) |
Create a revolute joint. | |
B2_API void | b2RevoluteJoint_EnableSpring (b2JointId jointId, bool enableSpring) |
Enable/disable the revolute joint spring. | |
B2_API bool | b2RevoluteJoint_IsSpringEnabled (b2JointId jointId) |
It the revolute angular spring enabled? | |
B2_API void | b2RevoluteJoint_SetSpringHertz (b2JointId jointId, float hertz) |
Set the revolute joint spring stiffness in Hertz. | |
B2_API float | b2RevoluteJoint_GetSpringHertz (b2JointId jointId) |
Get the revolute joint spring stiffness in Hertz. | |
B2_API void | b2RevoluteJoint_SetSpringDampingRatio (b2JointId jointId, float dampingRatio) |
Set the revolute joint spring damping ratio, non-dimensional. | |
B2_API float | b2RevoluteJoint_GetSpringDampingRatio (b2JointId jointId) |
Get the revolute joint spring damping ratio, non-dimensional. | |
B2_API float | b2RevoluteJoint_GetAngle (b2JointId jointId) |
Get the revolute joint current angle in radians relative to the reference angle. | |
B2_API void | b2RevoluteJoint_EnableLimit (b2JointId jointId, bool enableLimit) |
Enable/disable the revolute joint limit. | |
B2_API bool | b2RevoluteJoint_IsLimitEnabled (b2JointId jointId) |
Is the revolute joint limit enabled? | |
B2_API float | b2RevoluteJoint_GetLowerLimit (b2JointId jointId) |
Get the revolute joint lower limit in radians. | |
B2_API float | b2RevoluteJoint_GetUpperLimit (b2JointId jointId) |
Get the revolute joint upper limit in radians. | |
B2_API void | b2RevoluteJoint_SetLimits (b2JointId jointId, float lower, float upper) |
Set the revolute joint limits in radians. | |
B2_API void | b2RevoluteJoint_EnableMotor (b2JointId jointId, bool enableMotor) |
Enable/disable a revolute joint motor. | |
B2_API bool | b2RevoluteJoint_IsMotorEnabled (b2JointId jointId) |
Is the revolute joint motor enabled? | |
B2_API void | b2RevoluteJoint_SetMotorSpeed (b2JointId jointId, float motorSpeed) |
Set the revolute joint motor speed in radians per second. | |
B2_API float | b2RevoluteJoint_GetMotorSpeed (b2JointId jointId) |
Get the revolute joint motor speed in radians per second. | |
B2_API float | b2RevoluteJoint_GetMotorTorque (b2JointId jointId) |
Get the revolute joint current motor torque, usually in newton-meters. | |
B2_API void | b2RevoluteJoint_SetMaxMotorTorque (b2JointId jointId, float torque) |
Set the revolute joint maximum motor torque, usually in newton-meters. | |
B2_API float | b2RevoluteJoint_GetMaxMotorTorque (b2JointId jointId) |
Get the revolute joint maximum motor torque, usually in newton-meters. | |
b2RevoluteJointDef | b2DefaultRevoluteJointDef (void) |
Use this to initialize your joint definition. | |
A revolute joint allows for relative rotation in the 2D plane with no relative translation.
The revolute joint is probably the most common joint. It can be used for ragdolls and chains. Also called a hinge or pin joint.
struct b2RevoluteJointDef |
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:
Data Fields | ||
---|---|---|
b2BodyId | bodyIdA | The first attached body. |
b2BodyId | bodyIdB | The second attached body. |
bool | collideConnected | Set this flag to true if the attached bodies should collide. |
float | dampingRatio | The spring damping ratio, non-dimensional. |
float | drawSize | Scale the debug draw. |
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. |
b2Vec2 | localAnchorA | The local anchor point relative to bodyA's origin. |
b2Vec2 | localAnchorB | The local anchor point relative to bodyB's origin. |
float | lowerAngle | The lower angle for the joint limit in radians. Minimum of -0.95*pi radians. |
float | maxMotorTorque | The maximum motor torque, typically in newton-meters. |
float | motorSpeed | The desired motor speed in radians per second. |
float | referenceAngle |
The bodyB angle minus bodyA angle in the reference state (radians). This defines the zero angle for the joint limit. |
float | upperAngle | The upper angle for the joint limit in radians. Maximum of 0.95*pi radians. |
void * | userData | User data pointer. |
B2_API b2JointId b2CreateRevoluteJoint | ( | b2WorldId | worldId, |
const b2RevoluteJointDef * | def ) |
Create a revolute joint.
B2_API float b2RevoluteJoint_GetAngle | ( | b2JointId | jointId | ) |
Get the revolute joint current angle in radians relative to the reference angle.
B2_API 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.95 * B2_PI <= lower && upper <= -0.95 * B2_PI.