2

I have three 3D points p1, p2 and p3 and the sphere radius. How do I find the sphere center from 3 points and radius?

I expect two 3D points as solution because there are 2 spheres that meet the requirements.

Thanks.

2 Answers 2

8
  1. Find the plane P containing all three points. In that plane these points determine a triangle.

  2. Find the circle around this triangle. Let C denote the center of this circle.

  3. Find the line perpendicular to P and crossing it at C.

  4. On this line, find those 2 points with the desired distance from the circle.

I have ignored degenerate cases.

2

There are a number of ways to formalize this. Here's one of them (basically the same as Ali suggested, but with more math): you want to find points

(a) equidistant from p1, p2, p3, with

(b) the distance being exactly R.

First off, find a center of the circumscribed circle as per http://en.wikipedia.org/wiki/Circumscribed_circle (see the part about "the circumcircle of a triangle embedded in d dimensions"):

p0 = cross(
    dot(p21, p21) * p31 - dot(p31, p31) * p21,
    n
) / 2 / dot(n, n) + p1,

with p21=p2-p1, p31=p3-p1, n=cross(p21,p31).

The points from item (a) lie on a line that passes through this point, and is orthogonal to the plane containing p1, p2, p3, so its equation is

p(t) = p0 + n * t

Substitute this into

dist(p1, p)^2 = dot(p - p1, p - p1) = R^2

to get the quadratic equation

dot(n, n) * t^2 - 2*dot(n, p0-p1) * t + dot(p0-p1, p0-p1) = R^2

Actually, n and (p0-p1) are orthogonal, so the second addend on the left is 0, and

t1 = sqrt((R^2 - dot(p0-p1, p0-p1))/ dot(n, n)),
t2 = -sqrt((R^2 - dot(p0-p1, p0-p1))/ dot(n, n))

(note how p1 in p0 cancels out). Substitute these into p(t) to get the answer.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.