This topic is now archived and is closed to further replies.


Colliding Objects

Recommended Posts

Yaskil    122
Hi, I am trying simulate realistic behaviours of some objects. I can calculate the forces applied to object and behaviours of the object to that forces like friction, air resistance etc. But i am having trouble in calculating the new forces after 2 objects are collided. Lets assume that i am dropping a mass (i dont mean a rubber ball or stg. that can jump easily i mean stg big like a stone) in a specific distance. What happens when it hits the ground (lets ignore angular velocity . I know that it moves with acceleration of -9.8 m/s^2 downwards while dropping. When it hits the ground how can i calculate the forces applied to object and what are the forces in that time. Also what can be the reaction of the object in that time is there any idea?

Share this post

Link to post
Share on other sites
uutee    142
Hi Yaskil,

In interactive, computer graphics physics engines, collisions are usually not handled using forces.

This is because the collision process takes very little time (less than a split second), so you''d need to use extremely small time step to be able to handle collisions using forces.

Therefore, most physics engines make an assumption that the bodies are completely rigid (ie. non-deforming, a case which never truely exists in reality), and collisions between them are instantaneous (ie. they take no time).

In English this means that once two objects are detected to have collided (or are detected to be colliding shortly, depending on your collision detection algorithms), their velocities are changed instantly so that there will be no interpenetration.

- Mikko Kauppila

Share this post

Link to post
Share on other sites
Yaskil    122
yep i got it.

lets change my question a little bit. how can i calculate (or the physic engines are calculating) the new velocity of the objects after collision (specially collision with the ground).

Share this post

Link to post
Share on other sites
Atheist    150
The answer to your question lies in your view of realism. You said you can compute the air-resistance of an object. I strongly doubt that since really HEAVY computation is needed to get results that come close to reality (I think wanted to try a linear approach F~v but thats only a rough approximation).

Lets come to your falling stone. What actually happens is that the atoms of your stone start to feel the atoms of the ground. Again there is no way to compute this correctly. So I think you might to consider your ball and your floor as objects with a uniform density of mass to find your way back to classical mechanics.

What actually happenes depends on the properties of your stone and your floor. Generally you will lose some kinetic energy by deformations of either (or both). So try reducing the total kinetic energy E by a constant factor (depening only on material properties, not in E) and try to solve your equations (conservation of energy[<< apply change here] and momentum) with that.

forces don´t help you when assuming instantanious reactions. They will be infinite for them. The forces after two objects that don´t change mass or shape collided are the same as before (quite obvious, no?).

@angular momentum:
not considering that you will only get semi-realistic effects when the connecting line of your center of mass to the point where collisions occurs is perpendicular to the plane in which the collision occurs (so you are fine for colliding balls or balls hitting a floor with infinite mass but will get problems for a cube hitting the floor with one of it''s edges).

you cannot simulate realistic behaviour w/o some unrealistic approximations. The approximations to choose depend on you. I think you should be a bit more specific of what you want to do.

Share this post

Link to post
Share on other sites
Atheist    150
Since you possibly weren´t helped with my last post and since your 2nd question is a bit more specific i´ll try to give you a hint (but as mentioned above it´s just an approximation to what really happens - the approximation i´d choose):

how can i calculate the new velocity of the objects after collision with the ground?

first for simplicity let´s assume your ground stretches out in the x-y-plane, has an infinite mass and is at rest. Your object is an incompressible sphere with a spherical symmetric density of mass. The total mass is M. The speedvector will be called v = (vx, vy, vz).

The total kinetic energy E of your body is: 2E = m(vx²+vy²+vz²)

Now we split up E into E1 (perpendicular to plane) and E2 (parallel to plane) by 2E1 = m*vz², 2E2 = m(mx²+my²) so E = E1 + E2.

Now you define two values c1 and c2 that give the fraction of E1 and E2 being conservated in the hit (1 for a perfectly elastic one, less for others; you´ll have to tryout).
Hence you have the partial energies after the hit by E1' = c1*E1, E2' = E2*c2. You might want to have a cut, so that (Ei < Emin => Ei' = 0 or else your object will never stop to bounce).

hitting the floor vx will change its sign while vy and vy remain their signs. The magnitude of vz after the hit vz' will be abs(vz') = squareroot(2E1' / m). Same is true for vx' and vy' (note: Their relative magnitude remains the same; you need that as a boundary condition to solve the resulting equation).

The reason for the splitup E = E1+E2 is that imho vertical energy will decrease faster than horizontal energy (so c1
Hope that helped you!

[edited by - Atheist on July 7, 2003 12:08:57 PM]

Share this post

Link to post
Share on other sites
oliii    2196
a very very very simple way to alter the velocity is to use ''miroring'' effects, like a ray reflecting off a flat surface.

V'' = V - 2.0f * ((V * N) * N)

V : incident velocity
V'' : resulting veloctiy after impact
N : normal of collision

you can reduce the bounce by replacing "2.0f" with (1.0f + CoR), CoR being your coeficient of restitution, 0 <= CoR <= 1.

This is inaccurate, but in some situations, it''s adequate.

for two massive objects, that''s slightly more complicated...

And for impulse, forces....

look at the equation for calculating ''j'', mid-way through.

Share this post

Link to post
Share on other sites
Yaskil    122
In your replies i gathered the following headlines

- We should decrease the kinetic energy of the hitting object after the hit with an constant (1 for perfect hits less for others). This constant can vary on the properties of the rigid bodies.

- Kinetic energy can be calculated by 2E = m.v formula

- We should examine the kinetic energy two ways one perpendicular to surface, and other is parallel to surface. Two way because vertical kinetic energy will decrease faster then horizontal kinetic energy.

- On the moment of hit we should recalculate the energy of the object with formula E = E.Cr (Cr is decrease constant or coefficient restitution) so after finding new kinetic energy we can recalculate the speed by v = 2E/m

- Or we can use the ray reflecting technique which is calculated by V'' = V - ( 1.0 + Cr ) * ( ( V * N ) * N ) where 1.0f >= Cr >= 0

I will try both solutions. I realized the fact that the behaviours of the objects for physical reactions depends on the way that we look at realism. But how the games like n4speed achives that (when car hits a wall same problem occurs). Are those the ways that they are using? and one more question for

Atheist how can we calculate the direction of the object after collision.

Share this post

Link to post
Share on other sites
Atheist    150
still assuming you hit a floor of infinite mass that is at rest in the xy-plane with aspherical symmetric body you will have:

vz'' = -sqrt(E1''/E1)*vz = -sqrt(c1)*vz = -a1*vz, where a1=sqrt(c1)=const.
vy'' = a2*vy, where a2 = sqrt(c2)
vz'' = a2*vz

So this is exactly what oliii wrote (except he uses a2=1).

If you generalize that for hitting floors/walls that aren´t in the xy-plane you split up the velocity v in two vectors. One (vn) is perpendicular to the plane you hit. The other one (vp) is parallel to the plane. The plane might have a normal n with |n|=1 (well that´s usually assumed for normals anyways) pointing in the direction of your object.

vn = -(v * n)*n
vp = v - vn, since v = vn + vp by definition

now you inverse the part of your vector that is perpendicular to the plane and remove a fraction of its magnitude:
vn'' = -a1*vn = -a1*((-v*n)*n) = a1(v*n)*n.

The direction parallel to the plane remains the same except for you might want to slow it down a little:
vp'' = +a2*vp = a2*(v + (v*n)*n)

Now you have
v'' = vn'' + vp'' = ...
your velocity after the collision. (Hope there´s no stupid error in it, but I´m too lazy doublechecking it now).

As for car racing games: I´d bet they assume to be the wall to be static (plane with infinite mass) but they DO consider
a) angular momentum; when you hit a wall with an edge of your car (let´s say its a cube) you start rotating.
b) deformation of at least the car. When you hit a wall your car will take damage. The kinetic energy "lost" in the hit will do deformations on your car thus damaging it.

Share this post

Link to post
Share on other sites