How to compute the formula of common tangent plane of three spheres Now there are three spheres, $s_0(x_0,y_0,z_0,r_0), s_1(x_1,y_1,z_1,r_1), s_2(x_2,y_2,z_2,r_2)$. $(x_i,y_i,z_i)$ represents the center of the $i$th sphere,and $r_i$ is the radius. I want to calculate the formula of the common tangent planes of the three spheres. I don't know how. Please tell me the answers if you know. Thanks very much!
 A: See Solving a common tangent problem using matrices for the corresponding planar situation. I'll adapt one of my answers there to your 3d setup. I'll be a bit faster here than I was there, so if you feel lost, check out the 2d post first.
I'd do a bit of Lie sphere geometry. Encode a sphere as $(x,y,z,\pm r,x^2+y^2+z^2-r^2,1)^T$ or any multiple thereof. Notice how these are oriented spheres, and choosing the sign for each will lead to different solutions. (Flipping the signs of all the spheres doesn't change anything, though, so there are only $2^2=4$ sign combinations to consider, not $2^3=8$.) The point at infinity is $(0,0,0,0,1,0)^T$ and a “sphere” passing through that point will actually be a plane. Two spheres $a,b$ are in oriented contact if $a^T\cdot L\cdot b=0$ and a vector $a$ represents a sphere if it is not the null vector and $a^T\cdot L\cdot a=0$. The matrix $L$ used here has the form
$$L=\begin{pmatrix}-2&&&&&\\&-2&&&&\\&&-2&&&\\&&&2&&\\&&&&0&1\\&&&&1&0\end{pmatrix}$$
Note that other people do Lie geometry using different basis vectors, and different matrices for the bilinear form. Dividing the above matrix by $2$ is common, and choosing the basis in such a way that the matrix becomes diagonal with $\pm1$ along that diagonal is common, too. But I'll stick to what I described.
So now compute a matrix formed by $s_i^T\cdot L$ including the point at infinity as $s_3$:
$$M=\begin{pmatrix}
-2x_0 & -2y_0 & -2z_0 & \pm2r_0 & 1 & x_0^2+y_0^2+z_0^2-r_0^2 \\
-2x_1 & -2y_1 & -2z_1 & \pm2r_1 & 1 & x_1^2+y_1^2+z_1^2-r_1^2 \\
-2x_2 & -2y_2 & -2z_2 & \pm2r_2 & 1 & x_2^2+y_2^2+z_2^2-r_2^2 \\
0&0&0&0&0&1
\end{pmatrix}$$
Now you want a vector $v$ such that $M\cdot v=0$. The last row tells you immediately that the last coordinate of $v$ has to be zero. From the other rows you get an underdetermined set of equations for the other five elements of $v$. In general you will find a two-dimensional space of solutions here, or kernel of the matrix, if you prefer to think of it in these terms. Pick two vectors $v_1,v_2$ which are a basis of this kernel. Then find a solution to $(v_1+\lambda v_2)^T\cdot L\cdot (v_1+\lambda v_2)=0$. This is a quadratic equation in $\lambda$, so you will get two solutions here. (Actually one should also consider $\lambda=\infty$, so check whether $v_2^T\cdot L\cdot v_2=0$ is already a solution.) Combined with the four different choices of which spheres have same sign and which ones have different sign, you end up with up to $8$ common tangential planes.
But what does the vector actually encode? Suppose you have $v_1+\lambda v_2=(a,b,c,d,e,0)^T$. Then this encodes the plane $ax+by+cz=\frac12e$. The fourth coordinate isn't needed any more, it merely represents $d=\pm\sqrt{a^2+b^2+c^2}$, the oriented norm of the normal vector.
