   Ball never stops bouncing
  I am creating a bouncing ball simulation and I am having a problem with the ball never stopping its bounce. Basically, my velocity never gets smaller, it just reflects the same little amount after a while (even when I try to clamp values). In my balls update the only way velocity is affected is by "velocity.y -= (gravity * elapsedTime);".When I go to reflect my velocity, I do take into account of coefficient of restitution, however, unless it is 0 there will also be some sort of bounce always. Here is my vector reflectionD3DXVec3Normalize(&surfaceNormalized, &collisionNormal);D3DXVECTOR3 incomingVelocity = sphere->GetVelocity();float IDotN = D3DXVec3Dot(&incomingVelocity, &surfaceNormalized);D3DXVECTOR3 reflectedVelocity = incomingVelocity - ((1.0f+sphere->GetCoR()) * surfaceNormalized * IDotN);I then set my reflectedVelocity to my sphere's velocity. For example, my coefficient of restitution I am using is 0.5, which should then eventually stop bouncing.I did it out on paper, and my "algorithm" is is going what I expect it to do, there is just not enough slow down on the velocity for to ever stop jittering. My question is, is my vector reflection algorithm correct? I thought it was, as it does seem it. If it is, how else can I slow down the velocity so it does not always bounce?The one thing I was thinking it is may have something to with the fact that I do calculate my collision time but I never do anything with that? But I never see anythinng to do with it   
  It looks correct, try replacing phere->GetCoR() with a constant 0.5f. Also we can't see where you put the velocity back into the sphere, and also, is the velocity of the sphere affected anywhere else?   ;  I tried with a constant 0.5 (so 1.0f+0.5f) and it I got the same thing, the function is fine. I st my velocity by doing a sphere->SetVelocity(reflectedVelocity);nothing fancy   ;  Without thinking too thorough about your troubles, could it be you just run into a precision problem?Take a float with small absolute and subtract something with even smaller absolute from it and you arrive at X - Y == X with Y != 0 ...You could compare velocity to a lower threshold (epsilon) and manually set it to 0 once you arrive there.;  Yes, if you continually multiply a non zero value by a fraction, it will never reach zero only get closer and closer to zero.I assumed that you meant any coefficient other than 0 would behave as if the coefficient was 1.0.;  Bear in mind that you're constantly injecting new velocity into the ball every time you apply gravity. It is common for physics engines to use a threshold under which restitution is treated as zero. This should fix your problem, as well as improve overall stability of more complex simulations.   ;  Your velocity will reduce with each bounce, but will continue to have a non-zero velocity. It will follow the pattern vn=viCRn, where n is the number of bounces.The best you can do is set a threshold below which the velocity is set to 0, and work out how many bounces you will allow before it stops.For instance, lets say you have a velocity of 10, you set a threshold of 0.001, and you want it to come to a halt after 6 bounces:CR = n√(vthreshold/vi)CR = 6√(0.001/10)= 0.215My rule with games is rigid formula, arbitrary numbers; so just tweak the values until it does what you want it to.;  My problem is that the velocity does not reduce, it will get to a certain threshold and about stay there. I would like to prevent a way of limiting the number of bounces and just do it "right".I am thinking maybe the way I do my vector reflection is wrong, can anyone verify that this is the proper equation?reflectedVelocity = v - ((1+cor) * n * (dot(i, n))?surfaceNormalized = Normalize(collisionNormal)iDotN = Dot(incomingVelocity, surfaceNormalized)reflectedVelocity = sphere.velocity - ((1.0f+sphere.cor) * surfaceNormalized * IDotN);   ;  I'm sure it was the first thing that everybody scrutinized. It is correct as long as your CoR is in [0,1]Feed me numbers: what is the initial velocity? what is the velocity when it collides? does it not slow down at all? you said a certain threshold; what threshold? what is your timestep?Are you handling the collision at the exact moment of intersection?   ;  You still haven't showed us a bit of code that does the following:sphere.velocity = reflectedVelocity;   