The code above has an elasticity constant, but 1.0 is not the correct value for perfectly inelastic collsions. (Those where no energy is lost)
NFx# = -the_target_physics_data\elasticity# * coll_nx# * VdotN#
See that line? Well in a perfectly inelastic collision, that elasticity value there would be 2.0. So if you set it to 1.0, then you SHOULD be losing almost all your energy instantly, because that would mean a perfectly elastic collision.
This line SHOULD say:
NFx# = -(1.0 + the_target_physics_data\elasticity#) * coll_nx# * VdotN#
Then a value of 1.0 for elasticity will represent a bouncy ball and 0.0 will represent a pool ball.
Sort of.
Those physics don't take into account mass, or how much energy is transferred to the other object. So 1.0 means (I think it's called) an elastic collision where the ball KEEPS all of it's energy when it collides with the ground, and 0.0 represents an inelastic collision where the ball TRANSFERS all of it's energy to the other object when they collide.
Here's the kicker though. Because I'm not transferring energy, if you have anything other than an elasticity of 1.0, then each time energy should be transferred from one ball to another (or from a ball to the floor) the energy is simply "lost". And that violates the laws of physics. Of course, if the balls collided with the floor presumably it would have so much mass anyhow that if the balls were not completely inelastic (0.0) then when they hit the floor it would get the energy but only barely budge. But of course you don't even budge the floor you treat it like an object with infinite mass. Either way, an even slightly inelastic collision with the floor will cause the balls to eventually slow down because the floor will just store the energy if anything at all, and not give it back.
Imagine for example pool balls colliding with a wall in a space station. Most likely they'd hit the wall, and then stick there. The wall gets all the energy and doesn't give it back. The ship moves a tiny bit but that is imperceptible because the difference in mass is so great. Either way, if the collision is inelastic, then the balls come to a rest.
Now if two inelastic balls of the same SIZE hit eachother in space, well that's a different story. They'll "bounce" off one another. One will gain the velocity and direction which the other previously had. Like when you have those steel balls on string and you let two go at the same time, they both bounce back, over and over again. Or if you release three, then three pop out on the other side.
I'm not really sure though why three pop out on the other side, rather than just one moving at three times the speed. Hm... I suppose it may have something to do with harmonics or something of the metal. Or not. I'll have to ask a physicist. :-)
Oh and what Steve said also applies. Floating point numbers aren't perfectly accurate. Energy can be lost. You'd have to be really careful with your calculations to make sure that the velocity A plus the veloicity of B before the collision equals the velocity of A plus the velocity of B AFTER the collision. And even then you might not be safe.
NFx# = -the_target_physics_data\elasticity# * coll_nx# * VdotN#
See that line? Well in a perfectly inelastic collision, that elasticity value there would be 2.0. So if you set it to 1.0, then you SHOULD be losing almost all your energy instantly, because that would mean a perfectly elastic collision.
This line SHOULD say:
NFx# = -(1.0 + the_target_physics_data\elasticity#) * coll_nx# * VdotN#
Then a value of 1.0 for elasticity will represent a bouncy ball and 0.0 will represent a pool ball.
Sort of.
Those physics don't take into account mass, or how much energy is transferred to the other object. So 1.0 means (I think it's called) an elastic collision where the ball KEEPS all of it's energy when it collides with the ground, and 0.0 represents an inelastic collision where the ball TRANSFERS all of it's energy to the other object when they collide.
Here's the kicker though. Because I'm not transferring energy, if you have anything other than an elasticity of 1.0, then each time energy should be transferred from one ball to another (or from a ball to the floor) the energy is simply "lost". And that violates the laws of physics. Of course, if the balls collided with the floor presumably it would have so much mass anyhow that if the balls were not completely inelastic (0.0) then when they hit the floor it would get the energy but only barely budge. But of course you don't even budge the floor you treat it like an object with infinite mass. Either way, an even slightly inelastic collision with the floor will cause the balls to eventually slow down because the floor will just store the energy if anything at all, and not give it back.
Imagine for example pool balls colliding with a wall in a space station. Most likely they'd hit the wall, and then stick there. The wall gets all the energy and doesn't give it back. The ship moves a tiny bit but that is imperceptible because the difference in mass is so great. Either way, if the collision is inelastic, then the balls come to a rest.
Now if two inelastic balls of the same SIZE hit eachother in space, well that's a different story. They'll "bounce" off one another. One will gain the velocity and direction which the other previously had. Like when you have those steel balls on string and you let two go at the same time, they both bounce back, over and over again. Or if you release three, then three pop out on the other side.
I'm not really sure though why three pop out on the other side, rather than just one moving at three times the speed. Hm... I suppose it may have something to do with harmonics or something of the metal. Or not. I'll have to ask a physicist. :-)
Oh and what Steve said also applies. Floating point numbers aren't perfectly accurate. Energy can be lost. You'd have to be really careful with your calculations to make sure that the velocity A plus the veloicity of B before the collision equals the velocity of A plus the velocity of B AFTER the collision. And even then you might not be safe.