### cpGearJointGetRatio Source: https://viblo.github.io/Munk2D/cp_gear_joint_8h_source.html Gets the ratio of a gear joint. ```APIDOC ## cpGearJointGetRatio ### Description Gets the ratio of a gear joint. ### Function Signature `cpFloat cpGearJointGetRatio(const cpConstraint *constraint)` ### Parameters - **constraint** (cpConstraint*) - Required - The gear joint constraint. ### Return Value - **cpFloat** - The ratio of the gear joint. ``` -------------------------------- ### cpConstraintGetPreSolveFunc Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the pre-solve function that is called before the solver runs. ```APIDOC ## cpConstraintGetPreSolveFunc ### Description Get the pre-solve function that is called before the solver runs. ### Method cpConstraintGetPreSolveFunc ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpConstraintPreSolveFunc - The pre-solve callback function. ``` -------------------------------- ### cpConstraintGetBodyA Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the first body the constraint is attached to. ```APIDOC ## cpConstraintGetBodyA ### Description Get the first body the constraint is attached to. ### Method cpConstraintGetBodyA ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpBody* - The first body. ``` -------------------------------- ### cpConstraintGetPostSolveFunc Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the post-solve function that is called before the solver runs. ```APIDOC ## cpConstraintGetPostSolveFunc ### Description Get the post-solve function that is called before the solver runs. ### Method cpConstraintGetPostSolveFunc ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpConstraintPostSolveFunc - The post-solve callback function. ``` -------------------------------- ### cpConstraintGetPostSolveFunc Source: https://viblo.github.io/Munk2D/group__cp_constraint.html Gets the post-solve function that is called after the solver runs. ```APIDOC ## cpConstraintGetPostSolveFunc ### Description Gets the post-solve function that is called after the solver runs. ### Function Signature ```c CP_EXPORT cpConstraintPostSolveFunc cpConstraintGetPostSolveFunc(const cpConstraint *constraint) ``` ### Parameters - **constraint** (const cpConstraint*) - The constraint. ### Returns - **cpConstraintPostSolveFunc** - The post-solve function pointer. ``` -------------------------------- ### cpShapeGetDensity Source: https://viblo.github.io/Munk2D/group__cp_shape.html Get the density of the shape. ```APIDOC ## cpShapeGetDensity ### Description Get the density of the shape if you are having Chipmunk calculate mass properties for you. ### Function Signature `CP_EXPORT cpFloat cpShapeGetDensity(cpShape *shape)` ### Parameters - **shape** (cpShape*) - Required - The shape. ### Returns - **cpFloat** - The density of the shape. ``` -------------------------------- ### cpSpaceInit Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Initializes a cpSpace instance. ```APIDOC ## cpSpaceInit ### Description Initialize a cpSpace. ### Method cpSpaceInit ### Signature cpSpace * cpSpaceInit(cpSpace *space) ### Parameters - **space** (cpSpace*) - Required - The space to initialize. ### Returns - **cpSpace*** - The initialized space. ``` -------------------------------- ### cpShapeGetMass Source: https://viblo.github.io/Munk2D/group__cp_shape.html Get the mass of the shape. ```APIDOC ## cpShapeGetMass ### Description Get the mass of the shape if you are having Chipmunk calculate mass properties for you. ### Function Signature `CP_EXPORT cpFloat cpShapeGetMass(cpShape *shape)` ### Parameters - **shape** (cpShape*) - Required - The shape. ### Returns - **cpFloat** - The mass of the shape. ``` -------------------------------- ### cpGrooveJointInit Source: https://viblo.github.io/Munk2D/cp_groove_joint_8h_source.html Initializes a groove joint. ```APIDOC ## cpGrooveJointInit ### Description Initialize a groove joint. ### Function Signature `cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB)` ### Parameters - **joint** (cpGrooveJoint*) - The joint to initialize. - **a** (cpBody*) - The first body. - **b** (cpBody*) - The second body. - **groove_a** (cpVect) - The first endpoint of the groove relative to the first body. - **groove_b** (cpVect) - The second endpoint of the groove relative to the first body. - **anchorB** (cpVect) - The location of the second anchor relative to the second body. ### Returns - **cpGrooveJoint*** - The initialized groove joint. ``` -------------------------------- ### cpBBTreeInit Source: https://viblo.github.io/Munk2D/cp_spatial_index_8h_source.html Initializes a bounding box tree. ```APIDOC ## cpBBTreeInit ### Description Initialize a bounding box tree. ### Signature `CP_EXPORT cpSpatialIndex * cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex)` ### Parameters - **tree** (cpBBTree*) - The bounding box tree to initialize. - **bbfunc** (cpSpatialIndexBBFunc) - The bounding box callback function. - **staticIndex** (cpSpatialIndex*) - The static index to use. ### Returns - **cpSpatialIndex*** - The initialized spatial index. ``` -------------------------------- ### cpSimpleMotorGetRate Source: https://viblo.github.io/Munk2D/group__cp_simple_motor.html Get the rate of the motor. ```APIDOC ## cpSimpleMotorGetRate ### Description Get the rate of the motor. ### Function Signature ```c CP_EXPORT cpFloat cpSimpleMotorGetRate(const cpConstraint *constraint) ``` ### Parameters - **constraint** (const cpConstraint *) - The simple motor constraint. ### Returns - **cpFloat** - The rate of the motor. ``` -------------------------------- ### cpConstraintGetUserData Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the user definable data pointer for this constraint. ```APIDOC ## cpConstraintGetUserData ### Description Get the user definable data pointer for this constraint. ### Method cpConstraintGetUserData ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpDataPointer - The user data pointer. ``` -------------------------------- ### cpBodyInit Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Initializes a cpBody with the given mass and moment of inertia. ```APIDOC ## cpBodyInit ### Description Initialize a cpBody. ### Function Signature `CP_EXPORT cpBody * cpBodyInit(cpBody *body, cpFloat mass, cpFloat moment)` ### Parameters - **body** (cpBody*) - The body to initialize. - **mass** (cpFloat) - The mass of the body. - **moment** (cpFloat) - The moment of inertia of the body. ### Returns cpBody* - The initialized body. ``` -------------------------------- ### cpBodyGetMass Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Get the mass of the body. ```APIDOC ## cpBodyGetMass ### Description Get the mass of the body. ### Method cpBodyGetMass ### Signature cpFloat cpBodyGetMass(const cpBody *body) ### Parameters - **body** (const cpBody*) - The body to query. ### Returns - **cpFloat** - The mass of the body. ``` -------------------------------- ### cpArbiterGetNormal Source: https://viblo.github.io/Munk2D/cp_arbiter_8h_source.html Get the normal of the collision. ```APIDOC ## cpArbiterGetNormal ### Description Get the normal of the collision. ### Signature `CP_EXPORT cpVect cpArbiterGetNormal(const cpArbiter *arb);` ### Parameters - **arb** (const cpArbiter*) - Required - The arbiter. ### Returns - **cpVect** - The collision normal. ``` -------------------------------- ### cpGearJointInit Source: https://viblo.github.io/Munk2D/cp_gear_joint_8h_source.html Initializes a gear joint with the given bodies, phase, and ratio. ```APIDOC ## cpGearJointInit ### Description Initializes a gear joint with the given bodies, phase, and ratio. ### Function Signature `cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio)` ### Parameters - **joint** (cpGearJoint*) - Required - Pointer to the joint to initialize. - **a** (cpBody*) - Required - First body connected by the joint. - **b** (cpBody*) - Required - Second body connected by the joint. - **phase** (cpFloat) - Required - Phase offset of the gears. - **ratio** (cpFloat) - Required - Ratio of the gear joint. ### Return Value - **cpGearJoint*** - Pointer to the initialized gear joint. ``` -------------------------------- ### cpShapeGetBody Source: https://viblo.github.io/Munk2D/group__cp_shape.html Get the body this shape is connected to. ```APIDOC ## cpShapeGetBody ### Description The cpBody this shape is connected to. ### Function Signature `CP_EXPORT cpBody* cpShapeGetBody(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape. ### Returns - **cpBody*** - The body the shape is connected to. ``` -------------------------------- ### cpBBNewForExtents constructor Source: https://viblo.github.io/Munk2D/cp_b_b_8h_source.html Creates a bounding box centered at point c with half-width hw and half-height hh. ```c static inline cpBB cpBBNewForExtents(const cpVect c, const cpFloat hw, const cpFloat hh) { return cpBBNew(c.x - hw, c.y - hh, c.x + hw, c.y + hh); } ``` -------------------------------- ### cpSimpleMotorNew Source: https://viblo.github.io/Munk2D/group__cp_simple_motor.html Allocate and initialize a simple motor. ```APIDOC ## cpSimpleMotorNew ### Description Allocate and initialize a simple motor. ### Function Signature ```c CP_EXPORT cpConstraint *cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate) ``` ### Parameters - **a** (cpBody *) - The first body. - **b** (cpBody *) - The second body. - **rate** (cpFloat) - The rate of the motor. ### Returns - **cpConstraint*** - A pointer to the new simple motor constraint. ``` -------------------------------- ### cpShapeGetSpace Source: https://viblo.github.io/Munk2D/group__cp_shape.html Get the space this shape is added to. ```APIDOC ## cpShapeGetSpace ### Description The cpSpace this body is added to. ### Function Signature `CP_EXPORT cpSpace* cpShapeGetSpace(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape. ### Returns - **cpSpace*** - The space the shape is added to. ``` -------------------------------- ### cpDampedSpringGetStiffness Source: https://viblo.github.io/Munk2D/group__cp_damped_spring.html Get the stiffness of the spring in force/distance. ```APIDOC ## cpDampedSpringGetStiffness ### Description Get the stiffness of the spring in force/distance. ### Function Signature ```c CP_EXPORT cpFloat cpDampedSpringGetStiffness(const cpConstraint *constraint) ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpFloat** - The stiffness. ``` -------------------------------- ### cpBodyNew Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Allocates and initializes a new body with the given mass and moment. ```APIDOC ## cpBodyNew ### Description Allocate and initialize a cpBody. ### Function Signature `CP_EXPORT cpBody * cpBodyNew(cpFloat mass, cpFloat moment)` ### Parameters - **mass** (cpFloat) - The mass of the body. - **moment** (cpFloat) - The moment of inertia of the body. ### Returns cpBody* - The new body. ``` -------------------------------- ### cpBodyKineticEnergy Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Get the kinetic energy of the body. ```APIDOC ## cpBodyKineticEnergy ### Description Get the kinetic energy of the body. ### Method cpBodyKineticEnergy ### Signature cpFloat cpBodyKineticEnergy(const cpBody *body) ### Parameters - **body** (const cpBody*) - The body to query. ### Returns - **cpFloat** - The kinetic energy. ``` -------------------------------- ### cpSlideJointInit Source: https://viblo.github.io/Munk2D/cp_slide_joint_8h_source.html Initializes a slide joint with the given parameters. ```APIDOC ## cpSlideJointInit ### Description Initialize a slide joint. ### Function Signature ```c CP_EXPORT cpSlideJoint* cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max); ``` ### Parameters - **joint** (cpSlideJoint*) - The joint to initialize. - **a** (cpBody*) - The first body. - **b** (cpBody*) - The second body. - **anchorA** (cpVect) - The anchor point on the first body. - **anchorB** (cpVect) - The anchor point on the second body. - **min** (cpFloat) - The minimum distance between the anchors. - **max** (cpFloat) - The maximum distance between the anchors. ### Return Value - **cpSlideJoint*** - The initialized slide joint. ``` -------------------------------- ### cpBBTreeNew Source: https://viblo.github.io/Munk2D/cp_spatial_index_8h_source.html Allocates and initializes a bounding box tree. ```APIDOC ## cpBBTreeNew ### Description Allocate and initialize a bounding box tree. ### Signature `CP_EXPORT cpSpatialIndex * cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex)` ### Parameters - **bbfunc** (cpSpatialIndexBBFunc) - The bounding box callback function. - **staticIndex** (cpSpatialIndex*) - The static index to use. ### Returns - **cpSpatialIndex*** - The new bounding box tree. ``` -------------------------------- ### cpBodyGetTorque Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Get the torque applied to the body. ```APIDOC ## cpBodyGetTorque ### Description Get the torque applied to the body. ### Method cpBodyGetTorque ### Signature cpFloat cpBodyGetTorque(const cpBody *body) ### Parameters - **body** (const cpBody*) - The body to query. ### Returns - **cpFloat** - The torque applied to the body. ``` -------------------------------- ### cpBodyGetAngularVelocity Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Get the angular velocity of the body. ```APIDOC ## cpBodyGetAngularVelocity ### Description Get the angular velocity of the body. ### Method cpBodyGetAngularVelocity ### Signature cpFloat cpBodyGetAngularVelocity(const cpBody *body) ### Parameters - **body** (const cpBody*) - The body to query. ### Returns - **cpFloat** - The angular velocity of the body. ``` -------------------------------- ### cpSpaceAddPostStepCallback Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Schedules a post-step callback to be called when cpSpaceStep() finishes. ```APIDOC ## cpSpaceAddPostStepCallback ### Description Schedule a post-step callback to be called when cpSpaceStep() finishes. ### Method cpSpaceAddPostStepCallback ### Signature cpBool cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data) ### Parameters - **space** (cpSpace*) - Required - The space. - **func** (cpPostStepFunc) - Required - The callback function. - **key** (void*) - Required - The key for the callback. - **data** (void*) - Required - User data. ### Returns - **cpBool** - True if the callback was scheduled. ``` -------------------------------- ### cpSegmentShapeGetRadius Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the radius of a segment shape. ```APIDOC ## cpSegmentShapeGetRadius ### Description Get the radius of a segment shape. ### Function Signature `cpFloat cpSegmentShapeGetRadius(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpFloat** - The radius of the segment shape. ``` -------------------------------- ### cpSimpleMotorInit Source: https://viblo.github.io/Munk2D/group__cp_simple_motor.html Initialize a simple motor. ```APIDOC ## cpSimpleMotorInit ### Description Initialize a simple motor. ### Function Signature ```c CP_EXPORT cpSimpleMotor *cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate) ``` ### Parameters - **joint** (cpSimpleMotor *) - The simple motor to initialize. - **a** (cpBody *) - The first body. - **b** (cpBody *) - The second body. - **rate** (cpFloat) - The rate of the motor. ### Returns - **cpSimpleMotor*** - The initialized simple motor. ``` -------------------------------- ### cpSegmentShapeGetNormal Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the normal of a segment shape. ```APIDOC ## cpSegmentShapeGetNormal ### Description Get the normal of a segment shape. ### Function Signature `cpVect cpSegmentShapeGetNormal(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpVect** - The normal of the segment. ``` -------------------------------- ### cpBBNewForCircle constructor Source: https://viblo.github.io/Munk2D/cp_b_b_8h_source.html Creates a bounding box for a circle centered at p with radius r. ```c static inline cpBB cpBBNewForCircle(const cpVect p, const cpFloat r) { return cpBBNewForExtents(p, r, r); } ``` -------------------------------- ### cpCircleShapeGetRadius Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the radius of a circle shape. ```APIDOC ## cpCircleShapeGetRadius ### Description Get the radius of a circle shape. ### Function Signature `cpFloat cpCircleShapeGetRadius(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpFloat** - The radius of the circle shape. ``` -------------------------------- ### cpBBNew constructor Source: https://viblo.github.io/Munk2D/cp_b_b_8h_source.html Creates a new cpBB from the given left, bottom, right, and top coordinates. ```c static inline cpBB cpBBNew(const cpFloat l, const cpFloat b, const cpFloat r, const cpFloat t) { cpBB bb = {l, b, r, t}; return bb; } ``` -------------------------------- ### cpSpatialIndexBBFunc Source: https://viblo.github.io/Munk2D/group__cp_spatial_index.html Callback function type for spatial index bounding box. The spatial index calls this function to get the bounding box associated with an object. ```APIDOC ## cpSpatialIndexBBFunc ### Description Callback function type for spatial index bounding box. The spatial index calls this function to get the bounding box associated with an object. ### Type Definition ```c typedef cpBB(* cpSpatialIndexBBFunc)(void *obj); ``` ### Parameters - **obj** (void*) - Pointer to the object for which the bounding box is requested. ### Returns cpBB - The bounding box of the object. ``` -------------------------------- ### cpCircleShapeGetOffset Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the offset of a circle shape. ```APIDOC ## cpCircleShapeGetOffset ### Description Get the offset of a circle shape. ### Function Signature `cpVect cpCircleShapeGetOffset(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpVect** - The offset of the circle shape. ``` -------------------------------- ### cpSpaceNew Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Allocates and initializes a new cpSpace object. ```APIDOC ## cpSpaceNew ### Description Allocate and initialize a cpSpace. ### Method Function ### Signature `CP_EXPORT cpSpace * cpSpaceNew(void)` ### Parameters None ### Returns - **cpSpace\*** - A pointer to the newly created space. ``` -------------------------------- ### cpBodyNewKinematic Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Allocate and initialize a cpBody, and set it as a kinematic body. ```APIDOC ## cpBodyNewKinematic ### Description Allocate and initialize a cpBody, and set it as a kinematic body. ### Method cpBodyNewKinematic ### Signature cpBody * cpBodyNewKinematic(void) ### Returns - **cpBody*** - A new kinematic body. ``` -------------------------------- ### cpDampedSpringGetDamping Source: https://viblo.github.io/Munk2D/cp_damped_spring_8h_source.html Gets the damping of a damped spring. ```APIDOC ## cpDampedSpringGetDamping ### Description Gets the damping of a damped spring. ### Method Function ### Signature ```c cpFloat cpDampedSpringGetDamping(const cpConstraint *constraint); ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpFloat** - The damping. ``` -------------------------------- ### cpDampedSpringGetStiffness Source: https://viblo.github.io/Munk2D/cp_damped_spring_8h_source.html Gets the stiffness of a damped spring. ```APIDOC ## cpDampedSpringGetStiffness ### Description Gets the stiffness of a damped spring. ### Method Function ### Signature ```c cpFloat cpDampedSpringGetStiffness(const cpConstraint *constraint); ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpFloat** - The stiffness. ``` -------------------------------- ### cpSpaceAddBody Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Adds a rigid body to the simulation space. ```APIDOC ## cpSpaceAddBody ### Description Add a rigid body to the simulation. ### Method Function ### Signature `CP_EXPORT cpBody * cpSpaceAddBody(cpSpace *space, cpBody *body)` ### Parameters - **space** (cpSpace*) - The space to add the body to. - **body** (cpBody*) - The body to add. ### Returns - **cpBody\*** - The added body. ``` -------------------------------- ### cpDampedRotarySpringGetDamping Source: https://viblo.github.io/Munk2D/cp_damped_rotary_spring_8h_source.html Gets the damping coefficient of the spring. ```APIDOC ## cpDampedRotarySpringGetDamping ### Description Gets the damping coefficient of the spring. ### Method cpDampedRotarySpringGetDamping ### Parameters - **constraint** (const cpConstraint*) - The constraint. ### Returns - **cpFloat** - The damping coefficient. ``` -------------------------------- ### cpBBExpand Source: https://viblo.github.io/Munk2D/group__cp_b_b_b.html Returns a bounding box that holds both `bb` and `v`. ```APIDOC ## cpBBExpand ### Description Returns a bounding box that holds both `bb` and `v`. ### Function Signature `static cpBB cpBBExpand(const cpBB bb, const cpVect v)` ### Parameters - **bb** (cpBB) - The bounding box. - **v** (cpVect) - The vector to include. ### Returns - **cpBB** - The expanded bounding box. ``` -------------------------------- ### cpSpaceStep Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Advances the simulation by a given time step. ```APIDOC ## cpSpaceStep ### Description Steps the space forward in time by dt. ### Method POST ### Endpoint cpSpaceStep(cpSpace *space, cpFloat dt) ### Parameters #### Path Parameters - **space** (cpSpace*) - Required - The space to step. - **dt** (cpFloat) - Required - The time step duration. ### Response #### Success Response No return value. ``` -------------------------------- ### cpDampedRotarySpringGetStiffness Source: https://viblo.github.io/Munk2D/cp_damped_rotary_spring_8h_source.html Gets the stiffness of the spring in force/distance. ```APIDOC ## cpDampedRotarySpringGetStiffness ### Description Gets the stiffness of the spring in force/distance. ### Method cpDampedRotarySpringGetStiffness ### Parameters - **constraint** (const cpConstraint*) - The constraint. ### Returns - **cpFloat** - The stiffness. ``` -------------------------------- ### cpGrooveJointNew Source: https://viblo.github.io/Munk2D/cp_groove_joint_8h_source.html Allocates and initializes a groove joint. ```APIDOC ## cpGrooveJointNew ### Description Allocate and initialize a groove joint. ### Function Signature `cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB)` ### Parameters - **a** (cpBody*) - The first body. - **b** (cpBody*) - The second body. - **groove_a** (cpVect) - The first endpoint of the groove relative to the first body. - **groove_b** (cpVect) - The second endpoint of the groove relative to the first body. - **anchorB** (cpVect) - The location of the second anchor relative to the second body. ### Returns - **cpConstraint*** - A pointer to the new groove joint constraint. ``` -------------------------------- ### cpPolyShapeGetRadius Source: https://viblo.github.io/Munk2D/cp_poly_shape_8h_source.html Gets the radius of a polygon shape. ```APIDOC ## cpPolyShapeGetRadius ### Description Get the radius of a polygon shape. ### Signature ```c CP_EXPORT cpFloat cpPolyShapeGetRadius(const cpShape *shape); ``` ### Parameters - **shape** (const cpShape*) - The polygon shape. ### Returns - **cpFloat** - The radius of the polygon shape. ``` -------------------------------- ### cpPolylineSetInit Source: https://viblo.github.io/Munk2D/cp_polyline_8h_source.html Initializes a polyline set. ```APIDOC ## cpPolylineSetInit ### Description Initializes a polyline set. ### Function Signature ```c cpPolylineSet *cpPolylineSetInit(cpPolylineSet *set); ``` ### Parameters - **set** (cpPolylineSet*) - The polyline set to initialize. ### Returns - **cpPolylineSet*** - The initialized polyline set. ``` -------------------------------- ### cpCircleShapeInit Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Initialize a circle shape. ```APIDOC ## cpCircleShapeInit ### Description Initialize a circle shape. ### Function Signature `cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset)` ### Parameters - **circle** (cpCircleShape*) - Required - The circle shape to initialize. - **body** (cpBody*) - Required - The body to attach the shape to. - **radius** (cpFloat) - Required - The radius of the circle. - **offset** (cpVect) - Required - The offset of the circle from the body's center of gravity. ### Return Value - **cpCircleShape*** - The initialized circle shape. ``` -------------------------------- ### cpGearJointGetPhase Source: https://viblo.github.io/Munk2D/cp_gear_joint_8h_source.html Gets the phase offset of the gears. ```APIDOC ## cpGearJointGetPhase ### Description Gets the phase offset of the gears. ### Function Signature `cpFloat cpGearJointGetPhase(const cpConstraint *constraint)` ### Parameters - **constraint** (cpConstraint*) - Required - The gear joint constraint. ### Return Value - **cpFloat** - The phase offset of the gears. ``` -------------------------------- ### cpSweep1DInit Source: https://viblo.github.io/Munk2D/cp_spatial_index_8h_source.html Initializes a 1D sort and sweep broadphase. ```APIDOC ## cpSweep1DInit ### Description Initialize a 1D sort and sweep broadphase. ### Signature `CP_EXPORT cpSpatialIndex * cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex)` ### Parameters - **sweep** (cpSweep1D*) - The 1D sweep to initialize. - **bbfunc** (cpSpatialIndexBBFunc) - The bounding box callback function. - **staticIndex** (cpSpatialIndex*) - The static index to use. ### Returns - **cpSpatialIndex*** - The initialized spatial index. ``` -------------------------------- ### cpShapeGetMoment Source: https://viblo.github.io/Munk2D/group__cp_shape.html Get the calculated moment of inertia for this shape. ```APIDOC ## cpShapeGetMoment ### Description Get the calculated moment of inertia for this shape. ### Function Signature `CP_EXPORT cpFloat cpShapeGetMoment(cpShape *shape)` ### Parameters - **shape** (cpShape*) - Required - The shape. ### Returns - **cpFloat** - The moment of inertia. ``` -------------------------------- ### cpDampedSpringGetSpringForceFunc Source: https://viblo.github.io/Munk2D/cp_damped_spring_8h_source.html Gets the spring force callback function. ```APIDOC ## cpDampedSpringGetSpringForceFunc ### Description Get the damping of the spring. ### Function Signature ```c CP_EXPORT cpDampedSpringForceFunc cpDampedSpringGetSpringForceFunc(const cpConstraint *constraint) ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpDampedSpringForceFunc** - The spring force callback function. ``` -------------------------------- ### cpGearJointNew Source: https://viblo.github.io/Munk2D/cp_gear_joint_8h_source.html Allocates and initializes a gear joint. ```APIDOC ## cpGearJointNew ### Description Allocates and initializes a gear joint. ### Function Signature `cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio)` ### Parameters - **a** (cpBody*) - Required - First body connected by the joint. - **b** (cpBody*) - Required - Second body connected by the joint. - **phase** (cpFloat) - Required - Phase offset of the gears. - **ratio** (cpFloat) - Required - Ratio of the gear joint. ### Return Value - **cpConstraint*** - Pointer to the gear joint as a constraint. ``` -------------------------------- ### cpSpaceGetStaticBody Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Gets the static body provided by the space. ```APIDOC ## cpSpaceGetStaticBody ### Description The Space provided static body for a given cpSpace. ### Method cpSpaceGetStaticBody ### Signature cpBody * cpSpaceGetStaticBody(const cpSpace *space) ### Parameters - **space** (const cpSpace*) - Required - The space. ### Returns - **cpBody*** - The static body. ``` -------------------------------- ### cpConstraintGetPreSolveFunc Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Returns the pre-solve callback function for the constraint. ```APIDOC ## cpConstraintGetPreSolveFunc ### Description Returns the pre-solve callback function for the constraint. ### Method cpConstraintGetPreSolveFunc ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpConstraintPreSolveFunc - The pre-solve callback function. ``` -------------------------------- ### cpSegmentShapeGetB Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the second endpoint of a segment shape. ```APIDOC ## cpSegmentShapeGetB ### Description Get the second endpoint of a segment shape. ### Function Signature `cpVect cpSegmentShapeGetB(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpVect** - The second endpoint of the segment. ``` -------------------------------- ### Construct basic cpTransform matrices (scale, rotate, rigid, rigid inverse) Source: https://viblo.github.io/Munk2D/cp_transform_8h_source.html These inline functions construct common affine transforms using cpTransformNewTranspose. cpTransformScale creates a scaling transform, cpTransformRotate creates a rotation transform from an angle in radians, cpTransformRigid combines translation and rotation, and cpTransformRigidInverse computes the inverse of a rigid transform. They are part of the Chipmunk2D cpTransform.h header. ```c static inline cpTransform cpTransformScale(cpFloat scaleX, cpFloat scaleY) { return cpTransformNewTranspose( scaleX, 0.0, 0.0, 0.0, scaleY, 0.0 ); } ``` ```c static inline cpTransform cpTransformRotate(cpFloat radians) { cpVect rot = cpvforangle(radians); return cpTransformNewTranspose( rot.x, -rot.y, 0.0, rot.y, rot.x, 0.0 ); } ``` ```c static inline cpTransform cpTransformRigid(cpVect translate, cpFloat radians) { cpVect rot = cpvforangle(radians); return cpTransformNewTranspose( rot.x, -rot.y, translate.x, rot.y, rot.x, translate.y ); } ``` ```c static inline cpTransform cpTransformRigidInverse(cpTransform t) { return cpTransformNewTranspose( t.d, -t.c, (t.c*t.ty - t.tx*t.d), -t.b, t.a, (t.tx*t.b - t.a*t.ty) ); } ``` -------------------------------- ### cpTransformNew constructor Source: https://viblo.github.io/Munk2D/cp_transform_8h_source.html Creates a transform from the six components in row-major order: a, b, c, d, tx, ty. ```c static inline cpTransform cpTransformNew(cpFloat a, cpFloat b, cpFloat c, cpFloat d, cpFloat tx, cpFloat ty) { cpTransform t = {a, b, c, d, tx, ty}; return t; } ``` -------------------------------- ### cpSegmentShapeGetA Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get the first endpoint of a segment shape. ```APIDOC ## cpSegmentShapeGetA ### Description Get the first endpoint of a segment shape. ### Function Signature `cpVect cpSegmentShapeGetA(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpVect** - The first endpoint of the segment. ``` -------------------------------- ### cpShapeGetFriction / cpShapeSetFriction Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get or set the friction of a shape. ```APIDOC ## cpShapeGetFriction ### Description Get the friction of a shape. ### Function Signature `cpFloat cpShapeGetFriction(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpFloat** - The friction of the shape. ## cpShapeSetFriction ### Description Set the friction of a shape. ### Function Signature `void cpShapeSetFriction(cpShape *shape, cpFloat friction)` ### Parameters - **shape** (cpShape*) - Required - The shape to modify. - **friction** (cpFloat) - Required - The new friction value. ``` -------------------------------- ### cpBodyNewStatic Source: https://viblo.github.io/Munk2D/cp_body_8h_source.html Allocates and initializes a static body. ```APIDOC ## cpBodyNewStatic ### Description Allocate and initialize a cpBody, and set it as a static body. ### Function Signature `CP_EXPORT cpBody * cpBodyNewStatic(void)` ### Parameters None ### Returns cpBody* - The new static body. ``` -------------------------------- ### cpShapeGetElasticity / cpShapeSetElasticity Source: https://viblo.github.io/Munk2D/cp_shape_8h_source.html Get or set the elasticity of a shape. ```APIDOC ## cpShapeGetElasticity ### Description Get the elasticity of a shape. ### Function Signature `cpFloat cpShapeGetElasticity(const cpShape *shape)` ### Parameters - **shape** (const cpShape*) - Required - The shape to query. ### Return Value - **cpFloat** - The elasticity of the shape. ## cpShapeSetElasticity ### Description Set the elasticity of a shape. ### Function Signature `void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity)` ### Parameters - **shape** (cpShape*) - Required - The shape to modify. - **elasticity** (cpFloat) - Required - The new elasticity value. ``` -------------------------------- ### cpPinJointInit Source: https://viblo.github.io/Munk2D/cp_pin_joint_8h_source.html Initializes a pin joint with the given bodies and anchors. Returns a pointer to the initialized pin joint. ```APIDOC ## cpPinJointInit ### Description Initialize a pin joint. ### Function Signature ```c CP_EXPORT cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); ``` ### Parameters - **joint** (cpPinJoint*) - The joint to initialize. - **a** (cpBody*) - The first body. - **b** (cpBody*) - The second body. - **anchorA** (cpVect) - The anchor point relative to body a. - **anchorB** (cpVect) - The anchor point relative to body b. ### Returns - **cpPinJoint*** - The initialized pin joint. ``` -------------------------------- ### cpDampedSpringGetRestLength Source: https://viblo.github.io/Munk2D/cp_damped_spring_8h_source.html Gets the rest length of a damped spring. ```APIDOC ## cpDampedSpringGetRestLength ### Description Gets the rest length of a damped spring. ### Method Function ### Signature ```c cpFloat cpDampedSpringGetRestLength(const cpConstraint *constraint); ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpFloat** - The rest length. ``` -------------------------------- ### cpPivotJointInit Source: https://viblo.github.io/Munk2D/group__cp_pivot_joint.html Initializes a pivot joint with the given bodies and anchors. ```APIDOC ## cpPivotJointInit ### Description Initialize a pivot joint. ### Function Signature ```c CP_EXPORT cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB) ``` ### Parameters - **joint** (cpPivotJoint*) - The joint to initialize. - **a** (cpBody*) - The first body. - **b** (cpBody*) - The second body. - **anchorA** (cpVect) - The anchor point relative to body a. - **anchorB** (cpVect) - The anchor point relative to body b. ### Returns - **cpPivotJoint*** - The initialized joint. ``` -------------------------------- ### cpDampedSpringGetAnchorA Source: https://viblo.github.io/Munk2D/cp_damped_spring_8h_source.html Gets the anchor point A of a damped spring. ```APIDOC ## cpDampedSpringGetAnchorA ### Description Gets the anchor point A of a damped spring. ### Method Function ### Signature ```c cpVect cpDampedSpringGetAnchorA(const cpConstraint *constraint); ``` ### Parameters - **constraint** (const cpConstraint*) - The damped spring constraint. ### Returns - **cpVect** - The anchor point A. ``` -------------------------------- ### cpBBNew Source: https://viblo.github.io/Munk2D/group__cp_b_b_b.html Convenience constructor for cpBB structs. ```APIDOC ## cpBBNew ### Description Convenience constructor for cpBB structs. ### Function Signature `static cpBB cpBBNew(const cpFloat l, const cpFloat b, const cpFloat r, const cpFloat t)` ### Parameters - **l** (cpFloat) - Left coordinate. - **b** (cpFloat) - Bottom coordinate. - **r** (cpFloat) - Right coordinate. - **t** (cpFloat) - Top coordinate. ### Returns - **cpBB** - The constructed bounding box. ``` -------------------------------- ### cpConstraintGetErrorBias Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the rate at which joint error is corrected. ```APIDOC ## cpConstraintGetErrorBias ### Description Get rate at which joint error is corrected. ### Method cpConstraintGetErrorBias ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpFloat - The error bias. ``` -------------------------------- ### Iterate body constraints with CP_BODY_FOREACH_CONSTRAINT Source: https://viblo.github.io/Munk2D/chipmunk__private_8h_source.html Provides iteration over a body's constraints. cpConstraintNext returns the next constraint in the list for the given body, and the macro CP_BODY_FOREACH_CONSTRAINT loops through them. ```c static inline cpConstraint * cpConstraintNext(cpConstraint *node, cpBody *body) { return (node->a == body ? node->next_a : node->next_b); } #define CP_BODY_FOREACH_CONSTRAINT(bdy, var)\ for(cpConstraint *var = bdy->constraintList; var; var = cpConstraintNext(var, bdy)) ``` -------------------------------- ### cpConstraintGetBodyB Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the second body the constraint is attached to. ```APIDOC ## cpConstraintGetBodyB ### Description Get the second body the constraint is attached to. ### Method cpConstraintGetBodyB ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns cpBody* - The second body. ``` -------------------------------- ### cpConstraintGetImpulse Source: https://viblo.github.io/Munk2D/cp_constraint_8h_source.html Gets the last impulse applied by this constraint. ```APIDOC ## cpConstraintGetImpulse ### Description Get the last impulse applied by this constraint. ### Method cpConstraintGetImpulse ### Parameters - **constraint** (cpConstraint*) - Required - The constraint to query. ### Returns cpFloat - The last impulse. ``` -------------------------------- ### cpRotaryLimitJointInit Source: https://viblo.github.io/Munk2D/cp_rotary_limit_joint_8h_source.html Initializes a rotary limit joint. ```APIDOC ## cpRotaryLimitJointInit ### Description Initializes a rotary limit joint. ### Function Signature ```c CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); ``` ### Parameters - **joint** (cpRotaryLimitJoint*) - Required - The joint to initialize. - **a** (cpBody*) - Required - The first body. - **b** (cpBody*) - Required - The second body. - **min** (cpFloat) - Required - The minimum rotation limit. - **max** (cpFloat) - Required - The maximum rotation limit. ### Return Value - **cpRotaryLimitJoint*** - A pointer to the initialized rotary limit joint. ``` -------------------------------- ### Chipmunk arbiter initialization and threading helpers Source: https://viblo.github.io/Munk2D/chipmunk__private_8h_source.html Declares cpArbiterInit and provides the inline helper cpArbiterThreadForBody to return the thread belonging to the given body. Also declares the internal functions cpArbiterUnthread, cpArbiterUpdate, cpArbiterPreStep, cpArbiterApplyCachedImpulse, and cpArbiterApplyImpulse. ```c cpArbiter* cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b); static inline struct cpArbiterThread * cpArbiterThreadForBody(cpArbiter *arb, cpBody *body) { return (arb->body_a == body ? &arb->thread_a : &arb->thread_b); } void cpArbiterUnthread(cpArbiter *arb); void cpArbiterUpdate(cpArbiter *arb, struct cpCollisionInfo *info, cpSpace *space); void cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat bias, cpFloat slop); void cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef); void cpArbiterApplyImpulse(cpArbiter *arb); ``` -------------------------------- ### cpGrooveJointAlloc Source: https://viblo.github.io/Munk2D/cp_groove_joint_8h_source.html Allocates a groove joint. ```APIDOC ## cpGrooveJointAlloc ### Description Allocate a groove joint. ### Function Signature `cpGrooveJoint* cpGrooveJointAlloc(void)` ### Parameters None. ### Returns - **cpGrooveJoint*** - A pointer to the allocated groove joint. ``` -------------------------------- ### cpArbiterGetDepth Source: https://viblo.github.io/Munk2D/cp_arbiter_8h_source.html Get the depth of the ith contact point. ```APIDOC ## cpArbiterGetDepth ### Description Get the depth of the ith contact point. ### Signature `CP_EXPORT cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i);` ### Parameters - **arb** (const cpArbiter*) - Required - The arbiter. - **i** (int) - Required - The index of the contact point. ### Returns - **cpFloat** - The depth of the contact point. ``` -------------------------------- ### cpArbiterGetCount Source: https://viblo.github.io/Munk2D/cp_arbiter_8h_source.html Get the number of contact points for this arbiter. ```APIDOC ## cpArbiterGetCount ### Description Get the number of contact points for this arbiter. ### Signature `CP_EXPORT int cpArbiterGetCount(const cpArbiter *arb);` ### Parameters - **arb** (const cpArbiter*) - Required - The arbiter. ### Returns - **int** - The number of contact points. ``` -------------------------------- ### cpSpaceAlloc Source: https://viblo.github.io/Munk2D/cp_space_8h_source.html Allocates a cpSpace. ```APIDOC ## cpSpaceAlloc ### Description Allocate a cpSpace. ### Method cpSpaceAlloc ### Signature cpSpace * cpSpaceAlloc(void) ### Returns - **cpSpace*** - The allocated space. ``` -------------------------------- ### cpDampedRotarySpringGetDamping Source: https://viblo.github.io/Munk2D/cp_damped_rotary_spring_8h_source.html Gets the damping of the damped rotary spring. ```APIDOC ## cpDampedRotarySpringGetDamping ### Description Get the damping of the spring. ### Function Signature ```c CP_EXPORT cpFloat cpDampedRotarySpringGetDamping(const cpConstraint *constraint) ``` ### Parameters - **constraint** (const cpConstraint*) - Required - The constraint to query. ### Returns - **cpFloat** - The damping value. ```