Collision response.

Started by
4 comments, last by SporadicFire 19 years, 10 months ago
I have been working on some particle/spring based simulation, and its been going quite well. I have most of the forces working, and they are all treated the same way. The only problem is collision response. I know how to do it, but the method involves modification of velocity directly, rather than through a force. Is there a physics-like way to do collision response by coming up with a force that will generate the correct results. SporadicFire
Advertisement
Yeah, I don''t like to change velocity directly either. It seems like a bad habit to adopt, it could make your code behaviour wierd if you start using it all over the place. I''ve been trying to calculate the force using the current frame time so that the calculated force changes the velocity for just the right amount it needs to be changed. I haven''t fully implemented my collisions but its working alright even though I''d still prefer an even cleaner approach.
quote:Original post by SporadicFire
I have been working on some particle/spring based simulation, and its been
going quite well. I have most of the forces working, and they
are all treated the same way. The only problem is collision
response. I know how to do it, but the method involves modification of velocity directly, rather than through a force. Is there a physics-like way to do collision
response by coming up with a force that will generate the
correct results.

SporadicFire


While I haven''t written this code myself, a friend wrote a very similar simulation, and the physically correct solution involves rigid-body dynamics. Basically what you have to do is solve for the force that the collision plane (floor, ceiling, wall, whatever, assuming that you''re talking about an environmental collision, as opposed to an inter-object collision) would need to exert to prevent the dynamic object from moving through the collision plane.

This turns the problem on its head a bit, since for the dynamic objects in the scene you''re used to accumulating forces and solving for velocity and/or position. In this case, you have position and velocity and you need to solve for force.

I''m sorry that I don''t have any more specifics for you, but hopefully this will point you in a good direction.
Thanks Clu and AP, you both have some good ideas

Yes, I am indeed talking about environmental collision. Specifically, collision between point mass particles
and a flat surface.

quote:
While I haven''t written this code myself, a friend wrote a very similar simulation,
and the physically correct solution involves rigid-body dynamics. Basically what you
have to do is solve for the force that the collision plane (floor, ceiling, wall,
whatever, assuming that you''re talking about an environmental collision, as opposed
to an inter-object collision) would need to exert to prevent the dynamic object from
moving through the collision plane.



I sort of understand what with force would be. It would be
force that that brings the velocity of the particle along the normal to 0 (or negate its direction if you want bounce)
before it hits the object. But, to compute this force, you''d
have to predict that a collision is about to happen (which
is probably not that hard). And, to add the bounce, I guess
the force would have to be along the reflective vector of the
velocity of the incoming particle. In absense of bounce, this would make the velocity
along the normal zero when the particle gets there and then
the particle would simply slide.

Actually, spring forces are already based on position and
velocity, so this isnt such a bad idea. I''ll try to implement
this and see what happens.

SporadicFire
Here is the formula I use to do collision in my flight simulator program (treating the camera as a point-object):

vVector = pPoly.Normal*g_FrameInterval*(Magnitude(m_Velocity) / (4.0 * MaxVelocity)) + vVector;

I then normalize the vector. (pPoly.Normal and vVector are both prenormalized). You might find it useful, because it gradually pushes the object away over several frames.

If you want the collision response to happen instantaneously don't use this way, but rather just vVector = pPoly.Normal + vVector and then normalize, vVector being the movement vector of the object.

Edit: I might need to note that the final result of both of the equations I give there is merely movement parallel to the polygon, so multiply the normal by 2 to push it off and away at a congruent angle to its incoming trajectory.

[edited by - uber_n00b on May 28, 2004 9:39:07 PM]
My fellow Americans I have just signed legislation that outlaws Russia forever. Bombing will commence in five minutes.
http://www.d6.com/users/checker/dynamics.htm

http://www.cs.unc.edu/~ehmann/RigidTutorial/

http://www.euclideanspace.com/physics/dynamics/collision/steve.htm

and a little demo
http://uk.geocities.com/olivier_rebellion/, "Cube bouncingon plane"

to simplify it and avoid rotations, you can set the inverse inertia matrix to be 0 in the impulse calculations, that will give you the impact force.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement