So i have a problem similar to the cannonball problem. I have a couple of spheres with the same radius, lets say for example 5, and i have to arrange them to a pyramid with 4 of them at the bottom layer and the last one on top between the 4 at the bottom. I have to calculate the position of the last one i.e. the altitude. The problem: the 4 spheres at the bottom layer do not have to be touching, all of them may have equal space between them.
So lets assume the pyramid would look something like this
o - o
| x |
o - o
with o being the bottom spheres, x being the top sphere resting on the other 4 and all spaces represented by - and | being equal in length.
How do i calculate the altitude of the top shere?
Without loss of generality set the common sphere radius at $\frac12$ and the separation between adjacent sphere centres at the base at $d\ge1$. There is then a right-angled triangle between the (centre of the) top sphere, any base sphere and the pyramid's centre (the last being the right angle); letting the height difference between the first two entites be $h$, the Pythagorean theorem gives $$\frac12d^2+h^2=1\implies h=\sqrt{1-d^2/2}$$ Adding the height of the base above the ground gives the final answer as $\sqrt{1-d^2/2}+\frac12$.