Search code examples
collision-detectiongame-physics

Figuring out ellipsoid-ellipsoid collision detection


I've been working on collision detection code for a project, and I'm trying to figure out the method to use to detect collisions between objects. Since I use ellipsoids to test against level geometry, I'd like to use them for collisions between objects as well. The problem is figuring out exactly how. One method I've seen converts the ellipsoids to a sphere and an axis-aligned ellipsoid, which looks like a great solution, but the method involves finding eigenvectors and other advanced stuff that I don't really understand (yet) and would rather not have to implement.

It should be easy to convert the ellipsoids to a sphere and a skewed ellipsoid by applying a series of affine transformations. I've read that a skewed ellipse is still elliptical, so the skewing is equivalent to a rotation and a scaling, and I assume that the same principle applies to ellipsoids. However, I'm not sure how to determine the rotation and axis lengths of the new ellipse. If I knew that, it would be easy to make the ellipsoid axis-aligned. After that, I'm hoping to be able to perform a sweep test, but I'm not sure how efficiently it can be done, and I haven't figured out the equations to use yet, although I could likely figure those out with a little work.

I'm also considering working with other collision shapes if ellipsoids don't work out, but it would be really nice to be able to use the same shapes for object-world and object-object collisions.


Solution

  • You're right, it is complicated.

    There is a paper titled An Algebraic Approach to Continuous Collision Detection for Ellipsoids

    There is another paper here (archive) from this site that describes an algorithm mathematically.

    Matlab script Are Two Ellipsoids in Contact?, which references the aforementioned paper.