# numerical inaccuracy ellipsoid-ellipsoid collision

I am trying to implement ellipsoid-ellipsoid collision in my C++ code. Briefly this task can described as next: Let's assume that we have two arbitrarily oriented ellipses in the in space and this ellipses are intersected. This ellipses initially located in the center of coordinate system. We need to find how far we need to move one ellips relative to the other along the line joining their centres until the would not be intersected more. It is quite simple mathematical task. I use next equations:

1)ellipsoid equation in matrix form $$\vec{x}^TA1\vec{x}-1 = 0$$ $$(\vec{x}-d\vec{n})^TA2(\vec{x}-d\vec{n})-1 = 0$$ 2)equality of normals $$A1\vec{x} = \lambda A2(\vec{x}-d\vec{n})$$ Where $$\vec{n}$$ is the unit vector in the direction from one center to another. I am looking for variable $$d$$ from this system.

I have found this system and its solution on the last page of this article http://www.matthiasmueller.info/publications/orientedparticles.pdf It seems like everything is fine, this algorithm works well for most cases, however I have noticed, that for some ellipses there is an error occurs (I mean that this algorithm gives not exact result). I also have noticed, that error occurs primarily when the ratio between the ellipse radii more than 2. In order to solve this problem I have changed all variables in my code from float to double, but it did not give any result. It seems like small error in input data results in very big error in output data. Does anybody know how I can overcome this kind of instability?

• This isn't a solution, but the intersection of two quadric surfaces (which includes ellipses) results in another quadric surface and has a closed form expression. You should be able to find the intersection that results in a point. Neverthess, this solution on a sister site has a bunch of links to papers that may provide you with another path. – Damien Oct 9 '13 at 9:25