Department of Energy Argonne National Laboratory Office of Science NEWTON's Homepage NEWTON's Homepage
NEWTON, Ask A Scientist!
NEWTON Home Page NEWTON Teachers Visit Our Archives Ask A Question How To Ask A Question Question of the Week Our Expert Scientists Volunteer at NEWTON! Frequently Asked Questions Referencing NEWTON About NEWTON About Ask A Scientist Education At Argonne Shortest Distance on Sphere Formula
Name: Paul
Status: student	
Age:  N/A
Location: N/A
Country: N/A
Date: N/A


Question:
I am trying to determine the shortest distance between a point and the surface of a sphere. The only way I have to do it now is a brute force method where I find the distance between the point and a ton of actual points on the surface of the sphere, then take the minimum of these. However, I would much rather have some equations that I could use.

If I have a point, (X,Y,Z), and a sphere, x^2+y^2+z^2 = R^2 (or similarly (x-a)^2+(y-b)^2+(z-c)^2 = R^2) ... is there a formula for the distance between the two? Ideally, I would like to be able to find this distance given the point, (X,Y,Z), the sphere radius, R, and the sphere center, (a,b,c). So I would end up with a function: D = f(X,Y,Z,a,b,c,R)



Replies:
I do not know about a formula, but here is an algorithm: Draw a line through the center of the sphere and the point (X,Y,Z). This line will intersect the surface of the sphere at the point closest to the point (X,Y,Z).

Tim Mooney
Beamline Controls & Data Acquisition Group
Advanced Photon Source, Argonne National Lab.


Hmmm... interesting question.

My guess would be to find the minimum distance between the center of the sphere and the point (call that D1) and then the minimum distance between the surface of the sphere and the point would just be D1 - R, where R is the radius of the sphere.

D1 is fairly easy to find (the minimum distance between two points in space). See http://en.wikipedia.org/wiki/Euclidean_distance for the equation.

I hope that helps!

Regards,

Todd Clark, Office of Science
US Department of Energy


Hello Paul,

Here is a pretty good way to do it. First let me restate the question so we're certain I understand what you are asking. "Given a sphere in space and a point outside the sphere, what is the shortest distance between the point and the surface of the sphere."

We can make the problem much easier to solve by putting the center of the sphere at the origin. The point will be at some coordinates in space, (X,Y,Z). Thus the distance from that point to the origin is

distance = the_square_root_of (X^2 + Y^2 + Z^2) = (X^2 + Y^2 + Z^2)^(1/2)

Now, if the sphere is centered at the origin, then the distance from the origin to any point on the surface is just the radius of the sphere R. Thus, let us look at the line connecting the point in space to the origin. That line passes through the surface of the sphere, and is perpendicular to the surface. Since the distance from the origin to the surface is just the radius R, then the distance between the point in space and the surface is :

distance_point_to_sphere = (X^2 + Y^2 + Z^2)^(1/2) - R

To extend this to a sphere at arbitrary positions in space is pretty straight forward too.

First, think of two points out in space, one at (X,Y,Z) and the other at (a,b,c). What is the distance between these two points?

distance_between_two_points = ( (X-a)^2 + (Y-b)^2 + (Z-c)^2 ) ^ (1/2)

now, if the center of the second point (a,b,c) is the center of the sphere, then the distance along the line connecting the two points is just the radius of the sphere R. so the distance between point (X,Y,Z) and the surface is

distance_point_to_sphere = ( (X-a)^2 + (Y-b)^2 + (Z-c)^2 ) ^ (1/2) - R

Michael S. Pierce
Materials Science Division
Argonne National Laboratory



Click here to return to the Mathematics Archives

NEWTON is an electronic community for Science, Math, and Computer Science K-12 Educators, sponsored and operated by Argonne National Laboratory's Educational Programs, Andrew Skipor, Ph.D., Head of Educational Programs.

For assistance with NEWTON contact a System Operator (help@newton.dep.anl.gov), or at Argonne's Educational Programs

NEWTON AND ASK A SCIENTIST
Educational Programs
Building 360
9700 S. Cass Ave.
Argonne, Illinois
60439-4845, USA
Update: June 2012
Weclome To Newton

Argonne National Laboratory