Sign in to follow this  

Sphere Sweep and Cuboid Sweep

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this