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

A prismatic joint allows for translation along a single axis with no rotation. More...

Collaboration diagram for Prismatic Joint:

Data Structures

struct  b2PrismaticJointDef
 Prismatic joint definition. More...
 

Functions

b2JointId b2CreatePrismaticJoint (b2WorldId worldId, const b2PrismaticJointDef *def)
 Create a prismatic (slider) joint.
 
void b2PrismaticJoint_EnableSpring (b2JointId jointId, bool enableSpring)
 Enable/disable the joint spring.
 
bool b2PrismaticJoint_IsSpringEnabled (b2JointId jointId)
 Is the prismatic joint spring enabled or not?
 
void b2PrismaticJoint_SetSpringHertz (b2JointId jointId, float hertz)
 Set the prismatic joint stiffness in Hertz.
 
float b2PrismaticJoint_GetSpringHertz (b2JointId jointId)
 Get the prismatic joint stiffness in Hertz.
 
void b2PrismaticJoint_SetSpringDampingRatio (b2JointId jointId, float dampingRatio)
 Set the prismatic joint damping ratio (non-dimensional)
 
float b2PrismaticJoint_GetSpringDampingRatio (b2JointId jointId)
 Get the prismatic spring damping ratio (non-dimensional)
 
void b2PrismaticJoint_EnableLimit (b2JointId jointId, bool enableLimit)
 Enable/disable a prismatic joint limit.
 
bool b2PrismaticJoint_IsLimitEnabled (b2JointId jointId)
 Is the prismatic joint limit enabled?
 
float b2PrismaticJoint_GetLowerLimit (b2JointId jointId)
 Get the prismatic joint lower limit.
 
float b2PrismaticJoint_GetUpperLimit (b2JointId jointId)
 Get the prismatic joint upper limit.
 
void b2PrismaticJoint_SetLimits (b2JointId jointId, float lower, float upper)
 Set the prismatic joint limits.
 
void b2PrismaticJoint_EnableMotor (b2JointId jointId, bool enableMotor)
 Enable/disable a prismatic joint motor.
 
bool b2PrismaticJoint_IsMotorEnabled (b2JointId jointId)
 Is the prismatic joint motor enabled?
 
void b2PrismaticJoint_SetMotorSpeed (b2JointId jointId, float motorSpeed)
 Set the prismatic joint motor speed, typically in meters per second.
 
float b2PrismaticJoint_GetMotorSpeed (b2JointId jointId)
 Get the prismatic joint motor speed, typically in meters per second.
 
void b2PrismaticJoint_SetMaxMotorForce (b2JointId jointId, float force)
 Set the prismatic joint maximum motor force, typically in newtons.
 
float b2PrismaticJoint_GetMaxMotorForce (b2JointId jointId)
 Get the prismatic joint maximum motor force, typically in newtons.
 
float b2PrismaticJoint_GetMotorForce (b2JointId jointId)
 Get the prismatic joint current motor force, typically in newtons.
 

Detailed Description

A prismatic joint allows for translation along a single axis with no rotation.

The prismatic joint is useful for things like pistons and moving platforms, where you want a body to translate along an axis and have no rotation. Also called a slider joint.


Data Structure Documentation

◆ b2PrismaticJointDef

struct b2PrismaticJointDef

Prismatic joint definition.

This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space.

Collaboration diagram for b2PrismaticJointDef:
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.
bool enableLimit Enable/disable the joint limit.
bool enableMotor Enable/disable the joint motor.
bool enableSpring Enable a linear spring along the prismatic joint 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.
b2Vec2 localAxisA The local translation unit axis in bodyA.
float lowerTranslation The lower translation limit.
float maxMotorForce The maximum motor force, typically in newtons.
float motorSpeed The desired motor speed, typically in meters per second.
float referenceAngle The constrained angle between the bodies: bodyB_angle - bodyA_angle.
float upperTranslation The upper translation limit.
void * userData User data pointer.

Function Documentation

◆ b2CreatePrismaticJoint()

b2JointId b2CreatePrismaticJoint ( b2WorldId worldId,
const b2PrismaticJointDef * def )

Create a prismatic (slider) joint.

See also
b2PrismaticJointDef for details

◆ b2PrismaticJoint_SetSpringHertz()

void b2PrismaticJoint_SetSpringHertz ( b2JointId jointId,
float hertz )

Set the prismatic joint stiffness in Hertz.

This should usually be less than a quarter of the simulation rate. For example, if the simulation runs at 60Hz then the joint stiffness should be 15Hz or less.