Re: [Algorithms] collision with spheres
Brought to you by:
vexxed72
From: Eric Y. <er...@od...> - 2001-05-31 20:42:10
|
tSG, I'm sorry if this is off-topic, I think I'm coming into the thread late. 8-) One problem is that when a box and sphere intersect, you get a volume instead of just a collision "point". The impulse-based simulators try to turn this into a point by subdividing time to find when the two objects first come in contact (within a small epsilon "layer" around the object). Or, the other way to do this is to try to backsolve the translations/rotations to calculate the time at which they collided at a point, and then solve for the point. I would think the strategy would be to disqualify as many collisions as possible, so put spheres around the boxes, and do sphere-sphere tests first. Then, if they collide, use the faces of the boxes as planes, and see if the sphere falls completely on one side of the planes. You can plug the sphere's point into the implicit plane equations and the distance just pops out, which you compare against the radius. If all this says you still have a collision, then you have to do the "expensive math", and hopefully you can make a simplifying assumption. If the spheres are the "movers" then maybe you can use the sphere-plane results from above and see if the intersection happened on the face, or on the edge. If it happened on the face, you can use the face normal as the collision normal; if it happened on the edge, use an edge normal, etc. - Eric tSG wrote: > > As a matter of fact, the sphere-sphere collision problem is much > > easier than the box-sphere collision problem. Moreover, it is an > > utterly trivial computational geometry problem; hard to think of one > > that would be simpler. > > True :) Anyway how would you solve the box-sphere collision problem? > Are there any methods that computes it easily and fastly? I found just one > solution: > compute the distance for all the faces (or for all the edges, depends on > the position of the sphere and the box) of the box and the sphere... > But this doesn't result a too nice code, and maybe it is slow. I haven't > tried it > out yet. Should I? :) > > Cheers > tSG > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/lists/listinfo/gdalgorithms-list |