FIFTY LINETurn G-code
Online generatorOnline calculatorsReference

← All calculators

Sphere and segment calculator

From any two of radius, base diameter and height the calculator finds the third and gives you the points and the arc for the program. Covers a convex spherical end, a concave dish and a ball on a neck.

Quick answer

Sphere radius from base diameter D and height h: R = (a² + h²) / 2h, a = D/2. Example: D = 2″, h = 0.25″ → R = (1 + 0.0625) / 0.5 = 2.125″; D = 40 mm, h = 5 mm → R = 42.5 mm.

Shape
Known
Units

Result

Sphere radius R
—
Base diameter D
—
Height h
—
Sphere center
—
Segment angle (from the axis)
—

Contour (G7, zero at the face)

Points follow the part contour. Check the toolpath in a simulator before cutting.

Who needs it and why

Drawings often give a sphere not by its radius but by what is easy to measure: "a spherical end 3 mm high on a 20 mm diameter". The program needs the arc radius and its end points. Or the other way round: the radius is given and you need to know where the sphere meets the cylinder.

  • Spherical ends — shafts, pushrods, pins, pads: the radius from the dome height and diameter.
  • Dishes and concave spheres — for a ball seat, a center, a tip: the depth from the radius and diameter.
  • Balls on a neck — knobs, ball studs, handles: where the ball ends and the neck begins.
  • Checking a part — find the actual radius from a measured height and diameter.

The formulas

a = D / 2 is half the base diameter:

  • radius R = (a² + h²) / (2h)
  • height h = R − √(R² − a²)
  • base diameter D = 2 · √(h · (2R − h))
  • ball Ø 2R on a neck Ø d: length from tip to neck R + √(R² − (d/2)²)

The arc from the axis to the diameter for a convex shape, and from the diameter to the axis for a dish, is G3 (counterclockwise in the XZ plane). The Turn G-code Sphere cycle builds the toolpath along the arc — convex or concave, down to a pulley groove — and shows it in the 2D simulator.