sugarlabs / physics

a box2d playpen
GNU General Public License v3.0
7 stars 26 forks source link

Reduce maximum restitution #56

Closed sparshg closed 1 year ago

sparshg commented 1 year ago

Refer: https://github.com/sugarlabs/physics/issues/28#issuecomment-1644697676 @chimosky I have set the restitution to 0.95 instead of 1 to atleast prevent the system from gaining energy and becoming unstable.

chimosky commented 1 year ago

Tested 86cfb08 and the objects never stopped bouncing. 8c1ee5c fixes the issue, please test.

sparshg commented 1 year ago

Tested https://github.com/sugarlabs/physics/commit/86cfb08b5c29e461bd166664033d9990a001d967 and the objects never stopped bouncing

That is the intended behaviour, that is what was meant by restitution=1 (no relative speed change) for basketball, meaning that it should bounce till the same height and keep bouncing forever. My change will set it to 0.95, it will not bounce forever as a side-effect but it will bounce for long enough and also prevent unexpacted energy gain.

I don't think 8c1ee5c would be correct

sparshg commented 1 year ago

@quozl Can you take a look at this? Thanks

quozl commented 1 year ago

What specifically do you need? I raised the issue because I didn't plan to fix it myself; otherwise I would have fixed it immediately when the code was in my head.

Various resources give the bounce height of a basketball in competition at standard inflation, temperature, and air pressure, of between 60% and 80%. 16% doesn't seem right, nor does 93%. 100% is not realistic simulation.

sparshg commented 1 year ago

I did set it to 95% just because it was close to the original value of 100% so there won't be much noticeable change, but yes it won't be realistic. I think 70% would be a good choice then and solve all the issues too.

chimosky commented 1 year ago

Tested 53d9541, 70% is a good choice.