Advertisement

resolving multiple collisions

Started by July 12, 2002 06:21 PM
6 comments, last by a2k 22 years, 7 months ago
all the articles i''ve read on rigid body collision detection deal with resolving points with respect to the center of mass of the rigid body, by inducing a linear and angular impulse force, thereby modifying the instantaneous velocity. now, with that, how would you solve multiple collisions? what i mean is this: if a block is approaching a wall, and the four points of the block simultaneously collide with the wall, each point will have its own collision response impulse? that doesn''t sound right, because then the response would be 4x that of the actual response. would you take the average of the four points? i''m not sure how to determine whether the points are colliding on the same wall, or different walls. another instance is if two adjacent walls with normals that differ in only, say, 5 degrees, and two verts of one side of a box hit one wall and the other two verts of the box side hit the other wall. this would also generate an incorrect impulse magnitude. any advice? a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
I haven''t even started my collision system, but here goes:
quote:

all the articles i''ve read on rigid body collision detection say:

1. resolving points with respect to the center of mass of the rigid body

2. induce a linear and angular impulse force, thereby modifying the instantaneous velocity.

now, with that, how would you solve multiple collisions? what I mean is this:

if a block is approaching a wall, and the four points of the block simultaneously collide with the wall, will each point have its own collision response impulse?

That doesn''t sound right, because then the response would be 4x that of the actual response. Would you take the average of the four points?
Well, you could scale back the impulse response to 1/nth the size of each impulse in the response. Say all 4 corners collided at the same time. Your list would contain all four corners'' impulses and your impulse count would be 4. 1/4 = .25 so you would multiply each impulse by .25 and add them together.

If you were using vectors, this would essentially scale the vectors to 1/4 their size (you shouldn''t normalize them first). Adding them together would give the resultant vector and impulse direction. The magnitude of the impulse would be the average in each direction added together.

The reason you average them together is because there is only one mass with one force being distributed through the collision. If one corner hits first, this method would generate force to deflect the onject with all of the impulse force.

quote:

i''m not sure how to determine whether the points are colliding on the same wall, or different walls. another instance is if two adjacent walls with normals that differ in only, say, 5 degrees, and two verts of one side of a box hit one wall and the other two verts of the box side hit the other wall. this would also generate an incorrect impulse magnitude.


No, this would simulate reality if you calculate the resultant impulses correctly.
quote:

any advice?
I picked up the latest issue of Game Developer (August) and it has an article entitled Outsourcing Reality: Integrating a Commercial Physics Engine by Matt MacLaurin. His article lightly convers the different kinds of forces you can use in a physics engine and the benefits and drawbacks of each.

www.gdmag.com

-James
Advertisement
quote:

Well, you could scale back the impulse response to 1/nth the size of each impulse in the response.



thanks, that''s what i was planning to do. but i would think it''s somewhat related to the next question...


i posted:

i''m not sure how to determine whether the points are colliding on the same wall, or different walls. another instance is if two adjacent walls with normals that differ in only, say, 5 degrees, and two verts of one side of a box hit one wall and the other two verts of the box side hit the other wall. this would also generate an incorrect impulse magnitude.

No, this would simulate reality if you calculate the resultant impulses correctly.

but the situation that i mean is, supposing the two walls didn''t even differ in normal direction (essentially the same wall, but different face). you would still get the same result as the first case where the impulse is multiplied than the actual collision. and if you make the normal differ in just a slight, say 1 - 5 degrees. it would still give the same multiplied impulse. wouldn''t this be incorrect? i realize, however, that the magnitudes of the impulse for walls that differ by slightly that much are required to prevent the penetration through the wall (especially if it''s a fully inelastic collision), so is it still correct to take the full magnitude of the impulse even if the normals differed by only a few degrees?


quote:

I picked up the latest issue of Game Developer (August) and it has an article entitled Outsourcing Reality: Integrating a Commercial Physics Engine by Matt MacLaurin. His article lightly convers the different kinds of forces you can use in a physics engine and the benefits and drawbacks of each.

www.gdmag.com

-James



thanks for the link, and the suggestions. i''ll look into it some more.

a2k

------------------General Equation, this is Private Function reporting for duty, sir!a2k
I thought that newtonian physics only held for collisions involving two bodies?
just what i thought i knew, thats all.

anyway, on realism you might like to consider this:
a cube travels towards a plane and hits it face on, it bounces straight back, because the moments applied to it by the collision all cancel each other out. true no? not realistic though is it, when was last time you dropped a dice and it bounced straight back up?

thats what my problem was when i threw together an RBD, i think i made time slightly furry, added a little randomness to it, so that one vertex hits before the others, then it rebounded back, spinning. lovely.

Fatray.


www.blitzbasic.com
(edit:not my website, just something i like. im not affiliated blah blah blah)



[edited by - Fatray on July 12, 2002 10:57:06 PM]
" The reason it's done that way? That's just the way algebra works. How else would you do it? " - AP
quote:
Original post by a2k
thanks, that''s what i was planning to do. but i would think it''s somewhat related to the next question...


i posted:

i''m not sure how to determine whether the points are colliding on the same wall, or different walls. another instance is if two adjacent walls with normals that differ in only, say, 5 degrees, and two verts of one side of a box hit one wall and the other two verts of the box side hit the other wall. this would also generate an incorrect impulse magnitude.


but the situation that i mean is, supposing the two walls didn''t even differ in normal direction (essentially the same wall, but different face). you would still get the same result as the first case where the impulse is multiplied than the actual collision. and if you make the normal differ in just a slight, say 1 - 5 degrees. it would still give the same multiplied impulse. wouldn''t this be incorrect? i realize, however, that the magnitudes of the impulse for walls that differ by slightly that much are required to prevent the penetration through the wall (especially if it''s a fully inelastic collision), so is it still correct to take the full magnitude of the impulse even if the normals differed by only a few degrees?

thanks for the link, and the suggestions. i''ll look into it some more.

a2k


I believe the impulse system would treat the collision as smacking flat into a wall that doesn''t really exist.

Inelastic? Right? So there is no deflection, simply an impluse to counter the collision and keep in on the right side of the wall.

It hits the first polygon with 2 corners and the 2nd polygon that is set inward 5 degrees with the other 2 corners. Theoretically, your impulse minutae would add up to a reflection off of a wall that doesn''t exist -- All four collision points connected to form a plane -- Theoretically. Try smashing a building block into a corner at an angle. You are pushing as hard as you can against the block, and it acts as if you have run into an imaginary wall (until you scratch the paint and your wife goes bannanas!).

Hope that helps.


-James
quote:

so that one vertex hits before the others, then it rebounded back, spinning



sorry, but that defeats the purpose of my trying to solve multiple collisions.


and james, um, i''m still not clear, but you''re helping me with every bit that you''re saying. lemme draw up a vector diagram, and explain what i mean. (i know you know that you think you know what i mean, but for the sake of clarity, let''s look at a picture.)

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Advertisement


okay, so these are the two cases that we're discussing. we want an inelastic collision. the right side is the vector diagram of the situation on the left. also, i translated the velocity vector at the center of mass to the point of contact to illustrate further.

in the top case, we both agree that by averaging the impulses of the collisions that occur on the same wall, we can obtain a reasonably believable resultant impulse, because in this case, we'd be doubling an impulse that should be calculated once.

now, for the bottom case, the resultant velocity vectors from both collision points sum up with the current velocity to give a resultant final velocity vector that actually suggests that the wall pushes the object away more than it should.

to prove this, we look at the next diagram to see it mathematically.



if the velocity vector at that instant is 1.0, the unit vector, we can calculate that if the normal was at a 15 degree angle, the resultant vector would be at an angle of 30 degrees (to make calculations easier). now the vertical component would then be calculated to be 0.866 (cos(30)) (we're not concerned about the horizontal component because it cancels out, as in the top case).

so, if we add the two vertical components of the two collision vectors, we get more than the 1.0 that was the initial velocity, therefore not "canceling" the initial velocity, but rather pushing the object away from the wall, which is not an inelastic collision.

am i wrong about this?

a2k

[edited by - a2k on July 13, 2002 2:38:57 AM]
------------------General Equation, this is Private Function reporting for duty, sir!a2k
You are absolutely right! I did some sketches and some hard math on paper and it turns out that the further inside the wall, the more elastic the collision doing it by averaging the impulses.

I also found that averaging them woulndn''t always free the object from the wall!

However, I did find a way that works everytime: Find the vertex with the greatest penetration of the wall and apply an impulse along the polygon''s normal of that magnitude.

Step 1:

Dot product suspected verticies that may have penetrated wall. If the result is less than zero, then the vertex is behind the wall.

Step 2:

Use the polygon''s normal in a set of parametric equations to figure out the time ''t'' it takes for each vertex to reach the closest point on the wall. The wall is a polygon whose plane equation should help in finding the time ''t''.

Normal = (Vx, Vy, Vz)
Closest point on plane = (x, y, z)
Vertex = (x1, y1, z1)

t = (x - x1)/Vx

Store time t and move on to next vertex. You would store the ''t'' values for every vertex/polygon pair. Testing the values as you go means you only ever have to store one value per polygon.

t_time = (t_time < new_time)? new_time : t_time;

After you get all of the t values you need, you use a parametric equation to move the main body in the direction of the normal for each polygon the object pierces. That should give you the point your body is moving to. Subtracting the points will give you an impulse vector of the correct magnitude.

You can do this one of 2 ways, wait till the end and add all of the impulse vectors (bad idea) or you can work on a per-polygon basis and move the object before checking for other collisions. This would encure a loop that would work until there are 0 collisions detected.

The good/bad thing about this is that it will produce a sliding effect: ie: Slide along wall while you walk and slide down hills. However, unless you provide some sort of friction impulse, you will slide down land at any angle until you reached a crevice.

-James

This topic is closed to new replies.

Advertisement