# API Reference

## `pymunk` Package

Submodules

- `pymunk.autogeometry` Module
- `pymunk.constraint` Module
- `pymunk.vec2d` Module
- `pymunk.matplotlib_util` Module
- `pymunk.pygame_util` Module
- `pymunk.pyglet_util` Module
- `pymunkoptions` Module

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://www.pymunk.org

This is the main containing module of Pymunk. It contains among other things the very central Space, Body and Shape classes.

When you import this module it will automatically load the chipmunk library file. As long as you haven’t turned off the debug mode a print will show exactly which Chipmunk library file it loaded. For example:

    >>> import pymunk

    Loading chipmunk for Windows (32bit) [C:\code\pymunk\chipmunk.dll]

`pymunk.``inf` = inf

  Infinity that can be passed as mass or inertia to a `Body`.

  Useful when you for example want a body that cannot rotate, just set its moment to inf. Just remember that if two objects with both infinite masses collides the world might explode. Similar effects can happen with infinite moment.

  Note

  In previous versions of Pymunk you used inf to create static bodies. This has changed. See `Body` for details.

`pymunk.``version` = ‘5.3.2’

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

`pymunk.``chipmunk_version` = ‘<Mock object>Rd7603e392782079b691d7948405af2dd66648a7a’

  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.

  This property does not show a valid value in the compiled documentation, only when you actually import pymunk and do pymunk.chipmunk_version

  The string is in the following format: <cpVersionString>R<github commit of chipmunk> where cpVersionString is a version string set by Chipmunk and the git commit hash corresponds to the git hash of the chipmunk source from github.com/slembcke/Chipmunk2D included with Pymunk. If the Chipmunk version is a release then the second part will be empty

  Note

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

class `pymunk.``Space`(threaded=False)

  Bases: `pymunk._pickle.PickleMixin`, `object`

  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.

  A Space can be copied and pickled. Note that any post step callbacks are not copied. Also note that some internal collision cache data is not copied, which can make the simulation a bit unstable the first few steps of the fresh copy.

  Custom properties set on the space will also be copied/pickled.

  Any collision handlers will also be copied/pickled. Note that depending on the pickle protocol used there are some restrictions on what functions can be copied/pickled.

  Example:

      >>> import pymunk, pickle
      >>> space = pymunk.Space()
      >>> space2 = space.copy()
      >>> space3 = pickle.loads(pickle.dumps(space))

  `__init__`(threaded=False)

    Create a new instance of the Space.

    If you set threaded=True the step function will run in threaded mode which might give a speedup. Note that even when you set threaded=True you still have to set Space.threads=2 to actually use more than one thread.

    Also note that threaded mode is not available on Windows, and setting threaded=True has no effect on that platform.

  `add`(*objs)

    Add one or many shapes, bodies or joints to the space

    Unlike Chipmunk and earlier versions of pymunk its now allowed to add objects even from a callback during the simulation step. However, the add will not be performed until the end of the step.

  `add_collision_handler`(collision_type_a, collision_type_b)

    Return the `CollisionHandler` for collisions between objects of type collision_type_a and collision_type_b.

    Fill the desired collision callback functions, for details see the `CollisionHandler` object.

    Whenever shapes with collision types (`Shape.collision_type`) a and b collide, this handler will be used to process the collision events. When a new collision handler is created, the callbacks will all be set to builtin callbacks that perform the default behavior (call the wildcard handlers, and accept all collisions).

    Parameters: | collision_type_a (int) – Collision type a collision_type_b (int) – Collision type b
    Return type: | `CollisionHandler`

  `add_default_collision_handler`()

    Return a reference to the default collision handler or that is used to process all collisions that don’t have a more specific handler.

    The default behavior for each of the callbacks is to call the wildcard handlers, ANDing their return values together if applicable.

  `add_post_step_callback`(callback_function, key, *args, **kwargs)

    Add a function to be called last in the next simulation step.

    Post step callbacks are registered as a function and an object used as a key. You can only register one post step callback per object.

    This function was more useful with earlier versions of pymunk where you weren’t allowed to use the add and remove methods on the space during a simulation step. But this function is still available for other uses and to keep backwards compatibility.

    Note

    If you remove a shape from the callback it will trigger the collision handler for the ‘separate’ event if it the shape was touching when removed.

    Note

    Post step callbacks are not included in pickle / copy of the space.

    Parameters: | callback_function (func(space : Space, key, *args, **kwargs)) – The callback function key (Any) – This object is used as a key, you can only have one callback for a single object. It is passed on to the callback function. args – Optional parameters passed to the callback kwargs – Optional keyword parameters passed on to the callback
    Returns: | True if key was not previously added, False otherwise

  `add_wildcard_collision_handler`(collision_type_a)

    Add a wildcard collision handler for given collision type.

    This handler will be used any time an object with this type collides with another object, regardless of its type. A good example is a projectile that should be destroyed the first time it hits anything. There may be a specific collision handler and two wildcard handlers. It’s up to the specific handler to decide if and when to call the wildcard handlers and what to do with their return values. (See Arbiter.call_wildcard*())

    When a new wildcard handler is created, the callbacks will all be set to builtin callbacks that perform the default behavior. (accept all collisions in `begin()` and `pre_solve()`, or do nothing for `post_solve()` and `separate()`.

    Parameters: | collision_type_a (int) – Collision type
    Return type: | `CollisionHandler`

  `bb_query`(bb, shape_filter)

    Query space to find all shapes near bb.

    The filter is applied to the query and follows the same rules as the collision detection.

    Note

    Sensor shapes are included in the result

    Parameters: | bb (BB) – Bounding box shape_filter (ShapeFilter) – Shape filter
    Return type: | [`Shape`]

  `bodies`

    A list of the bodies added to this space

  `collision_bias`

    Determines how fast overlapping shapes are pushed apart.

    Pymunk allows fast moving objects to overlap, then fixes the overlap over time. Overlapping objects are unavoidable even if swept collisions are supported, and this is an efficient and stable way to deal with overlapping objects. The bias value controls what percentage of overlap remains unfixed after a second and defaults to ~0.2%. Valid values are in the range from 0 to 1, but using 0 is not recommended for stability reasons. The default value is calculated as cpfpow(1.0f - 0.1f, 60.0f) meaning that pymunk attempts to correct 10% of error ever 1/60th of a second.

    ..Note::
      Very very few games will need to change this value.
  `collision_persistence`

    The number of frames the space keeps collision solutions around for.

    Helps prevent jittering contacts from getting worse. This defaults to 3.

    ..Note::
      Very very few games will need to change this value.
  `collision_slop`

    Amount of overlap between shapes that is allowed.

    To improve stability, set this as high as you can without noticable overlapping. It defaults to 0.1.

  `constraints`

    A list of the constraints added to this space

  `copy`()

    Create a deep copy of this space.

  `current_time_step`

    Retrieves the current (if you are in a callback from Space.step()) or most recent (outside of a Space.step() call) timestep.

  `damping`

    Amount of simple damping to apply to the space.

    A value of 0.9 means that each body will lose 10% of its velocity per second. Defaults to 1. Like gravity, it can be overridden on a per body basis.

  `debug_draw`(options)

    Debug draw the current state of the space using the supplied drawing options.

    If you use a graphics backend that is already supported, such as pygame and pyglet, you can use the predefined options in their x_util modules, for example `pygame_util.DrawOptions`.

    Its also possible to write your own graphics backend, see `SpaceDebugDrawOptions`.

    If you require any advanced or optimized drawing its probably best to not use this funtion for the drawing since its meant for debugging and quick scripting.

  `gravity`

    Global gravity applied to the space.

    Defaults to (0,0). Can be overridden on a per body basis by writing custom integration functions.

  `idle_speed_threshold`

    Speed threshold for a body to be considered idle.

    The default value of 0 means the space estimates a good threshold based on gravity.

  `iterations`

    Iterations allow you to control the accuracy of the solver.

    Defaults to 10.

    Pymunk uses an iterative solver to figure out the forces between objects in the space. What this means is that it builds a big list of all of the collisions, joints, and other constraints between the bodies and makes several passes over the list considering each one individually. The number of passes it makes is the iteration count, and each iteration makes the solution more accurate. If you use too many iterations, the physics should look nice and solid, but may use up too much CPU time. If you use too few iterations, the simulation may seem mushy or bouncy when the objects should be solid. Setting the number of iterations lets you balance between CPU usage and the accuracy of the physics. Pymunk’s default of 10 iterations is sufficient for most simple games.

  `point_query`(point, max_distance, shape_filter)

    Query space at point for shapes within the given distance range.

    The filter is applied to the query and follows the same rules as the collision detection. If a maxDistance of 0.0 is used, the point must lie inside a shape. Negative max_distance is also allowed meaning that the point must be a under a certain depth within a shape to be considered a match.

    See `ShapeFilter` for details about how the shape_filter parameter can be used.

    Note

    Sensor shapes are included in the result (In `Space.point_query_nearest()` they are not)

    Parameters: | point (`Vec2d` or (float,float)) – Where to check for collision in the Space max_distance (float) – Match only within this distance shape_filter (ShapeFilter) – Only pick shapes matching the filter
    Return type: | [`PointQueryInfo`]

  `point_query_nearest`(point, max_distance, shape_filter)

    Query space at point the nearest shape within the given distance range.

    The filter is applied to the query and follows the same rules as the collision detection. If a maxDistance of 0.0 is used, the point must lie inside a shape. Negative max_distance is also allowed meaning that the point must be a under a certain depth within a shape to be considered a match.

    See `ShapeFilter` for details about how the shape_filter parameter can be used.

    Note

    Sensor shapes are not included in the result (In `Space.point_query()` they are)

    Parameters: | point (`Vec2d` or (float,float)) – Where to check for collision in the Space max_distance (float) – Match only within this distance shape_filter (ShapeFilter) – Only pick shapes matching the filter
    Return type: | `PointQueryInfo` or None

  `reindex_shape`(shape)

    Update the collision detection data for a specific shape in the space.

  `reindex_shapes_for_body`(body)

    Reindex all the shapes for a certain body.

  `reindex_static`()

    Update the collision detection info for the static shapes in the space. You only need to call this if you move one of the static shapes.

  `remove`(*objs)

    Remove one or many shapes, bodies or constraints from the space

    Unlike Chipmunk and earlier versions of Pymunk its now allowed to remove objects even from a callback during the simulation step. However, the removal will not be performed until the end of the step.

    Note

    When removing objects from the space, make sure you remove any other objects that reference it. For instance, when you remove a body, remove the joints and shapes attached to it.

  `segment_query`(start, end, radius, shape_filter)

    Query space along the line segment from start to end with the given radius.

    The filter is applied to the query and follows the same rules as the collision detection.

    See `ShapeFilter` for details about how the shape_filter parameter can be used.

    Note

    Sensor shapes are included in the result (In `Space.segment_query_first()` they are not)

    Parameters: | start – Starting point end – End point radius (float) – Radius shape_filter (ShapeFilter) – Shape filter
    Return type: | [`SegmentQueryInfo`]

  `segment_query_first`(start, end, radius, shape_filter)

    Query space along the line segment from start to end with the given radius.

    The filter is applied to the query and follows the same rules as the collision detection.

    Note

    Sensor shapes are not included in the result (In `Space.segment_query()` they are)

    See `ShapeFilter` for details about how the shape_filter parameter can be used.

    Return type: | `SegmentQueryInfo` or None

  `shape_query`(shape)

    Query a space for any shapes overlapping the given shape

    Note

    Sensor shapes are included in the result

    Parameters: | shape (`Circle`, `Poly` or `Segment`) – Shape to query with
    Return type: | [`ShapeQueryInfo`]

  `shapes`

    A list of all the shapes added to this space

    (includes both static and non-static)

  `sleep_time_threshold`

    Time a group of bodies must remain idle in order to fall asleep.

    The default value of inf disables the sleeping algorithm.

  `static_body`

    A dedicated static body for the space.

    You don’t have to use it, but because its memory is managed automatically with the space its very convenient.

  `step`(dt)

    Update the space for the given time step.

    Using a fixed time step is highly recommended. Doing so will increase the efficiency of the contact persistence, requiring an order of magnitude fewer iterations to resolve the collisions in the usual case.

    It is not the same to call step 10 times with a dt of 0.1 and calling it 100 times with a dt of 0.01 even if the end result is that the simulation moved forward 100 units. Performing multiple calls with a smaller dt creates a more stable and accurate simulation. Therefor it sometimes make sense to have a little for loop around the step call, like in this example:

        >>> import pymunk
        >>> s = pymunk.Space()
        >>> steps = 10
        >>> for x in range(steps): # move simulation forward 0.1 seconds:
        ...     s.step(0.1 / steps)

    Parameters: | dt (float) – Time step length

  `threads`

    The number of threads to use for running the step function.

    Only valid on platforms other than Windows and when the Space was created with threaded=True. Currently the max limit is 2, setting a higher value wont have any effect. The default is 1 regardless if the Space was created with threaded=True, to keep determinism in the simulation.

class `pymunk.``Body`(mass=0, moment=0, body_type=<class ‘CP_BODY_TYPE_DYNAMIC’>)

  Bases: `pymunk._pickle.PickleMixin`, `object`

  A rigid body

  - Use forces to modify the rigid bodies if possible. This is likely to be the most stable.
  - Modifying a body’s velocity shouldn’t necessarily be avoided, but applying large changes can cause strange results in the simulation. Experiment freely, but be warned.
  - Don’t modify a body’s position every step unless you really know what you are doing. Otherwise you’re likely to get the position/velocity badly out of sync.

  A Body can be copied and pickled. Sleeping bodies that are copied will be awake in the fresh copy. When a Body is copied any spaces, shapes or constraints attached to the body will not be copied.

  `DYNAMIC`

    alias of `CP_BODY_TYPE_DYNAMIC`

  `KINEMATIC`

    alias of `CP_BODY_TYPE_KINEMATIC`

  `STATIC`

    alias of `CP_BODY_TYPE_STATIC`

  `__init__`(mass=0, moment=0, body_type=<class ‘CP_BODY_TYPE_DYNAMIC’>)

    Create a new Body

    Mass and moment are ignored when body_type is KINEMATIC or STATIC.

    Guessing the mass for a body is usually fine, but guessing a moment of inertia can lead to a very poor simulation so it’s recommended to use Chipmunk’s moment calculations to estimate the moment for you.

    There are two ways to set up a dynamic body. The easiest option is to create a body with a mass and moment of 0, and set the mass or density of each collision shape added to the body. Chipmunk will automatically calculate the mass, moment of inertia, and center of gravity for you. This is probably preferred in most cases. Note that these will only be correctly calculated after the body and shape are added to a space.

    The other option is to set the mass of the body when it’s created, and leave the mass of the shapes added to it as 0.0. This approach is more flexible, but is not as easy to use. Don’t set the mass of both the body and the shapes. If you do so, it will recalculate and overwrite your custom mass value when the shapes are added to the body.

  `activate`()

    Reset the idle timer on a body.

    If it was sleeping, wake it and any other bodies it was touching.

  `angle`

    Rotation of the body in radians.

    When changing the rotation you may also want to call `Space.reindex_shapes_for_body()` to update the collision detection information for the attached shapes if plan to make any queries against the space. A body rotates around its center of gravity, not its position.

    Note

    If you get small/no changes to the angle when for example a ball is “rolling” down a slope it might be because the Circle shape attached to the body or the slope shape does not have any friction set.

  `angular_velocity`

    The angular velocity of the body in radians per second.

  `apply_force_at_local_point`(force, point)

    Add the local force force to body as if applied from the body local point.

  `apply_force_at_world_point`(force, point)

    Add the force force to body as if applied from the world point.

    People are sometimes confused by the difference between a force and an impulse. An impulse is a very large force applied over a very short period of time. Some examples are a ball hitting a wall or cannon firing. Chipmunk treats impulses as if they occur instantaneously by adding directly to the velocity of an object. Both impulses and forces are affected the mass of an object. Doubling the mass of the object will halve the effect.

  `apply_impulse_at_local_point`(impulse, point=(0, 0))

    Add the local impulse impulse to body as if applied from the body local point.

  `apply_impulse_at_world_point`(impulse, point=(0, 0))

    Add the impulse impulse to body as if applied from the world point.

  `body_type`

    The type of a body (`Body.DYNAMIC`, `Body.KINEMATIC` or `Body.STATIC`).

    When changing an body to a dynamic body, the mass and moment of inertia are recalculated from the shapes added to the body. Custom calculated moments of inertia are not preserved when changing types. This function cannot be called directly in a collision callback.

  `center_of_gravity`

    Location of the center of gravity in body local coordinates.

    The default value is (0, 0), meaning the center of gravity is the same as the position of the body.

  `constraints`

    Get the constraints this body is attached to.

    The body only keeps a weak reference to the constraints and a live body wont prevent GC of the attached constraints

  `copy`()

    Create a deep copy of this body.

  `each_arbiter`(func, *args, **kwargs)

    Run func on each of the arbiters on this body.

    > `func(arbiter, *args, **kwargs) -> None`

    > Callback Parameters
    >   arbiter : `Arbiter`
    >     The Arbiter
    >   args
    >     Optional parameters passed to the callback function.
    >   kwargs
    >     Optional keyword parameters passed on to the callback function.

    Warning

    Do not hold on to the Arbiter after the callback!

  `force`

    Force applied to the center of gravity of the body.

    This value is reset for every time step.

  `is_sleeping`

    Returns true if the body is sleeping.

  `kinetic_energy`

    Get the kinetic energy of a body.

  `local_to_world`(v)

    Convert body local coordinates to world space coordinates

    Many things are defined in coordinates local to a body meaning that the (0,0) is at the center of gravity of the body and the axis rotate along with the body.

    Parameters: | v – Vector in body local coordinates

  `mass`

    Mass of the body.

  `moment`

    Moment of inertia (MoI or sometimes just moment) of the body.

    The moment is like the rotational mass of a body.

  `position`

    Position of the body.

    When changing the position you may also want to call `Space.reindex_shapes_for_body()` to update the collision detection information for the attached shapes if plan to make any queries against the space.

  `position_func`

    The position callback function.

    The position callback function is called each time step and can be used to update the body’s position.

    > `func(body, dt) -> None`

  `rotation_vector`

    The rotation vector for the body.

  `shapes`

    Get the shapes attached to this body.

    The body only keeps a weak reference to the shapes and a live body wont prevent GC of the attached shapes

  `sleep`()

    Forces a body to fall asleep immediately even if it’s in midair.

    Cannot be called from a callback.

  `sleep_with_group`(body)

    Force a body to fall asleep immediately along with other bodies in a group.

    When objects in Pymunk sleep, they sleep as a group of all objects that are touching or jointed together. When an object is woken up, all of the objects in its group are woken up. `Body.sleep_with_group()` allows you group sleeping objects together. It acts identically to `Body.sleep()` if you pass None as group by starting a new group. If you pass a sleeping body for group, body will be awoken when group is awoken. You can use this to initialize levels and start stacks of objects in a pre-sleeping state.

  `space`

    Get the `Space` that the body has been added to (or None).

  `torque`

    The torque applied to the body.

    This value is reset for every time step.

  static `update_position`(body, dt)

    Default rigid body position integration function.

    Updates the position of the body using Euler integration. Unlike the velocity function, it’s unlikely you’ll want to override this function. If you do, make sure you understand it’s source code (in Chipmunk) as it’s an important part of the collision/joint correction process.

  static `update_velocity`(body, gravity, damping, dt)

    Default rigid body velocity integration function.

    Updates the velocity of the body using Euler integration.

  `velocity`

    Linear velocity of the center of gravity of the body.

  `velocity_at_local_point`(point)

    Get the absolute velocity of the rigid body at the given body local point

  `velocity_at_world_point`(point)

    Get the absolute velocity of the rigid body at the given world point

    It’s often useful to know the absolute velocity of a point on the surface of a body since the angular velocity affects everything except the center of gravity.

  `velocity_func`

    The velocity callback function.

    The velocity callback function is called each time step, and can be used to set a body’s velocity.

    > `func(body : Body, gravity, damping, dt)`

  `world_to_local`(v)

    Convert world space coordinates to body local coordinates

    Parameters: | v – Vector in world space coordinates

class `pymunk.``Shape`(shape=None)

  Bases: `pymunk._pickle.PickleMixin`, `object`

  Base class for all the shapes.

  You usually dont want to create instances of this class directly but use one of the specialized shapes instead (`Circle`, `Poly` or `Segment`).

  All the shapes can be copied and pickled. If you copy/pickle a shape the body (if any) will also be copied.

  `__init__`(shape=None)
  `area`

    The calculated area of this shape.

  `bb`

    The bounding box `BB` of the shape.

    Only guaranteed to be valid after `Shape.cache_bb()` or `Space.step()` is called. Moving a body that a shape is connected to does not update it’s bounding box. For shapes used for queries that aren’t attached to bodies, you can also use `Shape.update()`.

  `body`

    The body this shape is attached to. Can be set to None to indicate that this shape doesnt belong to a body.

  `cache_bb`()

    Update and returns the bounding box of this shape

  `center_of_gravity`

    The calculated center of gravity of this shape.

  `collision_type`

    User defined collision type for the shape.

    See `Space.add_collision_handler()` function for more information on when to use this property.

  `copy`()

    Create a deep copy of this shape.

  `density`

    The density of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `elasticity`

    Elasticity of the shape.

    A value of 0.0 gives no bounce, while a value of 1.0 will give a ‘perfect’ bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.

  `filter`

    Set the collision `ShapeFilter` for this shape.

  `friction`

    Friction coefficient.

    Pymunk uses the Coulomb friction model, a value of 0.0 is frictionless.

    A value over 1.0 is perfectly fine.

    Some real world example values from Wikipedia (Remember that it is what looks good that is important, not the exact value).

    Material | Other | Friction
    --- | --- | ---
    Aluminium | Steel | 0.61
    Copper | Steel | 0.53
    Brass | Steel | 0.51
    Cast iron | Copper | 1.05
    Cast iron | Zinc | 0.85
    Concrete (wet) | Rubber | 0.30
    Concrete (dry) | Rubber | 1.0
    Concrete | Wood | 0.62
    Copper | Glass | 0.68
    Glass | Glass | 0.94
    Metal | Wood | 0.5
    Polyethene | Steel | 0.2
    Steel | Steel | 0.80
    Steel | Teflon | 0.04
    Teflon (PTFE) | Teflon | 0.04
    Wood | Wood | 0.4

  `mass`

    The mass of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `moment`

    The calculated moment of this shape.

  `point_query`(p)

    Check if the given point lies within the shape.

    A negative distance means the point is within the shape.

    Returns: | Tuple of (distance, info)
    Return type: | (float, `PointQueryInfo`)

  `segment_query`(start, end, radius=0)

    Check if the line segment from start to end intersects the shape.

    Return type: | `SegmentQueryInfo`

  `sensor`

    A boolean value if this shape is a sensor or not.

    Sensors only call collision callbacks, and never generate real collisions.

  `shapes_collide`(b)

    Get contact information about this shape and shape b.

    Return type: | `ContactPointSet`

  `space`

    Get the `Space` that shape has been added to (or None).

  `surface_velocity`

    The surface velocity of the object.

    Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.

  `update`(transform)

    Update, cache and return the bounding box of a shape with an explicit transformation.

    Useful if you have a shape without a body and want to use it for querying.

class `pymunk.``Circle`(body, radius, offset=(0, 0))

  Bases: `pymunk.shapes.Shape`

  A circle shape defined by a radius

  This is the fastest and simplest collision shape

  `__init__`(body, radius, offset=(0, 0))

    body is the body attach the circle to, offset is the offset from the body’s center of gravity in body local coordinates.

    It is legal to send in None as body argument to indicate that this shape is not attached to a body. However, you must attach it to a body before adding the shape to a space or used for a space shape query.

  `area`

    The calculated area of this shape.

  `bb`

    The bounding box `BB` of the shape.

    Only guaranteed to be valid after `Shape.cache_bb()` or `Space.step()` is called. Moving a body that a shape is connected to does not update it’s bounding box. For shapes used for queries that aren’t attached to bodies, you can also use `Shape.update()`.

  `body`

    The body this shape is attached to. Can be set to None to indicate that this shape doesnt belong to a body.

  `cache_bb`()

    Update and returns the bounding box of this shape

  `center_of_gravity`

    The calculated center of gravity of this shape.

  `collision_type`

    User defined collision type for the shape.

    See `Space.add_collision_handler()` function for more information on when to use this property.

  `copy`()

    Create a deep copy of this shape.

  `density`

    The density of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `elasticity`

    Elasticity of the shape.

    A value of 0.0 gives no bounce, while a value of 1.0 will give a ‘perfect’ bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.

  `filter`

    Set the collision `ShapeFilter` for this shape.

  `friction`

    Friction coefficient.

    Pymunk uses the Coulomb friction model, a value of 0.0 is frictionless.

    A value over 1.0 is perfectly fine.

    Some real world example values from Wikipedia (Remember that it is what looks good that is important, not the exact value).

    Material | Other | Friction
    --- | --- | ---
    Aluminium | Steel | 0.61
    Copper | Steel | 0.53
    Brass | Steel | 0.51
    Cast iron | Copper | 1.05
    Cast iron | Zinc | 0.85
    Concrete (wet) | Rubber | 0.30
    Concrete (dry) | Rubber | 1.0
    Concrete | Wood | 0.62
    Copper | Glass | 0.68
    Glass | Glass | 0.94
    Metal | Wood | 0.5
    Polyethene | Steel | 0.2
    Steel | Steel | 0.80
    Steel | Teflon | 0.04
    Teflon (PTFE) | Teflon | 0.04
    Wood | Wood | 0.4

  `mass`

    The mass of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `moment`

    The calculated moment of this shape.

  `offset`

    Offset. (body space coordinates)

  `point_query`(p)

    Check if the given point lies within the shape.

    A negative distance means the point is within the shape.

    Returns: | Tuple of (distance, info)
    Return type: | (float, `PointQueryInfo`)

  `radius`

    The Radius of the circle

  `segment_query`(start, end, radius=0)

    Check if the line segment from start to end intersects the shape.

    Return type: | `SegmentQueryInfo`

  `sensor`

    A boolean value if this shape is a sensor or not.

    Sensors only call collision callbacks, and never generate real collisions.

  `shapes_collide`(b)

    Get contact information about this shape and shape b.

    Return type: | `ContactPointSet`

  `space`

    Get the `Space` that shape has been added to (or None).

  `surface_velocity`

    The surface velocity of the object.

    Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.

  `unsafe_set_offset`(o)

    Unsafe set the offset of the circle.

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `unsafe_set_radius`(r)

    Unsafe set the radius of the circle.

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `update`(transform)

    Update, cache and return the bounding box of a shape with an explicit transformation.

    Useful if you have a shape without a body and want to use it for querying.

class `pymunk.``Poly`(body, vertices, transform=None, radius=0)

  Bases: `pymunk.shapes.Shape`

  A convex polygon shape

  Slowest, but most flexible collision shape.

  `__init__`(body, vertices, transform=None, radius=0)

    Create a polygon.

    A convex hull will be calculated from the vertexes automatically.

    Adding a small radius will bevel the corners and can significantly reduce problems where the poly gets stuck on seams in your geometry.

    It is legal to send in None as body argument to indicate that this shape is not attached to a body. However, you must attach it to a body before adding the shape to a space or used for a space shape query.

    Parameters: | body (Body) – The body to attach the poly to vertices ([(float,float)]) – Define a convex hull of the polygon with a counterclockwise winding. transform (Transform) – Transform will be applied to every vertex. radius (float) – Set the radius of the poly shape

  `area`

    The calculated area of this shape.

  `bb`

    The bounding box `BB` of the shape.

    Only guaranteed to be valid after `Shape.cache_bb()` or `Space.step()` is called. Moving a body that a shape is connected to does not update it’s bounding box. For shapes used for queries that aren’t attached to bodies, you can also use `Shape.update()`.

  `body`

    The body this shape is attached to. Can be set to None to indicate that this shape doesnt belong to a body.

  `cache_bb`()

    Update and returns the bounding box of this shape

  `center_of_gravity`

    The calculated center of gravity of this shape.

  `collision_type`

    User defined collision type for the shape.

    See `Space.add_collision_handler()` function for more information on when to use this property.

  `copy`()

    Create a deep copy of this shape.

  static `create_box`(body, size=(10, 10), radius=0)

    Convenience function to create a box given a width and height.

    The boxes will always be centered at the center of gravity of the body you are attaching them to. If you want to create an off-center box, you will need to use the normal constructor Poly(…).

    Adding a small radius will bevel the corners and can significantly reduce problems where the box gets stuck on seams in your geometry.

    Parameters: | body (Body) – The body to attach the poly to size ((float, float)) – Size of the box as (width, height) radius (float) – Radius of poly
    Return type: | `Poly`

  static `create_box_bb`(body, bb, radius=0)

    Convenience function to create a box shape from a `BB`.

    The boxes will always be centered at the center of gravity of the body you are attaching them to. If you want to create an off-center box, you will need to use the normal constructor Poly(..).

    Adding a small radius will bevel the corners and can significantly reduce problems where the box gets stuck on seams in your geometry.

    Parameters: | body (Body) – The body to attach the poly to bb (BB) – Size of the box radius (float) – Radius of poly
    Return type: | `Poly`

  `density`

    The density of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `elasticity`

    Elasticity of the shape.

    A value of 0.0 gives no bounce, while a value of 1.0 will give a ‘perfect’ bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.

  `filter`

    Set the collision `ShapeFilter` for this shape.

  `friction`

    Friction coefficient.

    Pymunk uses the Coulomb friction model, a value of 0.0 is frictionless.

    A value over 1.0 is perfectly fine.

    Some real world example values from Wikipedia (Remember that it is what looks good that is important, not the exact value).

    Material | Other | Friction
    --- | --- | ---
    Aluminium | Steel | 0.61
    Copper | Steel | 0.53
    Brass | Steel | 0.51
    Cast iron | Copper | 1.05
    Cast iron | Zinc | 0.85
    Concrete (wet) | Rubber | 0.30
    Concrete (dry) | Rubber | 1.0
    Concrete | Wood | 0.62
    Copper | Glass | 0.68
    Glass | Glass | 0.94
    Metal | Wood | 0.5
    Polyethene | Steel | 0.2
    Steel | Steel | 0.80
    Steel | Teflon | 0.04
    Teflon (PTFE) | Teflon | 0.04
    Wood | Wood | 0.4

  `get_vertices`()

    Get the vertices in local coordinates for the polygon

    If you need the vertices in world coordinates then the vertices can be transformed by adding the body position and each vertex rotated by the body rotation in the following way:

        >>> import pymunk
        >>> b = pymunk.Body()
        >>> b.position = 1,2
        >>> b.angle = 0.5
        >>> shape = pymunk.Poly(b, [(0,0), (10,0), (10,10)])
        >>> for v in shape.get_vertices():
        ...     print(v.rotated(shape.body.angle) + shape.body.position)
        Vec2d(1.0, 2.0)
        Vec2d(9.7758256189, 6.79425538604)
        Vec2d(4.98157023286, 15.5700810049)

    Returns: | The vertices in local coords
    Return type: | [`Vec2d`]

  `mass`

    The mass of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `moment`

    The calculated moment of this shape.

  `point_query`(p)

    Check if the given point lies within the shape.

    A negative distance means the point is within the shape.

    Returns: | Tuple of (distance, info)
    Return type: | (float, `PointQueryInfo`)

  `radius`

    The radius of the poly shape. Extends the poly in all directions with the given radius

  `segment_query`(start, end, radius=0)

    Check if the line segment from start to end intersects the shape.

    Return type: | `SegmentQueryInfo`

  `sensor`

    A boolean value if this shape is a sensor or not.

    Sensors only call collision callbacks, and never generate real collisions.

  `shapes_collide`(b)

    Get contact information about this shape and shape b.

    Return type: | `ContactPointSet`

  `space`

    Get the `Space` that shape has been added to (or None).

  `surface_velocity`

    The surface velocity of the object.

    Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.

  `unsafe_set_radius`(radius)

    Unsafe set the radius of the poly.

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `unsafe_set_vertices`(vertices, transform=None)

    Unsafe set the vertices of the poly.

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `update`(transform)

    Update, cache and return the bounding box of a shape with an explicit transformation.

    Useful if you have a shape without a body and want to use it for querying.

class `pymunk.``Segment`(body, a, b, radius)

  Bases: `pymunk.shapes.Shape`

  A line segment shape between two points

  Meant mainly as a static shape. Can be beveled in order to give them a thickness.

  `__init__`(body, a, b, radius)

    Create a Segment

    It is legal to send in None as body argument to indicate that this shape is not attached to a body. However, you must attach it to a body before adding the shape to a space or used for a space shape query.

    Parameters: | body (Body) – The body to attach the segment to a – The first endpoint of the segment b – The second endpoint of the segment radius (float) – The thickness of the segment

  `a`

    The first of the two endpoints for this segment

  `area`

    The calculated area of this shape.

  `b`

    The second of the two endpoints for this segment

  `bb`

    The bounding box `BB` of the shape.

    Only guaranteed to be valid after `Shape.cache_bb()` or `Space.step()` is called. Moving a body that a shape is connected to does not update it’s bounding box. For shapes used for queries that aren’t attached to bodies, you can also use `Shape.update()`.

  `body`

    The body this shape is attached to. Can be set to None to indicate that this shape doesnt belong to a body.

  `cache_bb`()

    Update and returns the bounding box of this shape

  `center_of_gravity`

    The calculated center of gravity of this shape.

  `collision_type`

    User defined collision type for the shape.

    See `Space.add_collision_handler()` function for more information on when to use this property.

  `copy`()

    Create a deep copy of this shape.

  `density`

    The density of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `elasticity`

    Elasticity of the shape.

    A value of 0.0 gives no bounce, while a value of 1.0 will give a ‘perfect’ bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.

  `filter`

    Set the collision `ShapeFilter` for this shape.

  `friction`

    Friction coefficient.

    Pymunk uses the Coulomb friction model, a value of 0.0 is frictionless.

    A value over 1.0 is perfectly fine.

    Some real world example values from Wikipedia (Remember that it is what looks good that is important, not the exact value).

    Material | Other | Friction
    --- | --- | ---
    Aluminium | Steel | 0.61
    Copper | Steel | 0.53
    Brass | Steel | 0.51
    Cast iron | Copper | 1.05
    Cast iron | Zinc | 0.85
    Concrete (wet) | Rubber | 0.30
    Concrete (dry) | Rubber | 1.0
    Concrete | Wood | 0.62
    Copper | Glass | 0.68
    Glass | Glass | 0.94
    Metal | Wood | 0.5
    Polyethene | Steel | 0.2
    Steel | Steel | 0.80
    Steel | Teflon | 0.04
    Teflon (PTFE) | Teflon | 0.04
    Wood | Wood | 0.4

  `mass`

    The mass of this shape.

    This is useful when you let Pymunk calculate the total mass and inertia of a body from the shapes attached to it. (Instead of setting the body mass and inertia directly)

  `moment`

    The calculated moment of this shape.

  `normal`

    The normal

  `point_query`(p)

    Check if the given point lies within the shape.

    A negative distance means the point is within the shape.

    Returns: | Tuple of (distance, info)
    Return type: | (float, `PointQueryInfo`)

  `radius`

    The radius/thickness of the segment

  `segment_query`(start, end, radius=0)

    Check if the line segment from start to end intersects the shape.

    Return type: | `SegmentQueryInfo`

  `sensor`

    A boolean value if this shape is a sensor or not.

    Sensors only call collision callbacks, and never generate real collisions.

  `set_neighbors`(prev, next)

    When you have a number of segment shapes that are all joined together, things can still collide with the “cracks” between the segments. By setting the neighbor segment endpoints you can tell Chipmunk to avoid colliding with the inner parts of the crack.

  `shapes_collide`(b)

    Get contact information about this shape and shape b.

    Return type: | `ContactPointSet`

  `space`

    Get the `Space` that shape has been added to (or None).

  `surface_velocity`

    The surface velocity of the object.

    Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.

  `unsafe_set_endpoints`(a, b)

    Set the two endpoints for this segment

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `unsafe_set_radius`(r)

    Set the radius of the segment

    Note

    This change is only picked up as a change to the position of the shape’s surface, but not it’s velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!

  `update`(transform)

    Update, cache and return the bounding box of a shape with an explicit transformation.

    Useful if you have a shape without a body and want to use it for querying.

`pymunk.``moment_for_circle`(mass, inner_radius, outer_radius, offset=(0, 0))

  Calculate the moment of inertia for a hollow circle

  inner_radius and outer_radius are the inner and outer diameters. (A solid circle has an inner diameter of 0)

`pymunk.``moment_for_poly`(mass, vertices, offset=(0, 0), radius=0)

  Calculate the moment of inertia for a solid polygon shape.

  Assumes the polygon center of gravity is at its centroid. The offset is added to each vertex.

`pymunk.``moment_for_segment`(mass, a, b, radius)

  Calculate the moment of inertia for a line segment

  The endpoints a and b are relative to the body

`pymunk.``moment_for_box`(mass, size)

  Calculate the moment of inertia for a solid box centered on the body.

  size should be a tuple of (width, height)

class `pymunk.``SegmentQueryInfo`

  Bases: `pymunk.query_info.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.

  To test if the query hit something, check if SegmentQueryInfo.shape == None or not.

  Segment queries are like ray casting, but because not all spatial indexes allow processing infinitely long ray queries it is limited to segments. In practice this is still very fast and you don’t need to worry too much about the performance as long as you aren’t using extremely long segments for your queries.

  The properties are as follows

  shape Shape that was hit, or None if no collision occured

  point The point of impact.

  normal The normal of the surface hit.

  alpha The normalized distance along the query segment in the range [0, 1]

  `__init__`

    x.__init__(…) initializes x; see help(type(x)) for signature

  `alpha`

    Alias for field number 3

  `count`(value) → integer – return number of occurrences of value
  `index`(value[, start[, stop]]) → integer – return first index of value.

    Raises ValueError if the value is not present.

  `normal`

    Alias for field number 2

  `point`

    Alias for field number 1

  `shape`

    Alias for field number 0

class `pymunk.``ContactPoint`(point_a, point_b, distance)

  Bases: `object`

  Contains information about a contact point.

  point_a and point_b are the contact position on the surface of each shape.

  distance is the penetration distance of the two shapes. Overlapping means it will be negative. This value is calculated as dot(point2 - point1), normal) and is ignored when you set the Arbiter.contact_point_set.

  `__init__`(point_a, point_b, distance)
  `distance`
  `point_a`
  `point_b`

class `pymunk.``ContactPointSet`(normal, points)

  Bases: `object`

  Contact point sets make getting contact information simpler.

  normal is the normal of the collision

  points is the array of contact points. Can be at most 2 points.

  `__init__`(normal, points)
  `normal`
  `points`

class `pymunk.``Arbiter`(_arbiter, space)

  Bases: `object`

  The Arbiter object encapsulates a pair of colliding shapes and all of

    the data about their collision.

    They are created when a collision starts, and persist until those shapes are no longer colliding.

  Warning

  Because arbiters are handled by the space you should never hold onto a reference to an arbiter as you don’t know when it will be destroyed! Use them within the callback where they are given to you and then forget about them or copy out the information you need from them.

  `__init__`(_arbiter, space)

    Initialize an Arbiter object from the Chipmunk equivalent struct and the Space.

    Note

    You should never need to create an instance of this class directly.

  `contact_point_set`

    Contact point sets make getting contact information from the Arbiter simpler.

    Return ContactPointSet

  `friction`

    The calculated friction for this collision pair.

    Setting the value in a pre_solve() callback will override the value calculated by the space. The default calculation multiplies the friction of the two shapes together.

  `is_first_contact`

    Returns true if this is the first step the two shapes started touching.

    This can be useful for sound effects for instance. If its the first frame for a certain collision, check the energy of the collision in a post_step() callback and use that to determine the volume of a sound effect to play.

  `is_removal`

    Returns True during a separate() callback if the callback was invoked due to an object removal.

  `restitution`

    The calculated restitution (elasticity) for this collision pair.

    Setting the value in a pre_solve() callback will override the value calculated by the space. The default calculation multiplies the elasticity of the two shapes together.

  `shapes`

    Get the shapes in the order that they were defined in the collision handler associated with this arbiter

  `surface_velocity`

    The calculated surface velocity for this collision pair.

    Setting the value in a pre_solve() callback will override the value calculated by the space. the default calculation subtracts the surface velocity of the second shape from the first and then projects that onto the tangent of the collision. This is so that only friction is affected by default calculation. Using a custom calculation, you can make something that responds like a pinball bumper, or where the surface velocity is dependent on the location of the contact point.

  `total_impulse`

    Returns the impulse that was applied this step to resolve the collision.

    This property should only be called from a post-solve, post-step

  `total_ke`

    The amount of energy lost in a collision including static, but not dynamic friction.

    This property should only be called from a post-solve, post-step

class `pymunk.``CollisionHandler`(_handler, space, *args, **kwargs)

  Bases: `object`

  A collision handler is a set of 4 function callbacks for the different collision events that Pymunk recognizes.

  Collision callbacks are closely associated with Arbiter objects. You should familiarize yourself with those as well.

  Note #1: Shapes tagged as sensors (Shape.sensor == true) never generate collisions that get processed, so collisions between sensors shapes and other shapes will never call the post_solve() callback. They still generate begin(), and separate() callbacks, and the pre_solve() callback is also called every frame even though there is no collision response. Note #2: pre_solve() callbacks are called before the sleeping algorithm runs. If an object falls asleep, its post_solve() callback won’t be called until it’s re-awoken.

  `__init__`(_handler, space, *args, **kwargs)

    Initialize a CollisionHandler object from the Chipmunk equivalent struct and the Space.

    Note

    You should never need to create an instance of this class directly.

  `begin`

    Two shapes just started touching for the first time this step.

    `func(arbiter, space, data) -> bool`

    Return true from the callback to process the collision normally or false to cause pymunk to ignore the collision entirely. If you return false, the pre_solve and post_solve callbacks will never be run, but you will still recieve a separate event when the shapes stop overlapping.

  `data`

    Data property that get passed on into the callbacks.

    data is a dictionary and you can not replace it, only fill it with data.

    Usefull if the callback needs some extra data to perform its function.

  `post_solve`

    Two shapes are touching and their collision response has been processed.

    `func(arbiter, space, data)`

    You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See Arbiter for more info.

  `pre_solve`

    Two shapes are touching during this step.

    `func(arbiter, space, data) -> bool`

    Return false from the callback to make pymunk ignore the collision this step or true to process it normally. Additionally, you may override collision values using Arbiter.friction, Arbiter.elasticity or Arbiter.surfaceVelocity to provide custom friction, elasticity, or surface velocity values. See Arbiter for more info.

  `separate`

    Two shapes have just stopped touching for the first time this step.

    `func(arbiter, space, data)`

    To ensure that begin()/separate() are always called in balanced pairs, it will also be called when removing a shape while its in contact with something or when de-allocating the space.

class `pymunk.``BB`(*args)

  Bases: `pymunk._pickle.PickleMixin`, `object`

  Simple bounding box.

  Stored as left, bottom, right, top values.

  `__init__`(*args)

    Create a new instance of a bounding box.

    Can be created with zero size with bb = BB() or with four args defining left, bottom, right and top: bb = BB(left, bottom, right, top)

  `area`()

    Return the area

  `bottom`
  `center`()

    Return the center

  `clamp_vect`(v)

    Returns a copy of the vector v clamped to the bounding box

  `contains`(other)

    Returns true if bb completley contains the other bb

  `contains_vect`(v)

    Returns true if this bb contains the vector v

  `copy`()

    Create a deep copy of this BB.

  `expand`(v)

    Return the minimal bounding box that contans both this bounding box and the vector v

  `intersects`(other)

    Returns true if the bounding boxes intersect

  `intersects_segment`(a, b)

    Returns true if the segment defined by endpoints a and b intersect this bb.

  `left`
  `merge`(other)

    Return the minimal bounding box that contains both this bb and the other bb

  `merged_area`(other)

    Merges this and other then returns the area of the merged bounding box.

  static `newForCircle`(p, r)

    Convenience constructor for making a BB fitting a circle at position p with radius r.

  `right`
  `segment_query`(a, b)

    Returns the fraction along the segment query the BB is hit.

    Returns infinity if it doesnt hit

  `top`

class `pymunk.``ShapeFilter`

  Bases: `pymunk.shape_filter.ShapeFilter`

  Pymunk has two primary means of ignoring collisions: groups and category masks.

  Groups are used to ignore collisions between parts on a complex object. A ragdoll is a good example. When jointing an arm onto the torso, you’ll want them to allow them to overlap. Groups allow you to do exactly that. Shapes that have the same group don’t generate collisions. So by placing all of the shapes in a ragdoll in the same group, you’ll prevent it from colliding against other parts of itself. Category masks allow you to mark which categories an object belongs to and which categories it collidies with.

  For example, a game has four collision categories: player (0), enemy (1), player bullet (2), and enemy bullet (3). Neither players nor enemies should not collide with their own bullets, and bullets should not collide with other bullets. However, players collide with enemy bullets, and enemies collide with player bullets.

  Object | Object Category | Category Mask
  --- | --- | ---
  Player | 1 | 4, 5
  Enemy | 2 | 2, 3, 4
  Player Bullet | 3 | 1, 5
  Enemy Bullet | 4 | 2, 5
  Walls | 5 | 1, 2, 3, 4

  Note that everything in this example collides with walls. Additionally, the enemies collide with each other.

  By default, objects exist in every category and collide with every category.

  Objects can fall into multiple categories. For instance, you might have a category for a red team, and have a red player bullet. In the above example, each object only has one category.

  The default type of categories and mask in ShapeFilter is unsigned int which has a resolution of 32 bits on most systems.

  There is one last way of filtering collisions using collision handlers. See the section on callbacks for more information. Collision handlers can be more flexible, but can be slower. Fast collision filtering rejects collisions before running the expensive collision detection code, so using groups or category masks is preferred.

  Example of how category and mask can be used to filter out player from enemy object:

      >>> import pymunk
      >>> s = pymunk.Space()
      >>> player_b = pymunk.Body(1,1)
      >>> player_c = pymunk.Circle(player_b, 10)
      >>> s.add(player_b, player_c)
      >>> player_c.filter = pymunk.ShapeFilter(categories=0x1)
      >>> hit = s.point_query_nearest((0,0), 0, pymunk.ShapeFilter())
      >>> hit != None
      True
      >>> filter = pymunk.ShapeFilter(mask=pymunk.ShapeFilter.ALL_MASKS ^ 0x1)
      >>> hit = s.point_query_nearest((0,0), 0, filter)
      >>> hit == None
      True
      >>> enemy_b = pymunk.Body(1,1)
      >>> enemy_c = pymunk.Circle(enemy_b, 10)
      >>> s.add(enemy_b, enemy_c)
      >>> hit = s.point_query_nearest((0,0), 0, filter)
      >>> hit != None
      True

  `ALL_CATEGORIES` = 4294967295L
  `ALL_MASKS` = 4294967295L
  `__init__`

    x.__init__(…) initializes x; see help(type(x)) for signature

  `categories`

    Alias for field number 1

  `count`(value) → integer – return number of occurrences of value
  `group`

    Alias for field number 0

  `index`(value[, start[, stop]]) → integer – return first index of value.

    Raises ValueError if the value is not present.

  `mask`

    Alias for field number 2

class `pymunk.``Transform`

  Bases: `pymunk.transform.Transform`

  Type used for 2x3 affine transforms.

  See wikipedia for details: http://en.wikipedia.org/wiki/Affine_transformation

  The properties map to the matrix in this way:

  a | c | tx
  b | d | ty

  An instance can be created in this way::

        >>> Transform(1,2,3,4,5,6)
        Transform(a=1, b=2, c=3, d=4, tx=5, ty=6)

  Or using the default identity in this way::

        >>> Transform.identity()
        Transform(a=1, b=0, c=0, d=1, tx=0, ty=0)

  Or overriding only some of the values (on a identity matrix):

        >>> Transform(b=3,ty=5)
        Transform(a=1, b=3, c=0, d=1, tx=0, ty=5)

  `__init__`

    x.__init__(…) initializes x; see help(type(x)) for signature

  `a`

    Alias for field number 0

  `b`

    Alias for field number 1

  `c`

    Alias for field number 2

  `count`(value) → integer – return number of occurrences of value
  `d`

    Alias for field number 3

  static `identity`()

    The identity transform

  `index`(value[, start[, stop]]) → integer – return first index of value.

    Raises ValueError if the value is not present.

  `tx`

    Alias for field number 4

  `ty`

    Alias for field number 5

class `pymunk.``PointQueryInfo`

  Bases: `pymunk.query_info.PointQueryInfo`

  PointQueryInfo holds the result of a point query made on a Shape or Space.

  The properties are as follows

  shape The nearest shape, None if no shape was within range.

  point The closest point on the shape’s surface. (in world space coordinates)

  distance The distance to the point. The distance is negative if the point is inside the shape.

  gradient The gradient of the signed distance function.

  > The value should be similar to PointQueryInfo.point/PointQueryInfo.distance, but accurate even for very small values of info.distance.

  `__init__`

    x.__init__(…) initializes x; see help(type(x)) for signature

  `count`(value) → integer – return number of occurrences of value
  `distance`

    Alias for field number 2

  `gradient`

    Alias for field number 3

  `index`(value[, start[, stop]]) → integer – return first index of value.

    Raises ValueError if the value is not present.

  `point`

    Alias for field number 1

  `shape`

    Alias for field number 0

class `pymunk.``ShapeQueryInfo`

  Bases: `pymunk.query_info.ShapeQueryInfo`

  Shape queries return more information than just a simple yes or no, they also return where a shape was hit. This object hold that information.

  `__init__`

    x.__init__(…) initializes x; see help(type(x)) for signature

  `contact_point_set`

    Alias for field number 1

  `count`(value) → integer – return number of occurrences of value
  `index`(value[, start[, stop]]) → integer – return first index of value.

    Raises ValueError if the value is not present.

  `shape`

    Alias for field number 0

class `pymunk.``SpaceDebugDrawOptions`

  Bases: `object`

  SpaceDebugDrawOptions configures debug drawing.

  If appropriate its usually easy to use the supplied draw implementations directly: pymunk.pygame_util, pymunk.pyglet_util and pymunk.matplotlib_util.

  `DRAW_COLLISION_POINTS`

    alias of `CP_SPACE_DEBUG_DRAW_COLLISION_POINTS`

  `DRAW_CONSTRAINTS`

    alias of `CP_SPACE_DEBUG_DRAW_CONSTRAINTS`

  `DRAW_SHAPES`

    alias of `CP_SPACE_DEBUG_DRAW_SHAPES`

  `__init__`()
  `collision_point_color`
  `color_for_shape`(shape)
  `constraint_color`
  `draw_circle`(*args)
  `draw_dot`(*args)
  `draw_fat_segment`(*args)
  `draw_polygon`(*args)
  `draw_segment`(*args)
  `flags`
  `shape_dynamic_color` = SpaceDebugColor(r=52, g=152, b=219, a=255)
  `shape_kinematic_color` = SpaceDebugColor(r=39, g=174, b=96, a=255)
  `shape_outline_color`
  `shape_sleeping_color` = SpaceDebugColor(r=114, g=148, b=168, a=255)
  `shape_static_color` = SpaceDebugColor(r=149, g=165, b=166, a=255)