Box2D 3.1.0
A 2D physics engine for games
Loading...
Searching...
No Matches
Motor Joint

Functions for the motor joint. More...

Collaboration diagram for Motor Joint:

Data Structures

struct  b2MotorJointDef
 A motor joint is used to control the relative motion between two bodies. More...
 

Functions

b2JointId b2CreateMotorJoint (b2WorldId worldId, const b2MotorJointDef *def)
 Create a motor joint.
 
void b2MotorJoint_SetLinearOffset (b2JointId jointId, b2Vec2 linearOffset)
 Set the motor joint linear offset target.
 
b2Vec2 b2MotorJoint_GetLinearOffset (b2JointId jointId)
 Get the motor joint linear offset target.
 
void b2MotorJoint_SetAngularOffset (b2JointId jointId, float angularOffset)
 Set the motor joint angular offset target in radians.
 
float b2MotorJoint_GetAngularOffset (b2JointId jointId)
 Get the motor joint angular offset target in radians.
 
void b2MotorJoint_SetMaxForce (b2JointId jointId, float maxForce)
 Set the motor joint maximum force, typically in newtons.
 
float b2MotorJoint_GetMaxForce (b2JointId jointId)
 Get the motor joint maximum force, typically in newtons.
 
void b2MotorJoint_SetMaxTorque (b2JointId jointId, float maxTorque)
 Set the motor joint maximum torque, typically in newton-meters.
 
float b2MotorJoint_GetMaxTorque (b2JointId jointId)
 Get the motor joint maximum torque, typically in newton-meters.
 
void b2MotorJoint_SetCorrectionFactor (b2JointId jointId, float correctionFactor)
 Set the motor joint correction factor, typically in [0, 1].
 
float b2MotorJoint_GetCorrectionFactor (b2JointId jointId)
 Get the motor joint correction factor, typically in [0, 1].
 
b2MotorJointDef b2DefaultMotorJointDef (void)
 Use this to initialize your joint definition.
 

Detailed Description

Functions for the motor joint.

The motor joint is used to drive the relative transform between two bodies. It takes a relative position and rotation and applies the forces and torques needed to achieve that relative transform over time.


Data Structure Documentation

◆ b2MotorJointDef

struct b2MotorJointDef

A motor joint is used to control the relative motion between two bodies.

A typical usage is to control the movement of a dynamic body with respect to the ground.

Collaboration diagram for b2MotorJointDef:
Data Fields
float angularOffset The bodyB angle minus bodyA angle in radians.
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 correctionFactor Position correction factor in the range [0,1].
int32_t internalValue Used internally to detect a valid definition. DO NOT SET.
b2Vec2 linearOffset Position of bodyB minus the position of bodyA, in bodyA's frame.
float maxForce The maximum motor force in newtons.
float maxTorque The maximum motor torque in newton-meters.
void * userData User data pointer.

Function Documentation

◆ b2CreateMotorJoint()

b2JointId b2CreateMotorJoint ( b2WorldId worldId,
const b2MotorJointDef * def )

Create a motor joint.

See also
b2MotorJointDef for details