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

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

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.
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.
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()

B2_API b2JointId b2CreatePrismaticJoint ( b2WorldId worldId,
const b2PrismaticJointDef * def )

Create a prismatic (slider) joint.

See also
b2PrismaticJointDef for details

◆ b2PrismaticJoint_SetSpringHertz()

B2_API 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.