TITLE: What is the general formula for calculating dot and cross products in spherical coordinates?
QUESTION [19 upvotes]: I was writing a C++ class for working with 3D vectors. I have written operations in the Cartesian coordinates easily, but I'm stuck and very confused at spherical coordinates. I googled my question but couldn't find a direct formula for vector product in the search results.
Assume that I have $ \overrightarrow{V_1} $ and $ \overrightarrow{V_2} $ vectors in shperical coordinates:
$ \overrightarrow{V_1} = r_1\hat{u_r} + \theta_1\hat{u_\theta} + \phi_1\hat{u_\phi} \\
  \overrightarrow{V_2} = r_2\hat{u_r} + \theta_2\hat{u_\theta} + \phi_2\hat{u_\phi} \\
  \hat{u_r}: \mbox{the unit vector in the direction of radius} \\
  \hat{u_\theta}: \mbox{the unit vector in the direction of azimuthal angle} \\
  \hat{u_\phi}: \mbox{the unit vector in the direction of polar angle} $
$ \theta $ and $ \phi $ angles are as represented in the image below:

What is the general formula for taking dot and cross products of these vectors?
$ \overrightarrow{V_1} \bullet \overrightarrow{V_2} = ? \\
  \overrightarrow{V_1} \times  \overrightarrow{V_2} = ? $
If you need an example, please work on this one:
$ \overrightarrow{V_1} = 2\hat{u_r} + \frac{\pi}{3}\hat{u_\theta} + \frac{\pi}{4}\hat{u_\phi} \\
  \overrightarrow{V_2} = 3\hat{u_r} + \frac{\pi}{6}\hat{u_\theta} + \frac{\pi}{2}\hat{u_\phi} $

REPLY [3 votes]: EDIT: this answer is only defined if the two vectors are defined at the same point in space, because spherical polar unit vectors change with poisition.
So if you have one point ($r$,$\theta$,$\phi$) which has defined $\mathbf{\hat r}$, $\mathbf{\hat \theta}$ and $\mathbf{\hat \phi}$, and two vectors coming out of that point, then the dot product is: 
$$
\mathbf V \cdot \mathbf U =  V_rU_r + V_\phi U_\phi + V_\theta U_\theta
$$
For the cross product take the determinant of the matrix with unit vectors and components, the same way you would for cartesian coordinates:
$$
\mathbf V \times \mathbf U = \begin{vmatrix} \mathbf{\hat r}&\mathbf{\hat \phi}& \mathbf{\hat \theta}\\ V_r &V_\phi &V_\theta\\ U_r & U_\phi & U_\theta \end{vmatrix}
$$
For example 
$$\mathbf{\hat r} \times \mathbf{\hat \phi}  = \begin{vmatrix} \hat r &\hat \phi& \hat \theta\\ 1 &0 &0\\ 0 & 1 & 0 \end{vmatrix} = \hat \theta
$$