Box2D 3.1.0
A 2D physics engine for games
|
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 | |
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) |
It 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. | |
float | b2RevoluteJoint_GetAngle (b2JointId jointId) |
Get the revolute joint current angle in radians relative to the reference angle. | |
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_SetMotorSpeed (b2JointId jointId, float motorSpeed) |
Set the revolute joint motor speed in radians per second. | |
float | b2RevoluteJoint_GetMotorSpeed (b2JointId jointId) |
Get the revolute joint motor speed in radians per second. | |
float | b2RevoluteJoint_GetMotorTorque (b2JointId jointId) |
Get the revolute joint current motor torque, typically in newton-meters. | |
void | b2RevoluteJoint_SetMaxMotorTorque (b2JointId jointId, float torque) |
Set the revolute joint maximum motor torque, typically in newton-meters. | |
float | b2RevoluteJoint_GetMaxMotorTorque (b2JointId jointId) |
Get the revolute joint maximum motor torque, typically 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. |
int32_t | 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. |
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. |
void * | userData | User data pointer. |
b2JointId b2CreateRevoluteJoint | ( | b2WorldId | worldId, |
const b2RevoluteJointDef * | def ) |
Create a revolute joint.
float b2RevoluteJoint_GetAngle | ( | b2JointId | jointId | ) |
Get the revolute joint current angle in radians relative to the reference angle.