Class pymunk.Body

Methods

  __init__(self, mass, inertia)
  __del__(self)
  apply_impulse(self, j, r)
Apply the impulse j to body with offset r.
  reset_forces(self)
Reset the forces on the body
  apply_force(self, f, r)
Apply (accumulate) the force f on body with offset r.
  update_velocity(self, gravity, damping, dt)
Updates the velocity of the body using Euler integration.
  update_position(self, dt)
Updates the position of the body using Euler integration.
  local_to_world(self, v)
Convert body local to world coordinates
  world_to_local(self, v)
Convert world to body local coordinates
  damped_spring(self, b, anchor1, anchor2, rlen, k, dmp, dt)
Apply a spring force between this and body b at anchors anchr1 and anchr2 respectively.

Properties

  mass
  moment
  angle
  rotation_vector
  torque
  position
  velocity
  angular_velocity

Method Details

apply_force

apply_force(self, f, r)
Apply (accumulate) the force f on body with offset r. Both f and r should be in world coordinates.

update_velocity

update_velocity(self, gravity, damping, dt)
Updates the velocity of the body using Euler integration. You don't need to call this unless you are managing the object manually instead of adding it to a Space.

update_position

update_position(self, dt)
Updates the position of the body using Euler integration. Like updateVelocity() you shouldn't normally need to call this yourself.

damped_spring

damped_spring(self, b, anchor1, anchor2, rlen, k, dmp, dt)
Apply a spring force between this and body b at anchors anchr1 and anchr2 respectively. k is the spring constant (force/distance), rlen is the rest length of the spring, dmp is the damping constant (force/velocity), and dt is the time step to apply the force over.

Property Details

mass

moment

angle

rotation_vector

torque

position

velocity

angular_velocity