import pymunk
space = pymunk.Space()
space.gravity = (0, -100)
body = pymunk.Body(body_type=pymunk.Body.DYNAMIC)
body.mass = 1
body.moment = pymunk.moment_for_box(body.mass, (100, 100))
shape = pymunk.Poly.create_box(body, (100, 100), 0)
space.add(body, shape)
for i in range(100):
print("center of gravity={0}\nposition ={1}\n".format(
body.center_of_gravity, body.position))
space.step(0.5)
The result is like this center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, 0.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, 0.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -25.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -75.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -150.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -250.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -375.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -525.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -700.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -900.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -1125.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -1375.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -1650.0)
center of gravity = Vec2d(0.0, 0.0) position = Vec2d(0.0, -1950.0)
. . .
What is the problem with center_of_gravity??