The angle between two vectors in spherical coordinates is depicted in the diagram below:

We have

where and are the unit vectors of and , respectively.

Substituting eq182b (the unit vector in spherical coordinates) in eq33, noting that and rearranging gives