Sphere and Line Intersection Calculator

Sphere & Line Calculator

Enter sphere center (h, k, l) and radius r · line defined by point (x₀, y₀, z₀) and direction (a, b, c).
All numbers accept decimals (use dot or comma).
Sphere (x – h)² + (y – k)² + (z – l)² = r²
📏 Line (x, y, z) = (x₀, y₀, z₀) + t · (a, b, c)

✔ decimal values allowed (e.g. 1.5, -0.75, 3.0)

intersection point(s)

method & derivation

Sphere equation (center \((h,k,l)\), radius \(r\)):

\[(x - h)^2 + (y - k)^2 + (z - l)^2 = r^2\]

Line parametric form (point \((x_0,y_0,z_0)\), direction \((a,b,c)\)):

\[x = x_0 + a t,\quad y = y_0 + b t,\quad z = z_0 + c t\]

Substitution yields a quadratic in \(t\):

\[(x_0 + a t - h)^2 + (y_0 + b t - k)^2 + (z_0 + c t - l)^2 = r^2\]

After expansion:

\[ \underbrace{(a^2+b^2+c^2)}_{A}\;t^2 \;+\; \underbrace{2\big[a(x_0-h)+b(y_0-k)+c(z_0-l)\big]}_{B}t \;+\; \underbrace{(x_0-h)^2+(y_0-k)^2+(z_0-l)^2 - r^2}_{C} = 0 \]

Discriminant \(\Delta = B^2 - 4AC\) determines the type of intersection:

  • \(\Delta > 0\) : two distinct points (secant)
  • \(\Delta = 0\) : one point (tangent)
  • \(\Delta < 0\) : no real intersection (line misses the sphere)

Then \(t = \frac{-B \pm \sqrt{\Delta}}{2A}\) and plug back into line equations.