The Maths behind Spherical Voxel Planets

Have you ever wondered about the maths required to produce a spherical voxel planet? For the last week, I have been working on two YouTube videos on the (im)possibility of making the Minetest world look and behave this way. The maths behind this turned out to be a bit more challening than I anticipated.