Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surprising simulation results #69

Closed
gmorenz opened this issue May 9, 2016 · 2 comments
Closed

Surprising simulation results #69

gmorenz opened this issue May 9, 2016 · 2 comments

Comments

@gmorenz
Copy link
Contributor

gmorenz commented May 9, 2016

Simulating a ball bouncing between two stationary paddles results in some surprising output. Everything has a restitution of 1, the ball starts with a velocity 20 towards one paddle. A few of the anomalies are that after the second bounce the velocity more than doubles, and that it reaches a velocity of over 400 for an extended period of time. Code demonstrating this is here, output of the code is here.

I assume this isn't the intended behavior? Unfortunately I'm not experienced enough with physics engines to try and debug this.

@sebcrozet
Copy link
Member

sebcrozet commented May 9, 2016

After investigating this, I figured out those three issue:

  1. The jump in velocity you are experiencing is due to a collision detection bug. It should be easy to fix for this specific case (involving a Ball), but harder when only other types of shape are involved.
  2. Even without the collision detection bug, you will observe that the ball will accelerate slowly but continuously as the simulation proceeds. This is the expected behavior because the physics engine has to add energy to the system in order to fix penetrations. Because the restitution coefficients are equal to 1, no velocity dampening will happen to dissipate the extra energy. To avoid this behavior, I should add a way to disable velocity-based constraint stabilisation, and give the user the ability to add damping to each rigid body.
  3. If velocity-based constraint stabilisation is disabled, the opposite will happen: the ball will lose all its kinetic energy extremely quickly. This is a bug probably due to those lines of the constraints solver.

sebcrozet added a commit that referenced this issue Aug 24, 2016
@sebcrozet
Copy link
Member

For will no longer happen since, starting with v0.8.0, nphysics only uses position-based constraint stabilization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants