Audited 05 Aug 2026·Last updated 28 Oct 2026·3 citations·Tier 2·0 uses

Sphere Equation Calculator

Write the standard equation of a sphere from its centre and radius, then find a point's signed distance from the surface: negative inside, positive outside.

Sphere Equation Calculator

Signed distance from sphere surface
0
The point's signed distance from the sphere's surface, in the units of the coordinates: negative inside, zero on the surface, positive outside.
Sphere equation
(x-1)^2 + (y-2)^2 + (z-3)^2 = 16

Background.

A sphere is every point that lies exactly the same distance from a centre. Write that sentence using Pythagoras's theorem in three dimensions and you get the equation (x − h)² + (y − k)² + (z − l)² = r², where (h, k, l) is the centre and r the radius. Substitute any point: if the left side equals r² the point is on the surface, if it is smaller the point is inside, and if it is larger the point is outside.

That test is the useful part. Here the centre-radius equation is written out for the sphere you describe, and a chosen point is then measured against its surface as a signed number: negative inside, zero on the surface, positive outside. The size of that number is a genuine distance in the units of your coordinates, the shortest gap between the point and the sphere, measured along the line through the centre.

It differs from simply substituting the point into the equation. For a sphere of radius 4 and a point 3.4641 units from the centre, the left side minus r² comes to −4, a quantity in squared units that grows with the size of the sphere. The signed distance is −0.5359, which says directly that the point sits just over half a unit inside.

Distance to the centre minus the radius is also the signed distance function that graphics programmers use to ray-march spheres, and the simplest collision test in a physics engine: two spheres touch when the gap between their centres equals the sum of their radii. In navigation, each range measured from a known point puts you somewhere on a sphere around it, and a position fix is where several such spheres meet.

Everything here is exact Euclidean geometry in x, y, z coordinates. Ellipsoids, and spheres fitted to scattered measurements, need other methods.

What is sphere equation calculator?

The standard equation of a sphere is (x − h)² + (y − k)² + (z − l)² = r². It says that the straight-line distance from any surface point (x, y, z) to the centre (h, k, l) equals the radius r. Expanding the squares gives the general form x² + y² + z² + Dx + Ey + Fz + G = 0, which hides the centre and radius until the squares are completed again. A point's signed distance from the sphere is its distance to the centre minus r.

How to use this calculator.

  1. Enter the centre in Center x, Center y and Center z, and the radius in Radius. If you only have the expanded equation, halve the x, y and z coefficients and change their signs to get the centre first.
  2. Enter the point you want to test in Point x, Point y and Point z, using the same units and axes as the centre.
  3. Read the signed distance. A negative value means the point is inside by that amount, a positive value means it is outside, and zero means it lies on the surface.
  4. Copy the equation shown with the result if you need the standard form. A negative centre coordinate appears with a plus sign, so a centre at x = −2 shows as (x+2)^2.

The formula.

(x-h)^2+(y-k)^2+(z-l)^2=r^2

The distance from the point (x, y, z) to the centre (h, k, l) is d = √((x − h)² + (y − k)² + (z − l)²), the three-dimensional form of Pythagoras's theorem, and the signed distance is d − r. Squaring both sides of d = r gives the standard equation, which is why the equation and the distance test describe the same surface; the right-hand side is shown as r², so a radius of 4 appears as 16. Because the result is d − r rather than d² − r², it is in the units of the coordinates and does not inflate for large spheres. The radius must be positive, since a radius of zero would describe a single point. The result reacts most to the coordinate in which the point is farthest from the centre, because each difference enters squared.

A worked example.

Example

The sphere has centre (1, 2, 3) and radius 4, so its equation is (x − 1)² + (y − 2)² + (z − 3)² = 16. The test point is (5, 2, 3). Its differences from the centre are 5 − 1 = 4, 2 − 2 = 0 and 3 − 3 = 0, so the squared distance is 4² + 0² + 0² = 16 and the distance is √16 = 4. Subtracting the radius, 4 − 4 = 0: the point lies exactly on the surface, at the tip of the radius that points along the x-axis. Move the point to (3, 4, 5) and every difference is 2, so d = √12 = 3.4641 and the signed distance is −0.5359, just inside the sphere. At (4, 6, 3) the differences are 3, 4 and 0, d = √25 = 5, and the point is 1 unit outside.

center Y2
center Z3
point X5
center X1
point Y2
point Z3
radius4

Frequently asked questions.

How do I get the centre and radius from x² + y² + z² − 2x − 4y − 6z − 2 = 0?
Complete the square in each variable. Halving and negating the coefficients −2, −4 and −6 gives the centre (1, 2, 3). Then r² = 1² + 2² + 3² − (−2) = 1 + 4 + 9 + 2 = 16, so the radius is 4, the same sphere as the worked example.
What does a negative signed distance tell me?
That the point is inside the sphere, and by how much: its magnitude is the distance to the nearest point on the surface. A point at the exact centre returns minus the radius, so for the radius-4 sphere the centre (1, 2, 3) gives −4.
How can I tell whether two spheres intersect?
Enter the first sphere and use the second sphere's centre as the point. The result is the gap between centres minus the first radius. If it is more than the second radius the spheres are apart, equal means they touch, and anything smaller means they overlap or one sits inside the other.
Can I use the page for a circle in a plane?
Yes. Give the centre and the point the same z value, for example 0. The z term then drops out and the result is the signed distance from a circle of the same radius drawn in that plane, which is the sphere's cross-section through its centre.
Can I treat the Earth as a sphere with this equation?
For rough work a sphere with the mean radius of about 6,371 km is common. The Earth is slightly flattened, though, with an equatorial radius near 6,378 km and a polar radius near 6,357 km, so surveying and GPS work use an ellipsoid, which this page does not model.

How this page was produced

Published by
Quanta Calculator
Primary sources
3 cited below
Method
(x-h)^2+(y-k)^2+(z-l)^2=r^2
Published
Last verified

Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 1560 calculators remain free
  • No billing is enabled
Coming soon