Sphere Sweep and Cuboid Sweep

Started by
3 comments, last by DrGUI 19 years, 2 months ago
Magic-software is down temporarily, so can someone tell me how to detect penetration between a sphere and a cuboid in its first position to its second including the volume it would have travelled, so that nothing is missed with a big time step or small objects. Thanks a lot.
Advertisement
Too bad the site is down! I certainly hope the new site retains all the content - that was a great resource.

By cuboid do you mean oriented bounding box? Or an arbitrary cuboid?

In any case, it's not entirely trivial and probably can't be communicated with all necessary details in a single post (at least not by me). But let's assume that you're working with an OBB. I would first subtract velocities so that the OBB can be considered stationary (vel = sphere.vel - box.vel, I believe). Then, transform the sphere position and (relative) velocity vector into the local space of the OBB so that it becomes an AABB.

An efficient implementation would probably next use Voronoi region information to find out a) what features of the box the sphere may be currently intersecting, and b) what features of the box the sphere might intersect in its motion.

Due to the axis-alignment, times and points of collision with the planes of the box faces can be done pretty easily. From there you can determine if a collision occurs within a box face.

If a collision with a plane occurs, but it is not within a face, the sphere could still collide with an edge or vertex. There are a number of ways to approach this problem, such as treating the sphere motion as a vector and the edges and corners as cylinders and spheres respectively, or sweeping directly against the edges and corners. The edge equations could probably be optimized for axis alignment.

At the end, don't forget to transform the collision point and normal back into world space.

Although it's on my list of things to do, I haven't implemented this yet, so the above is more or less an educated guess. Perhaps someone else will offer more specific advice, or a better algorithm.
Thanks!
I meant AAB, yes.
I also meant sphere-sphere and AAB-AAB, so those might be simpler?
Do you know how to find the collision tangent of two colliding spheres - something to do with the line of action?

www.magic-software.com has moved to www.geometrictools.com


Thanks again and ratings!

EDIT: the OOB information is still useful when I get some time to add support for OOBs - thnx
Quote:I also meant sphere-sphere and AAB-AAB, so those might be simpler?
Yes :-)

For AABB/AABB swept tests look for the article on gamasutra (linked from the articles section here) by Gomez. There's also an article called 'pool hall physics' or something like that which should cover sphere/sphere collision and response.

'Hope that helps.
Thanks - those look useful ;~}
I've read 'Pool Hall Lessons' before, but it seems to have been improved, thanks a lot!

This topic is closed to new replies.

Advertisement