Ok a long hard battle with my very limited math knowledge I think I came to an approximate solution.
It is not at all mathematically perfect, meaning the cube will be slightly floating at times, and will appear to slide or drift slightly, but it is as far as I could go.
I would ask anyone with a better math knowledge to improve on this solution.
You will need to set up drivers for it's rotation in such way that say rotation along Y axis will equal pi*locationX

For the tricky part, the Z height will be driver by something like:
0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))
Where roty
is the rotation along the Y axis and sl
will be the length of the side of the cube.
If you want it to react to rotation in two axis jus add the equation above to itself
0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2)))) + (abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))

For my case with a 1 x 1
unit cube you would get
0.5+(abs(cos(2*roty-pi/2))*(sqrt(.25**2)))+(abs(cos(2*rotx-pi/2))*(sqrt(.25**2)))

z=sqrt(2 - (mod(x, 2) - 1) ^ 2)
. $\endgroup$