Originally Posted by

**SlipEternal** Take a cross section of the cone and sphere (through the center of the sphere). It will look like a circle inscribed in a triangle. We want to figure out the $z$ you mention. Drop a line segment from the top of the cone to the base of the cone that goes through the center of the sphere (this will be an angle bisector of the triangle that goes through the center of the circle and bisects the base of the triangle by symmetry). Now, you have two right triangles. You may want to draw it. The circle will touch the hypotenuse of this right triangle at a right angle. So, if you draw the radius to the point where the circle touches the triangle, you wind up with a similar triangle to the original right triangle. Let's label these points. At the top of the triangle, you have point A. At the base of the triangle, you have points B on the left and C and the right. The angle bisector we drew in bisects BC at point D. The center of the circle is point E. The circle touches the right side of the triangle at point F. Once you have all of this drawn, it should be apparent that:

$$\dfrac{EF}{AF} = \dfrac{DC}{AD}$$

Plugging in what you know:

$$\dfrac{a}{AF} = \dfrac{r}{2a+z}$$

Solving for $AF$ gives:

$$AF = \dfrac{a(2a+z)}{r}$$

Now, by the pythagorean theorem, we have:

$$(a+z)^2 = a^2+\left(\dfrac{a(2a+z)}{r}\right)^2$$

Solve for $z$.