Box2D 3.2.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...

Data Structures

struct  b2PrismaticJointDef
 Prismatic joint definition Body B may slide along the x-axis in local frame A. 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_SetTargetTranslation (b2JointId jointId, float translation)
 Set the prismatic joint spring target translation, usually in meters.
float b2PrismaticJoint_GetTargetTranslation (b2JointId jointId)
 Get the prismatic joint spring target translation, usually in meters.
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_SetTargetMotorSpeed (b2JointId jointId, float motorSpeed)
 Set the prismatic joint motor speed, usually in meters per second.
float b2PrismaticJoint_GetTargetMotorSpeed (b2JointId jointId)
 Get the prismatic joint motor speed, usually in meters per second.
void b2PrismaticJoint_SetMaxMotorForce (b2JointId jointId, float force)
 Set the prismatic joint maximum motor force, usually in newtons.
float b2PrismaticJoint_GetMaxMotorForce (b2JointId jointId)
 Get the prismatic joint maximum motor force, usually in newtons.
float b2PrismaticJoint_GetCurrentTranslation (b2JointId jointId)
 Get the current joint translation, usually in meters.
float b2PrismaticJoint_GetCurrentSpeed (b2JointId jointId)
 Get the current joint translation velocity, usually in meters per second.
float b2PrismaticJoint_GetCurrentMotorForce (b2JointId jointId)
 Get the prismatic joint current motor force, usually in newtons.
b2PrismaticJointDef b2DefaultPrismaticJointDef (void)
 Use this to initialize your joint definition.

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 Body B may slide along the x-axis in local frame A.

Body B cannot rotate relative to body A. The joint translation is zero when the local frame origins coincide in world space.

Data Fields
b2JointDef base Base joint definition.
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.
int internalValue Used internally to detect a valid definition. DO NOT SET.
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 targetTranslation The target translation for the joint in meters.

The spring-damper will drive to this translation.

float upperTranslation The upper translation limit.

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.