Package pymunk :: Class Body
[frames] | no frames]

Class Body

object --+
         |
        Body

Instance Methods
 
__init__(self, mass, inertia)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__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.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
  mass
  moment
  angle
  rotation_vector
  torque
  position
  velocity
  angular_velocity

Inherited from object: __class__

Method Details

__init__(self, mass, inertia)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

apply_impulse(self, j, r)

 
Apply the impulse j to body with offset r.
Parameters:
  • j ((x,y) or Vec2d) - Impulse to be applied
  • r ((x,y) or Vec2d) - Offset the impulse with this vector

apply_force(self, f, r)

 

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

f : (x,y) or Vec2d
Force in world coordinates
r : (x,y) or Vec2d
Offset in world coordinates

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(self, dt)

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

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.
Parameters:
  • b (Body) - The other body
  • anchor1 ((x,y) or Vec2d) - Anchor point on the first body
  • anchor2 ((x,y) or Vec2d) - Anchor point on the second body
  • k (float) - The spring constant (force/distance)
  • rlen (float) - The rest length of the spring
  • dmp (float) - The damping constant (force/velocity)
  • dt (float) - The time step to apply the force over.

Property Details

mass

Get Method:
_get_mass(self)
Set Method:
_set_mass(self, mass)

moment

Get Method:
_get_moment(self)
Set Method:
_set_moment(self, moment)

angle

Get Method:
_get_angle(self)
Set Method:
_set_angle(self, angle)

rotation_vector

Get Method:
_get_rotation_vector(self)

torque

Get Method:
_get_torque(self)
Set Method:
_set_torque(self, t)

position

Get Method:
_get_position(self)
Set Method:
_set_position(self, pos)

velocity

Get Method:
_get_velocity(self)
Set Method:
_set_velocity(self, vel)

angular_velocity

Get Method:
_get_angular_velocity(self)
Set Method:
_set_angular_velocity(self, w)