Sphere–cylinder intersection
In the theory of analytic geometry for real three-dimensional space, the curve formed from the intersection between a sphere and a cylinder can be a circle, a point, the empty set, or a special type of curve. For the analysis of this situation, assume (without loss of generality) that the axis of the cylinder coincides with the z-axis; points on the cylinder (with radius ) satisfy

We also assume that the sphere, with radius  is centered at a point on the positive x-axis, at point . Its points satisfy

The intersection is the collection of points satisfying both equations. Trivial cases

Sphere lies entirely within cylinder 
If , the sphere lies entirely in the interior of the cylinder. The intersection is the empty set. Sphere touches cylinder in one point 
If the sphere is smaller than the cylinder () and , the sphere lies in the interior of
the cylinder except for one point. The intersection is the single point . Sphere centered on cylinder axis 
If the center of the sphere lies on the axis of the cylinder, . In that case, the intersection consists of
two circles of radius . These circles lie in the planes

If , the intersection is a single circle in the plane . Non-trivial cases 
Subtracting the two equations given above gives

Since  is a quadratic function of , the projection of the intersection onto the xz-plane is the section of an orthogonal parabola; it is only a section due to the fact that . The vertex of the parabola lies at point , where

Intersection consists of two closed curves 
If , the condition  cuts the parabola into two segments. In this case, the intersection of sphere and cylinder consists of two closed curves, which are mirror images of each other. Their projection in the xy-plane are circles of radius . Each part of the intersection can be parametrized by an angle :

The curves contain the following extreme points:

Intersection is a single closed curve 
If , the intersection of sphere and cylinder consists of a single closed curve. It can be described by the same parameter equation as in the previous section, but the angle 
must be restricted to , where . The curve contains the following extreme points:

Limiting case 

In the case , the cylinder and sphere are tangential to each other at point . The intersection resembles a figure eight: it is a closed curve which intersects itself. The above parametrization becomes

where  now goes through two full revolutions. In the special case , the intersection is known as Viviani's curve. Its parameter representation is

The volume of the intersection of the two bodies, sometimes called Viviani's volume, is

See also 
Viviani's curve

References

Analytic geometry
Spherical geometry
Spherical curves
Geometric intersection