D1 and D2 are densities
$$D1 = \frac{3*mass}{4*pi*r^3} $$ $$D2 = \frac{3*mass}{pi(3rh^2-h^3)} $$
and then $$\frac{D2}{D1} = \frac{3rh^2-h^3}{4r^3}$$
I'm not sure how to isolate the R and H so when given the two densities I can just calculate the ratio of $$\frac{H}{R}$$ Not given the mass, only the two densities are given
Let $x = \frac{h}{r}$. Then
$$\frac{D2}{D1} = \frac{3rh^2-h^3}{4r^3}\\ \frac{4D2}{D1} = 3(\frac{h}{r})^2-(\frac{h}{r})^3\\ \frac{4D2}{D1} = 3x^2-x^3\\ x^3 - 3x^2 + \frac{4D2}{D1} = 0$$
Unfortunately cubics aren't as easily solved as quadratics, though they do have exact formulas you can use. With the help of Wolfram Alpha you get the following:
Let $t = \frac{D2}{D1}$. Calculate
$$z = \sqrt[3]{2 \sqrt{t^2 - t} - 2 t + 1}$$
and then
$$\frac{h}{r} = z + \frac{1}{z} + 1$$