Sphere–Cylinder Intersections
A sphere and a cylinder are classic examples of implicit surfaces in 3D geometry.
A sphere with center \(C=(c_x,c_y,c_z)\) and radius \(R_s\) is described by
\((x-c_x)^2+(y-c_y)^2+(z-c_z)^2=R_s^2\).
An (infinite) cylinder is described as the set of points whose distance to a fixed axis line equals a constant radius \(R_c\).
The intersection between these two surfaces is not a filled region; it is typically a space curve—a closed loop (sometimes two loops) living on both surfaces simultaneously.
A helpful first question is whether an intersection exists at all.
Let the cylinder axis be the line \(A(t)=A_0+t\,\hat u\), where \(\hat u\) is a unit direction vector.
Compute the shortest distance \(d_0\) from the sphere center \(C\) to this axis line.
The cylinder surface consists of points at distance \(R_c\) from the axis, so the closest distance from \(C\) to the cylinder surface is
\(d_{\min}=|d_0-R_c|\).
If the sphere radius is too small to reach the cylinder surface, there is no intersection.
In practice, the existence test is:
intersection occurs when \(R_s \ge d_{\min}\).
Equality \(R_s=d_{\min}\) corresponds to a tangent (“just touching”) configuration.
There is an important special case: when the cylinder axis passes through the sphere’s center (\(d_0=0\)).
In coordinates aligned with the axis, the cylinder has equation \(x'^2+y'^2=R_c^2\) and the sphere is \(x'^2+y'^2+z'^2=R_s^2\).
Substituting gives \(z'^2=R_s^2-R_c^2\).
If \(R_s>R_c\), this produces two circles on planes perpendicular to the axis at
\(z'=\pm \sqrt{R_s^2-R_c^2}\).
If \(R_s=R_c\), the circles collapse to a single circle at \(z'=0\) (a limiting/tangent situation on the sphere).
If \(R_s
Outside the axis-through-center case, the intersection is generally not a planar conic.
A practical way to compute the curve is to parameterize the cylinder and enforce the sphere equation.
Choose an orthonormal basis \(\{e_1,e_2\}\) perpendicular to \(\hat u\).
Points on the cylinder can be written as
\(X(\theta,t)=A_0+t\hat u+R_c(\cos\theta\,e_1+\sin\theta\,e_2)\).
For each angle \(\theta\), substitute into the sphere constraint \(\|X(\theta,t)-C\|^2=R_s^2\).
Because \(t\) appears only along the axis direction, the result is a quadratic equation in \(t\).
Depending on the discriminant, each \(\theta\) yields 0, 1 (tangent), or 2 intersection points.
Sampling many \(\theta\) values produces a smooth numerical approximation to the intersection curve, which the 3D view renders as highlighted points/loops.
Geometrically, sphere–cylinder intersections appear in engineering and design: “a pipe through a ball,” dome penetrations, and machining toolpaths.
The key skills practiced here are translating geometry into equations, using distance-to-line formulas, recognizing special symmetric cases (circles),
and understanding that many real intersections are best handled with stable numerical sampling rather than forcing an over-complicated closed form.