How to find the smallest sphere that intersects 3 given lines in 3D?

260 Views Asked by At

Given that all 3 lines are infinitely long, how do I find the smallest sphere that intersects (or touches) those 3 lines in 3D?

There is a simple case where the sphere can be calculated from just 2 lines and the third line can just pass through the sphere. You can ignore that case.

The case I want to solve here is when the distances from the sphere center to all 3 lines are equal (all the lines are tangent to the sphere surface). Trying to solve this case leads me to the path of solving quadratic equation systems and Lagrange multiplier which I cannot solve for an exact closed-form solution.

As I want this solution to be efficient, I try to avoid iterative methods/numerical optimizations.

1

There are 1 best solutions below

7
On

Let the three lines be given by parametric equations

$ R_i(t) = P_{i} + t V_{i} ,\hspace{20pt} i = 1, 2, 3 $

where the direction vectors $\{ V_i \}$ are assumed to be unit vectors.

Given the distance $d$ between the center of the sphere $C$ and each of these lines ($d$ is the radius of the sphere), we can write three equations in the vector $C$:

$(C - P_{i} )^T (I_3 - {V_i V_i}^T ) (C - P_{i} ) = d^2, \hspace{20pt} i = 1, 2, 3 $

The above equation(s) are three equations of 3 cylinders (which are quadrics) having axes pointing along $\{V_i \}$ and passing through $\{ P_i \}$ respectively.

I don't know if an analytic solution exists for $C$ given $d$, but what I did was vary $d$ (in a descending variation) and compute $C$ numerically until no solution was possible. This way I was able to determine the minimum $d$ possible which is the radius of the smallest sphere.