pymunk icon indicating copy to clipboard operation
pymunk copied to clipboard

Incorrect angle values in collisions

Open DigitalDetective47 opened this issue 2 years ago • 1 comments

Below, I have created a simulation where a box lands on a flat floor.

import pymunk

space = pymunk.Space()
space.gravity = (0, -1)
box_body = pymunk.Body()
box_shape = pymunk.Poly.create_box(box_body, (1, 1))
box_body.position = (0, 20)
box_body.velocity = (0, 0)
box_shape.mass = 1
floor = pymunk.Segment(space.static_body, (-5, 0), (5, 0), 1)
space.add(floor, box_body, box_shape)
for _ in range(63):
    space.step(0.1)
print(box_body.angle)

When I run this code, I get a value of -4.8183679268731794e-14, rather than the 0.0 that I expect. I do, however, get 0.0 for all step counts less than 63, which correspond to times before the box hits the floor. When I change the step count to 64, I get 7.805375706901558e-15. I have discussed this with others on Stack Overflow, and everyone else seems to get the expected value of 0.0. I am on 64‐bit Windows 10 running Pymunk 6.2.0 with Python 3.9.7.

DigitalDetective47 avatar Sep 18 '21 00:09 DigitalDetective47

Thanks for the report. After I tried a bit I managed to reproduce the error. Dont have a good answer yet, will do some experiments.

viblo avatar Sep 19 '21 11:09 viblo