# Plane–sphere intersection

The three possible plane-sphere intersections:
1. No intersection.
2. Point intersection.
3. Circle intersection.

In the theory of analytic geometry for real three-dimensional space, the intersection of a plane and a sphere can be the empty set, a point, or a circle. Distinguishing these cases, and determining equations for the point and circle in the latter cases have use, for example, when calculating ray intersections in ray tracing.

For convenience in analysis, choose a coordinate system that places the center of the sphere at the origin; this can be accomplished by a translation. Thus the implicit equation for the sphere with radius r becomes

$x^2 + y^2 + z^2 = r^2 . \,\!$

Points on the plane may be described in one of two ways; both have benefits. An implicit equation for the plane is

$a x + b y + c z = d . \,\!$

Scale the coefficients, if necessary, so that a2 + b2 + c2 is normalized to 1 and d is non-negative (which we can always do); then d gives the minimum distance from the plane to the origin. Thus we have

• if d > r, no intersection;
• if d = r, a single point of intersection, at (dadbdc);
• if d < r, a circle of intersection, with center (dadbdc) and squared radius r2 − d2.

A parametric equation for the plane yields the most convenient equation for the circle. (An implicit form requires two equations, so this does not reduce the dimensionality.) We write this in terms of a known point P of the plane, which we may take to be (dadbdc), and two independent vectors in the plane, v1 and v2.

$\mathrm{Point}(s,t) = P + s \bold{v}_1 + t \bold{v}_2 \,\!$

Among a, b, and c, suppose c has the largest magnitude. (This is a safety precaution.) Then we may take v1 to be (0, c, −b) and v2 to be (c, 0, −a), because the vector from the origin to (abc) is perpendicular to the plane. Although these vectors span the plane, we cannot expect them to have unit magnitude nor to be perpendicular to each other. To convert them to an orthonormal basis, we can use the Gram-Schmidt process. Easier still is to scale v1 to unit length (dividing by (1 − a2)1/2), then to generate v2 as the cross product of this and the plane normal, (abc). Either way, setting

$t = R \cos \theta, \qquad s = R \sin \theta, \,\!$

with

$R = \sqrt{r^2-d^2} , \,\!$

in the Point equation, we obtain a parametric equation for the circle in terms of θ. Alternatively, rotate the coordinate system so that the circle center lies on the z axis, at (0, 0, d), then write the circle as

$(R \cos \theta, R \sin \theta, d) . \,\!$

This variation is convenient for analysis, but more expensive in applications.