A constraint is something that describes how two bodies interact with each other. (how they constrain each other). Constraints can be simple joints that allow bodies to pivot around each other like the bones in your body, or they can be more abstract like the gear joint or motors.
This submodule contain all the constraints that are supported by pymunk.
Chipmunk has a good overview of the different constraint on youtube which works fine to showcase them in pymunk as well. http://www.youtube.com/watch?v=ZgJJZTS0aMM
Bases: object
Base class of all constraints.
You usually don’t want to create instances of this class directly, but instead use one of the specific constraints such as the PinJoint.
The first of the two bodies constrained
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Like a damped spring, but works in an angular fashion
Like a damped spring, but works in an angular fashion.
Parameters : |
|
---|
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
How soft to make the damping of the spring.
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
The relative angle in radians that the bodies want to have
The spring constant (Young’s modulus).
Set the torque function
func(self, relative_angle) -> torque
Bases: pymunk.constraint.Constraint
A damped spring
Defined much like a slide joint.
Parameters : |
|
---|
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
How soft to make the damping of the spring.
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
The distance the spring wants to be.
The spring constant (Young’s modulus).
Bases: pymunk.constraint.Constraint
Keeps the angular velocity ratio of a pair of bodies constant.
Keeps the angular velocity ratio of a pair of bodies constant. ratio is always measured in absolute terms. It is currently not possible to set the ratio in relation to a third body’s angular velocity. phase is the initial angular offset of the two bodies.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Similar to a pivot joint, but one of the anchors is on a linear slide instead of being fixed.
The groove goes from groove_a to groove_b on body a, and the pivot is attached to anchr2 on body b. All coordinates are body local.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Keeps the anchor points at a set distance from one another.
a and b are the two bodies to connect, and anchr1 and anchr2 are the anchor points on those bodies.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Simply allow two objects to pivot about a single point.
a and b are the two bodies to connect, and pivot is the point in world coordinates of the pivot. Because the pivot location is given in world coordinates, you must have the bodies moved into the correct positions already. Alternatively you can specify the joint based on a pair of anchor points, but make sure you have the bodies in the right place as the joint will fix itself as soon as you start simulating the space.
That is, either create the joint with PivotJoint(a, b, pivot) or PivotJoint(a, b, anchr1, anchr2).
- a : Body
- The first of the two bodies
- b : Body
- The second of the two bodies
- args : [Vec2d] or [Vec2d,Vec2d]
- Either one pivot point, or two anchor points
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Works like a socket wrench.
Works like a socket wrench. ratchet is the distance between “clicks”, phase is the initial offset to use when deciding where the ratchet angles are.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Constrains the relative rotations of two bodies.
Constrains the relative rotations of two bodies. min and max are the angular limits in radians. It is implemented so that it’s possible to for the range to be greater than a full revolution.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
Bases: pymunk.constraint.Constraint
Keeps the relative angular velocity of a pair of bodies constant.
Keeps the relative angular velocity of a pair of bodies constant. rate is the desired relative angular velocity. You will usually want to set an force (torque) maximum for motors as otherwise they will be able to apply a nearly infinite torque to keep the bodies moving.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity
The desired relative angular velocity
Bases: pymunk.constraint.Constraint
Like pin joints, but have a minimum and maximum distance. A chain could be modeled using this joint. It keeps the anchor points from getting to far apart, but will allow them to get closer together.
a and b are the two bodies to connect, anchr1 and anchr2 are the anchor points on those bodies, and min and max define the allowed distances of the anchor points.
The first of the two bodies constrained
Activate the bodies this constraint is attached to
The second of the two bodies constrained
The rate at which joint error is corrected.
Defaults to pow(1.0 - 0.1, 60.0) meaning that it will correct 10% of the error every 1/60th of a second.
Get the last impulse applied by this constraint.
The maximum rate at which joint error is corrected. Defaults to infinity
The maximum force that the constraint can use to act on the two bodies. Defaults to infinity