Inner Products – General Formula for Dot and Cross Products in Spherical Coordinates

cross productinner-productsspherical coordinates

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:
spherical coordinates

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} $

Best Answer

Here are two ways to derive the formula for the dot product. I assume that $v_1$ and $v_2$ are vectors with spherical coordinates $(r_1, \varphi_1, \theta_1)$ and $(r_2, \varphi_2, \theta_2)$.

First way: Let us convert these spherical coordinates to Cartesian ones. For the first point we get Cartesian coordinates $(x_1, y_1, z_1)$ like this: $$ \begin{array}{rcl} x_1 & = & r_1 \sin \varphi_1 \cos \theta_1, \\ y_1 & = & r_1 \sin \varphi_1 \sin \theta_1, \\ z_1 & = & r_1 \cos \varphi_1. \end{array} $$ Similar formulas hold for $(x_2, y_2, z_2)$. Now, the dot product is simply equal to $$ (v_1, v_2) = x_1 x_2 + y_1 y_2 + z_1 z_2 = \\ = r_1 r_2 ( \sin \varphi_1 \sin \varphi_2 ( \cos \theta_1 \cos \theta_2 + \sin \theta_1 \sin \theta_2) + \cos \varphi_1 \cos \varphi_2) = \\ = r_1 r_2 ( \sin \varphi_1 \sin \varphi_2 \cos (\theta_1 - \theta_2) + \cos \varphi_1 \cos \varphi_2) $$

Second way: Actually, we could have done it without coordinate conversions at all. Indeed, we know that $(v_1, v_2) = r_1 r_2 \cos \alpha$, where $\alpha$ is the angle between $v_1$ and $v_2$. But $\cos \alpha$ can be immediately found by the Spherical law of cosines, which yields exactly the same formula that we just proved. Basically, our first way is itself a proof for the spherical law of cosines.

PS: I'm not saying anything about cross products, but my guess is that the correct formula will look terrible. Not only will it contain sines and cosines, it is likely that it will also contain arc functions (they will appear when we try to convert the result back to spherical coordinates). Unless those arc functions magically cancel out with all the sines and cosines. But it is highly unlikely, and I don't feel like going through the trouble of checking.

PPS: One more thing. Cross products are not the only scary thing about spherical coordinates. If you think about it, even addition of two vectors is extremely unpleasant in spherical coordinates. Multiplication by a number is alright though, because it only changes $r$ and doesn't affect $\varphi$ and $\theta$ (at least when we multiply by a positive number).

Related Question