I want to calculate the total electrostatic energy of the Cavendish Experiment (two concentric spheres of radii $R_{1,2}$ which are connected, outer one gets charged, then removed, then after removing the outer sphere and measuring the charge of the inner one, it's zero).
The formula for this is:
$E_{tot} = \frac{1}{2} \sum_{i,j = 1,2} E_{ij}$ with $E_{ij} = \frac{\sigma_i \sigma_j}{4 \pi \epsilon_0} \int_{S_i} d^2r \int_{S_j} d^2 r' \frac{1}{|\vec{r} - \vec{r}'|} e^{-\mu |\vec{r}-\vec{r}'|} $ where $S_{i,j}$ denotes integrating over the sphere i or j.
I have the sample solution for this exercise and they massively confuse me. They simply state:
"We calculate: $|\vec{r}-\vec{r}'| = \sqrt{r^2 + r'^2 - 2\vec{r}\cdot\vec{r}'} = \sqrt{R_i^2 + R_j^2 - 2R_i R_j cos \theta'}$" Now everything would be fine here if $cos \theta '$ would simply be the angle between $\vec{r}$ and $\vec{r}'$. But they actually go on calculating the integral then and use $\theta '$ as the same angle as the polar angle in the $r'$ spherical coordinatesystem. How is this true? This greatly simplifies the integral, such that we can immediately solve $\int_{S_i} d^2r$ to give $4 \pi R_i^2$ and with the substitution $x = cos \theta'$ the integral over sphere $j$ gets easy aswell.
But I can't make sense of why that formula is true. If I directly compute the scalar product of $\vec{r}'$ and $\vec{r}$ this gives me:
\begin{pmatrix} R_j sin(\theta') cos (\phi')\\ R_j sin (\theta') sin(\phi') \\ R_j cos(\phi') \end{pmatrix} scalar produced with \begin{pmatrix} R_i sin(\theta) cos (\phi)\\ R_i sin (\theta) sin(\phi) \\ R_i cos(\phi) \end{pmatrix} $= R_i R_j (sin(\theta') cos (\phi'))sin(\theta) cos (\phi) + sin (\theta') sin(\phi')sin (\theta) sin(\phi)+ cos(\phi')cos(\phi))$ This does never equal simply $R_i R_j cos \theta'$
Where did I go wrong here? I really hope someone can clear this up for me