The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Equation of a Sphere

Date: 09/17/97 at 09:20:03
From: Matt Ream
Subject: Equation of a sphere given 3 points

I am helping write a geometry computer program and we are stuck.  
We are trying to find an equation or group of equations simplified 
that would solve for the center point and radius of a sphere given 
three points in 3D space. We have already tried using the equation 
of a sphere and substituting to isolate one variable, but the algebra 
is far too complex and tedious. How would you use the equation of a 
plane to solve the problem?

Thank you,

Date: 09/17/97 at 11:16:11
From: Doctor Rob
Subject: Re: Equation of a sphere given 3 points

Three points are not enough to determine a sphere, even if they are 
not colinear (lying on the same line).  You need four points, not 
coplanar (lying in the same plane) to uniquely determine a sphere.

Nevertheless, three noncolinear points do determine a family of 
spheres. The points determine a plane, and within that plane, they 
determine a circle whose center and radius can be determined, but 
which are really unnecessary to the calculation.  The line 
perpendicular to that plane at the center of the circle contains the 
centers of this family of spheres. For each point on the line, there 
is a sphere whose center is there, and which intersects the plane in 
the circle. Its radius is the distance from that center to each of 
the three original points.

Let the three points be P, Q, and R, whose x-, y- and z-coordinates 
are given.  The equation of a plane can be written in the form
A*x + B*y + C*z = D, with A^2 + B^2 + C^2 = 1.  You can substitute 
the coordinates of P, Q, and R into that equation to get three linear 
equations in the coefficients A, B, C, and D, which, together with 
the quadratic equation above, determine A, B, C, and D (up to sign, 
which is irrelevant).

Next you can find the equations of the lines PQ, PR, and QR, and find 
the perpendicular bisectors of those line segments. Their intersection 
is the line of centers of the sphere family.  The line connecting 
P(xP,yP,zP) to Q(xQ,yQ,zQ) is given by:

   (x-xP)/(xQ-xP) = (y-yP)/(yQ-yP) = (z-zP)/(zQ-zP),

provided none of the denominators is zero. (If one of the denominators
is zero, say xQ = xP, drop that part of the equation and replace it by 
the numerator set equal to zero, i.e. x - xP = 0.  If two of the 
denominators are zero, drop all of the above and replace it with the 
two numerators set equal to zero.)  In parametric form, with parameter 
t, in all cases, the line can take the form

   x = t*(xQ-xP) + xP,
   y = t*(yQ-yP) + yP,
   z = t*(zQ-zP) + zP.

The parameter value t = 0 corrsponds to P, and the parameter value 
t = 1 corresponds to Q.

The midpoint of PQ is ([xP+xQ]/2,[yP+yQ]/2,[zP+zQ]/2), correponding to
parameter value t = 1/2.  The equation of the perpendicular bisecting
plane of PQ is then

  (xQ-xP)*(x-[xP+xQ]/2) + (yQ-yP)*(y-[yP+yQ]/2) 
    + (zQ-zP)*(z-[zP+zQ]/2) = 0.

Create the equations of the perpendicular bisecting planes of PR 
and QR in an analogous fashion. Then solve the three equations 
simultaneously for x, y, and z. Actually this system of equations 
is redundant, since the three planes must share a common line, so 
any two of them will suffice.

The result of this solving will be the equation of a line, which can 
be put into the parametric form

   x = A*t + a,
   y = B*t + b,
   z = C*t + c.

If all of A, B, and C are nonzero, this can be written as
(x-a)/A = (y-b)/B = (z-c)/C = t, and if not, a related form results.  
This is the line which consists of the centers of the family of 

Then the equation of the sphere corresponding to parameter value t is

   (x - [A*t+a])^2 + (y - [B*t+b])^2 + (z - [C*t+c])^2 = 
               (xP - [A*t+a])^2 + (yP - [B*t+b])^2 + (zP - [C*t+c])^2.

The right-hand side is the square of the radius, and the center is
O(A*t+a, B*t+b, C*t+c).

Testing to see if the three points are colinear is a separate issue!

-Doctor Rob,  The Math Forum
 Check out our web site!   
Associated Topics:
College Higher-Dimensional Geometry

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.