Package pymunk
[frames] | no frames]

Package pymunk

pymunk is a easy-to-use pythonic 2d physics library that can be used whenever you need 2d rigid body physics from Python.

Homepage: http://code.google.com/p/pymunk/

Forum: http://www.slembcke.net/forums/viewforum.php?f=6

Chipmunk documentation: http://code.google.com/p/chipmunk-physics/wiki/Documentation


Version: $Id: __init__.py 354 2011-11-24 14:59:38Z vb@viblo.se $

Submodules
  • pymunk.constraint: A constraint is something that describes how two bodies interact with each other. (how they constraint 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.
  • pymunk.util: Contains utility functions, mainly to help with polygon creation
  • pymunk.vec2d

Classes
  Space
Spaces are the basic unit of simulation. You add rigid bodies, shapes and joints to it and then step them all forward together through time.
  Body
A rigid body
  Shape
Base class for all the shapes.
  SegmentQueryInfo
Segment queries return more information than just a simple yes or no, they also return where a shape was hit and it's surface normal at the hit point. This object hold that information.
  Circle
A circle shape defined by a radius
  Segment
A line segment shape between two points
  Poly
A convex polygon shape
  Contact
Contact information
  Arbiter
Arbiters are collision pairs between shapes that are used with the collision callbacks.
  BB
Simple bounding box class. Stored as left, bottom, right, top values.
  Constraint
Base class of all constraints.
  DampedRotarySpring
Like a damped spring, but works in an angular fashion
  DampedSpring
A damped spring
  GearJoint
Keeps the angular velocity ratio of a pair of bodies constant.
  GrooveJoint
Similar to a pivot joint, but one of the anchors is on a linear slide instead of being fixed.
  PinJoint
Keeps the anchor points at a set distance from one another.
  PivotJoint
Simply allow two objects to pivot about a single point.
  RatchetJoint
Works like a socket wrench.
  RotaryLimitJoint
Constrains the relative rotations of two bodies.
  SimpleMotor
Keeps the relative angular velocity of a pair of bodies constant.
  SlideJoint
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.
Functions
 
moment_for_circle(mass, inner_radius, outer_radius, offset=(0, 0))
Calculate the moment of inertia for a circle
 
moment_for_segment(mass, a, b)
Calculate the moment of inertia for a segment
 
moment_for_poly(mass, vertices, offset=(0, 0))
Calculate the moment of inertia for a polygon
 
moment_for_box(mass, width, height)
Calculate the momentn of inertia for a box
 
reset_shapeid_counter()
Reset the internal shape counter
Variables
  version = '2.1.0'
The release version of this pymunk installation. Valid only if pymunk was installed from a source or binary distribution (i.e. not in a checked-out copy from svn).
  chipmunk_version = u'6.0.2R82ba83e'
The Chipmunk version compatible with this pymunk version. Other (newer) Chipmunk versions might also work if the new version does not contain any breaking API changes.
  inf = 1e+100
@deprecated You should create static bodies by invoking the body constructor without any arguments, not using the infinity field. Expect inf to be removed in pymunk 3.0
Function Details

reset_shapeid_counter()

 

Reset the internal shape counter

pymunk keeps a counter so that every new shape is given a unique hash value to be used in the spatial hash. Because this affects the order in which the collisions are found and handled, you should reset the shape counter every time you populate a space with new shapes. If you don't, there might be (very) slight differences in the simulation.


Variables Details

chipmunk_version

The Chipmunk version compatible with this pymunk version. Other (newer) Chipmunk versions might also work if the new version does not contain any breaking API changes.

The string is in the following format: <cpVersionString>R<svn or github commit of chipmunk> where cpVersionString is a version string set by Chipmunk and the svn version corresponds to the svn version of the chipmunk source files included with pymunk or the github commit hash.

Note: This is also the version of the Chipmunk source files included in the chipmunk_src folder (normally included in the pymunk source distribution).

Value:
u'6.0.2R82ba83e'

inf

@deprecated You should create static bodies by invoking the body constructor without any arguments, not using the infinity field. Expect inf to be removed in pymunk 3.0

Infinity that can be passed as mass or inertia to Body. Use this as mass and inertia when you need to create a static body.

Value:
1e+100