How do I find the intersection of a 3D line and a sphere?

62 Views Asked by At

I have a sphere with center $(0, 0, A)$ and radius $A$. I also have a point-vector equation for a line in 3D space:

$$ X = (x_0, y_0, z_0) + λ \begin{pmatrix}\begin{aligned} \frac{1}{2} ×& \frac{z_1 − z_0}{y_1 − y_0} + \frac{z_2 − z_0}{y_2 − y_0}, \\ \frac{\sqrt{3}}{2} ×& \frac{z_1 − z_0}{y_1 − y_0}, \\ \frac{\sqrt{3}}{2} ×& \frac{z_1 − z_0}{y_1 − y_0} × \frac{z_2 − z_0}{y_2 − y_0} \end{aligned}\end{pmatrix} $$

The point $(x_0, y_0, z_0)$ lies on the surface of the sphere, so it is one intersection point between the line and the sphere. I want to find the other intersection point between the line and the sphere. How do I do that?

1

There are 1 best solutions below

2
On BEST ANSWER

The equation of the sphere is

$ x^2 + y^2 + (z - A)^2 = A^2 $

if you let $ r = [x, y, z]^T $ and $r_1 = [0, 0, A]^T $, then in vector form, the equation is

$ (r - r_1) \cdot (r - r_1) = A^2 $

In addition to that, you have the line

$ L(\lambda) = L_0 + \lambda V $

where $L_0 = [x_0 , y_0 , z_0 ]^T $ , and $V $ is a known vector that depends on $ y_0, y_1, y_2 , z_0, z_1, z_2 $.

Plug in the equation of the line into the equation of the sphere

$ (L_0 + \lambda V - r_1) \cdot (L_0 + \lambda V - r_1) = A^2 $

And it is given that $L_0$ lies on the sphere, that is

$ (L_0 - r_1) \cdot (L_0 - r_1) = A^2 $

Then by expanding this expression, you get

$ (L_0 - r_1 ) \cdot (L_0 - r_1) + 2 \lambda \ V \cdot (L_0 - r_1) + \lambda^2 V \cdot V = A^2 $

Since $(L_0 - r_1) \cdot (L_0 - r_1) = A^2 $, then

$ 2 \lambda \ V \cdot (L_0 - r_1) + \lambda^2 V \cdot V = 0 $

Which has two solutions, $\lambda = 0 $ (and this corresponds to the point $L_0$) and

$ \lambda = - 2 \dfrac{ V \cdot (L_0 - r_1) }{V \cdot V} $

And this value corresponds to the second point of intersection.

Substitute this value into the equation of the line to get the coordinates of the second point of intersection.