### Distance in spherical coordinates

$s^2=(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2\\ =(R_2\sin\theta_2\cos\varphi_2-R_1\sin\theta_1\cos\varphi_1)^2 \\ + (R_2\sin\theta_2\sin\varphi_2-R_1\sin\theta_1\sin\varphi_1)^2 + (R_2\cos\theta_2-R_1\cos\theta_1)^2\\ = R_1^2+R_2^2 -2R_1R_2\cos\theta_1\cos\theta_2-2R_1 R_2 \sin\theta_1\sin\theta_2\cos(\varphi_2-\varphi_1)$