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
Points on the plane may be described in one of two ways; both have benefits. An implicit equation for the plane is
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 (da, db, dc);
- if d < r, a circle of intersection, with center (da, db, dc) 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 (da, db, dc), and two independent vectors in the plane, v1 and v2.
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 (a, b, c) 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, (a, b, c). Either way, setting
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
This variation is convenient for analysis, but more expensive in applications.