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.
Thanks for any help in advance.