# What different ways are there to model restitution in a physics engine?

In my physics engine I give a body a value for restitution between 0 and 1. When two bodies collide there seems to be different views on how the restitution of the collision should be calculated. To me the most intuitive seems to be to take the average of the two but some seem to take only the largest one.

Are there other ways to do it? Also, could the closing velocity or some other parameter come into effect?

-

Also, could the closing velocity or some other parameter come into effect?

According to Wikipedia,

in a series of experiments performed at Florida State University in 1955, it was shown that the COR varies as the collision speed approaches zero, first rising significantly as the speed drops, then dropping significantly as the speed drops to about 1 cm/s and again as the collision speed approaches zero.

To answer the main question, Cholesky's suggestion of a table is a good one, but if you want to reduce the number of cases you have to select values for then one approach would be to store for each material a base restitution and a weight with which to take a weighted average. What restitution is really about is how much of the energy of the collision is converted into forms other than the post-collision kinetic energy of the bodies. Sound can be neglected: what you're interested in is deformation. So give easily deformed materials such as soft sand a high weight and a low restitution and you have a model which should be good enough.

After all, games only have to feel right to the player: they don't have to be accurate simulations of the real world.

-
Citing an over 50-year old article, nice! :) I think we are getting somewhere now, so the weight you are talking about could probably be determined by the materials' "hardness" then? Sand would have high weight being soft and a brick wall having a low weight being hard? – Mikael Högström Nov 17 '12 at 13:11
@MikaelHögström, it's about hardness in the sense of elasticity vs plasticity. I suppose that if you really want to simulate rather than approximate you could calculate forces and use tables of yield strength... PS I've e-mailed the author of that thesis to notify him of the broken links. – Peter Taylor Nov 17 '12 at 13:27
So what about the brick wall? It isn't very elastic but still a rubber ball will bounce off it whith a high COR. It's not so much that I want a perfect simulation, rather something very simple to maintain. When I add a new material in an xml-file it's nice if I can just give it some values (like restitution, elasticity, hardness etc) and have everything "just work" rather than a table where all materials will need to have entries changed if another one is added. Very good answer though, I'll probably go with something like this! – Mikael Högström Nov 17 '12 at 15:04
@MikaelHögström, a brick wall is fairly elastic relative to sand. Unless you're thinking about forces on the order of driving a car into it, you can probably assume it won't take damage. – Peter Taylor Nov 17 '12 at 16:22
Good point :) I ended up going with a solution based on this, thanks a lot for your help! – Mikael Högström Nov 19 '12 at 22:03

I personally think that taking the largest one make the most sense: (throwing a bouncy ball at a brick bounces even though a brick has no restitution to speak of), but if you have a game where you need to model complex bouncy interactions you could store a "material" per body and build up a materialA vs. materialB lookup table.

-
Hmm yeah I guess in that case it makes sense... It raises some problems though, a ball which is very bouncy will bounce exactly the same whether it bounces on a brick wall or on, say, soft sand. Table version seems like a possible solution I guess... – Mikael Högström Nov 16 '12 at 23:02

BulletPhysics seems to just multiply the restitution factors. This might not be a universal solution, but it satisfies the "everything just works" approach when adding new materials.

-
Seems a bit weird to me but thanks for the info! I guess you would have to set the restitution factors a bit higher then – Mikael Högström Nov 20 '12 at 19:37

From a physics standpoint, the minimum restitution between two bodies should be used.

Think of gel hitting a rubber ball. The rubber ball has high restitution, but the gel has low. The rubber ball will not bounce off the gel. In the case of bounciness, lowest wins.

However, gel has low density, which allows the ball to penetrate it and hit something with higher restitution, such as the ground.

The gel will absorb some of the kinetic energy of the ball, how far the ball bounces, often considerably. But that's a bit off topic.

Restitution is a representation of loss of kinetic energy through collisions, so the lowest value is the most accurate. Throw a golf ball at a block of soft clay and you will see what I mean.

-