Consider a unit circle centered at $O = (0,0,0)$ with two points $A$ and $B$ on it. If the arc length between $A$ and $B$ is $\alpha$ (which is equal to the angle between $OA$ and $OB$), then the chord length $d$ satisfies
$$\frac{d}{2} = \sin\left(\frac{\alpha}{2}\right).$$
To find the surface distance between two points $A = (x_1, y_1, z_1)$ and $B = (x_2, y_2, z_2)$ on the unit sphere, note that the shortest path on the sphere between $A$ and $B$ is a great circle arc. By the previous observation, we find that the spherical distance is $$\alpha = 2\sin^{-1}\frac{d}{2} = 2\sin^{-1}\frac{\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2 + (z_1-z_2)^2}}{2}.$$
Generalizing this to spheres of radius $r$, we get
$$\alpha = 2r\sin^{-1}\frac{d}{2r} = 2r\sin^{-1}\frac{\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2 + (z_1-z_2)^2}}{2r}.$$
Alternatively, we can use the dot product of vectors, using the fact that for any two vectors $a$ and $b$ with an angle of $\gamma$, we have $a\cdot b = \|a\|\cdot\|b\|\cdot\cos\gamma$. If we let $a = A - O$ and $b = B - O$, we get two unit vectors with an angle of $\alpha$, so we get
$$\alpha = \cos^{-1}(a\cdot b) = \cos^{-1}(x_1x_2 + y_1y_2 + z_1z_2).$$
For arbitrary spheres of radius $r$ centered at $(x_0, y_0, z_0)$, we can reduce everything to the $r=1$ case by scaling and translating, and we get
$$\alpha = r\cos^{-1}\left(\frac{(x_1-x_0)(x_2-x_0)+(y_1-y_0)(y_2-y_0)+(z_1-z_0)(z_2-z_0)}{r^2}\right).$$