I am writing a bouncing ball game in Java for Android phones. Everything seems to work fine apart from a small problem with collisions and the coefficient of restitution.

When a ball collides with a surface, the vector normal of this surface is calculated (nx and ny), and the vector direction of the ball (dx and dy) is reflected in this normal vector.

At the moment I am then using 0.9 as the coefficient of restitution and so multiplying both dx and dy by this value, which is obviously far too simplistic, as it does not properly simulate rolling.

Is there a simple formula to calculate the new dx and dy more accurately, so that if the ball is travelling almost parallel to a slope when it collides it loses less speed than if it collides perpendicularly.

Apologies for not posting any of my code, I'm away from my computer so can post it later if this would help anyone's understanding.

3 Answers
3

Coefficient of restitution has to do with the relative elasticity of the colliding objects. It's a simplisitic way to account for the fact that the ball and the surface both deform on impact. Some of the energy of deformation is lost (e.g. generated heat, sound waves, etc.), but most of it goes back into "pushing" the other body away.

None of the energy is lost if the coefficient of restitution equals 1.0. Think of it as a "fudge factor" so you don't have to do a dynamic elasticity problem.

Rolling is another matter.

I think the coefficient of restitution should only be applied to the normal component of the velocity. Friction and sliding would have to apply to the tangential component if you want to get closer to the real physics.

You'll also need another equation beyond just displacements in the x, y directions. You'll need another for the torque about the z-axis about the centroid of the ball.

Newton's equations of motion would sum forces in the x and y directions and the moments about the z-axis for the ball.

I might be wrong but an solution to this would be to calculate the angle of the ball, meaning artan(dy/dx).

Having this angle in reference to your origin you could then multiply by the cosine of this angle. Were if it would be completely parallel the speed would remain unchanged and if was completely perpendicular the speed would be zero.

You would have to account for this to make sure there is a min and max speed you want the balls to bounce.