Bouncing Ball
-
- Posts: 14
- Joined: Wed Aug 03, 2005 3:47 pm
Bouncing Ball
How do you guys get a bouncing ball to eventually come to rest? It would be nice if somehow the velocity and position became zero eventually due to floating point round-off errors.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
-
- Posts: 14
- Joined: Wed Aug 03, 2005 3:47 pm
-
- Posts: 1
- Joined: Thu Oct 19, 2006 2:36 am
- Location: Western Australia
How much jittering are we talking about?
With any physics simulations, objects resting on other objects are generally always jittering to some degree which is also true in reality.
If you want to be able to make sure that an object remains absolutely still, then you could put in a check:
This way the ball's velocity will be considered zero when it is very small.
With any physics simulations, objects resting on other objects are generally always jittering to some degree which is also true in reality.
If you want to be able to make sure that an object remains absolutely still, then you could put in a check:
Code: Select all
if (vel.length() < minVel)
vel = 0;
-
- Posts: 127
- Joined: Sun Aug 13, 2006 4:41 pm
- Location: Cedar Hill, Texas
Even if you didn't clamp it, the fact that the computer doesn't have infinite precision should mean that roundoff error will eventually allow the velocity to reach zero.
But since that could take quite a while and there are performance optimisations to be had by stopping things from moving unnecessarily, it's probably a good idea to clamp it anyway.
But since that could take quite a while and there are performance optimisations to be had by stopping things from moving unnecessarily, it's probably a good idea to clamp it anyway.