# Conversion of cartesian position and velocity to spherical velocity

Let's say that there is a particle with Cartesian coordinates $$(x,y,z)=(1, 2, 3)$$ and Cartesian velocity $$(x', y', z')=(4, 5, 6)$$.

Converting the position to spherical coordinates is straightforward:

$$r = \sqrt{x^2+y^2+z^2}$$

$$\theta = \text{atan2}(y,x)$$

$$\phi = \text{arccos}(z/r)$$

However, velocity eludes me, despite having the equation written in front of me.

From that same reference, $$\vec{v} = \dot{r} \hat{e}_r + r\dot{\theta}\text{sin}(\phi)\hat{e}_{\theta} + r\dot{\phi}\hat{e}_{\phi}$$.

Hold on...what I want are $$\dot{r}$$, $$\dot{\theta}$$, and $$\dot{\phi}!$$

What would be the way to get the spherical velocity components in terms of Cartesian position and velocity?

• $\dot{r}, \dot{\theta}, \dot{\phi}$ are time derivatives of the new coordinates $(r,\theta, \phi)$. You can calculate the velocity in the new reference frame by writing: $$\vec{r} = l \hat{e}_r$$ and calculating the derivative with respect to time, noticing that both $l$ and $\hat{e}_r$ my vary in time. Commented Apr 24, 2020 at 21:02
• @Socrates What is the $l$?
– Dave
Commented Apr 24, 2020 at 21:08
• It is actually $r$, the distance from the origin, I can't edit it anymore. Commented Apr 24, 2020 at 21:09
• And $\hat{e}_r$ is the unit vector in the direction of increasing $r$, it can be calculated from this definition as follows: $\frac{ \partial \vec{r} }{ \partial r } / \left| \frac{\partial \vec{r}}{\partial r} \right|$ Commented Apr 24, 2020 at 21:12
• @Socrates Differentiate with respect to $r$?
– Dave
Commented Apr 24, 2020 at 21:16

In spherical coordinates the velocity is: $$\vec{v} = v_r \hat{e_r} + v_\phi \hat{e_\phi} + v_\theta \hat{e_\theta}$$ which is the same as you write above. Since the unit vectors are orthogonal, to get $$v_r$$, you take the scalar product $$\vec{v}\cdot \hat{e_r} = v_r$$

However, the velocity vector is the same vector wether you write it using the spherical coordinates or Cartesian coordinates. In the Cartesian coordinate system, the velocity is given by: $$\vec{v} = v_x \hat{e_x} + v_y \hat{e_y} +v_z \hat{e_z}$$

So you can use the equation above to calculate $$v_r$$ in terms of the components of the velocity in the Cartesian system

$$v_r = \vec{v}\cdot \hat{e_r} = v_x \hat{e_x}\cdot \hat{e_r} + v_y \hat{e_y}\cdot \hat{e_r} +v_z \hat{e_z}\cdot \hat{e_r}$$

To calculate the scalar products above, it is best to sketch the unit vectors of the spherical system against the basis of the Cartesian unit vectors. You will get, for instance $$\hat{e_r}\cdot\hat{e_x} = \sin\theta\cos\phi$$ and so on for each component.

Sketch method

In the way I wrote above, you could get $$\hat{e_r}\cdot\hat{e_x}$$ by a sketch with which you could identify the angles. For instance, take the radial unit vector $$\hat{e_r}$$- it is pointing in the direction of increasing coordinate $$r$$. Now, you can decompose this unit vector $$\hat{e_r}$$ into a part in the direction of $$\hat{e_z}$$, and a part which is spanned by $$\hat{e_x}$$ and $$\hat{e_y}$$.

I will write this formally as (keep in mind that we are working with vectors of unit lenght): $$\hat{e_r} = a_1 \hat{e_x} + a_2 \hat{e_y} + a_3 \hat{e_z}$$ To visualize, see the Wikipedia image for the spherical coordinate system

From this sketch, you can see that the length of $$\hat{e_r}$$ in the direction $$\hat{e_z}$$ is exactly $$\cos\theta$$, hence $$a_3 = \hat{e_z}\cdot \hat{e_r} = \cos\theta$$

Now that the $$z$$ component is sorted out, lets look at the rest. You can view the remaining part $$a_1 \hat{e_x} + a_2 \hat{e_y}$$ as the orthogonal projection of the vector $$\hat{e_r}$$ to the $$xy$$ plane. The length of this projection is $$\sin\theta$$, so to get the part in the direction of the $$x$$ axis multiply this length with $$\cos\phi$$.

Finally, you obtain $$a_1 = \hat{e_r}\cdot\hat{e_x} = \sin\theta\cos\phi$$

and similarly for the component in the $$x$$ direction $$a_2 = \hat{e_r}\cdot\hat{e_y} = \sin\theta\sin\phi$$

Jacobians

(If I understand OP's comment, the question is why can't we apply the Jacobian matrix to perform the coordinate transformation)

From here down, we use the Einstein convention where repeated indices are summed over. I recommend 1 as a good textbook for a better understanding.

In a more precise definition, a basis for vector fields are the partial derivatives along the coordinate chart axes, so in the Cartesian system we have: $$\hat{e_x} = \frac{\partial}{\partial x}$$ and a vector can be written out as $$V = V^i \frac{\partial}{\partial x^i} = V^1 \frac{\partial}{\partial x^1} + V^2 \frac{\partial}{\partial x^2} + V^3 \frac{\partial}{\partial x^3}$$ and the components $$V^1, V^2, V^3$$ are the same as in $$V = V^1\hat{e_x} + V^2\hat{e_y} + V^3\hat{e_z}$$

If we want to change the coordinates, we just use the chain rule:

$$$$V = V^i \frac{\partial}{\partial x^i} = V^i \frac{\partial y^j}{\partial x^i}\frac{\partial}{\partial y^j} \tag{*}\label{one}$$$$

So we just read off the components in the new coordinate system $$y$$ as $$V'^i = V^i \frac{\partial y^j}{\partial x^i}$$ and find inside the inverse of the Jacobian matrix.

However, this method works if in both cases the basis vectors are the partial derivatives against the coordinate variables. For instance, in the case of the polar coordinate system, this is not true, e.g.

$$\hat{e_\phi} \neq \frac{\partial}{\partial_\phi}$$ but $$\hat{e_\phi} = \frac{1}{r} \frac{\partial}{\partial_\phi}$$

so it is not correct to apply the inverse of the Jacobian matrix for calculating new vector components in such a basis (formally known as non-coordinate basis). (See excercise 2.1 in 1) It does not mean that the non-coordinate bases are not useful, only that linear relations such as \ref{one} are not applicable.

1 Bernard Schutz: Geometrical Methods of mathematical physics

• I'm mostly following this and can work out most of the rest of the calculations. When it comes time to take $\hat{e}_r \cdot \hat{e}_y$, is that $\sin\theta\sin\phi$ or $r\cos\theta\cos\phi$? Then I think I can go through the Jacobian and get my function of spherical velocities in terms of Cartesian position and velocity.
– Dave
Commented Apr 24, 2020 at 22:29
• They are all unit vectors, so $\hat{e_r}\cdot\hat{e_y}$ would be $\sin\theta \sin\phi$ Commented Apr 25, 2020 at 10:44
• I have been able to go through the calculation and get the full transformation. I remain confused, however, about why $\hat{e_r}\cdot \hat{e_{x}}=\sin\theta\cos\phi$ and the relationship to the Jacobian. Could you please elaborate on that?
– Dave
Commented Apr 26, 2020 at 2:50
• Thanks for the long edit. What I meant is why $\hat{e_r}\cdot\hat{e_x}=\sin\theta\cos\phi$ or in general why $\hat{e}_{spherical}\cdot\hat{e}_{Cartesian}=\frac{\partial Cartesian}{\partial spherical}$ (the elements of the Jacobian matrix)? I thought I got your explanation until you said that it doesn’t work for polar coordinates.
– Dave
Commented Apr 28, 2020 at 1:22
• The scalar products of the basis vectors in two systems are here not equal to the Jacobian matrix - en.wikipedia.org/wiki/… notice the factor of $r$ inside Commented Apr 28, 2020 at 14:36

You can backtrack from the required end result to arrive at the solution.

What you are looking for is to write the vector $$\vec{V}$$ in spherical coordinates as $$\vec{V} = V_r \hat{r} + V_{\theta} \hat{\theta} + V_{\phi} \hat{\phi}$$

You already have the same vector in the cartesian coordinates as $$\vec{V} = 3 \hat{i} + 4 \hat{j} + 5 \hat{k}$$

Now it is obvious that all you need is the formulas for converting $$\hat{i}, \hat{j}, \hat{k}$$ into $$\hat{r}, \hat{\theta}, \hat{\phi}$$. The set of formulas for this conversion is $$$$\begin{bmatrix} \hat{i} \\ \hat{j} \\ \hat{k} \end{bmatrix} = \begin{bmatrix} \sin\theta \cos\phi & \cos\theta \cos\phi & -\sin\phi \\ \sin\theta \sin\phi & \cos\theta \sin\phi & \cos\phi \\ \cos\theta & -\sin\theta & 0 \end{bmatrix} \begin{bmatrix} \hat{r} \\ \hat{\theta} \\ \hat{\phi} \end{bmatrix}$$$$

The derivation of these formulas are quite simple. It is just the Euler rotation matrix. At any given point, unit vectors $$\hat{r}, \hat{\theta}, \hat{\phi}$$ can be obtained by suitably rotating $$\hat{i}, \hat{j}, \hat{k}$$ unit vectors.

From this, we know that we need $$\theta$$ and $$\phi$$. They can be obtained by converting the position coordinates of the particle from the cartesian coordinates to spherical coordinates. Also note that r is really not needed. The unit vectors in spherical system depend only on $$\theta$$ and $$\phi$$.

$$r = \sqrt{x^2+y^2+z^2} = \sqrt{1^2 + 2^2 + 3^2} = 3.74$$ $$\theta = atan2(\sqrt{x^2+y^2}, z) = 36.7 \text{ degrees }$$ $$\phi = atan2(y, x) = 63.43 \text{ degrees }$$

Plugging these value in, we get our formula for $$\hat{i}, \hat{j}, \hat{k}$$

$$$$\begin{bmatrix} \hat{i} \\ \hat{j} \\ \hat{k} \end{bmatrix} = \begin{bmatrix} 0.26726 & 0.35857 & -0.89443 \\ 0.53452 & 0.71714 & 0.44721 \\ 0.80178 & -0.59761 & 0.00000 \end{bmatrix} \begin{bmatrix} \hat{r} \\ \hat{\theta} \\ \hat{\phi} \end{bmatrix}$$$$

Opening up... $$\hat{i} = 0.26726 \text{ } \hat{r} + 0.35857 \text{ }\hat{\theta} - 0.89443 \text{ }\hat{\phi}$$ $$\hat{j} = 0.53452 \text{ } \hat{r} + 0.71714 \text{ }\hat{\theta} + 0.44721 \text{ }\hat{\phi}$$ $$\hat{k} =0.80178 \text{ } \hat{r} - 0.59761 \text{ }\hat{\theta}$$

Plug the values in $$\vec{V} = 3 \hat{i} + 4 \hat{j} + 5 \hat{k}$$ $$= 3 ( 0.26726 \text{ } \hat{r} + 0.35857 \text{ }\hat{\theta} - 0.89443 \text{ }\hat{\phi} ) + 4 ( 0.53452 \text{ } \hat{r} + 0.71714 \text{ }\hat{\theta} + 0.44721 \text{ }\hat{\phi} ) + 5 (0.80178 \text{ } \hat{r} - 0.59761 \text{ }\hat{\theta})$$ $$= 6.9488 \text{ } \hat{r} + 0.95622 \text{ }\hat{\theta} - 0.89445 \text{ }\hat{\phi}$$

Caveat:- My spherical coordinates are differant than yours. Our $$\theta$$ and $$\phi$$ are switched. I am using physics convention as defined by https://en.wikipedia.org/wiki/Spherical_coordinate_system#/media/File:3D_Spherical.svg

Now, let's take this exercise further, and write the velocity in terms of its contravariant component. Remember, when the velocity components are contravariant, they must be combined with the covariant bases to reproduce the orginal vector. Meaning, our original vector can also be written as

$$\vec{V} = v^i e_i$$ $$\vec{V} = v^r e_r + v^{\theta} e_{\theta} + v^{\phi} e_{\phi}$$

where $$e_i$$ are the covariant bases. Covariant bases in the spherical coordinate system are related to the spherical unit vectors as

$$e_r = \hat{r}$$ $$e_{\theta} = r \hat{\theta}$$ $$e_{\phi} = r sin(\theta)\hat{\phi}$$

So, we are interested in finding out the contravariant components $$v^r, v^{\theta}, v^{\phi}$$.

Plugging the values in, we get $$$$\vec{V} = v^r \hat{r} + v^{\theta} r \hat{\theta} + v^{\phi} r sin(\theta)\hat{\phi}$$ \tag{1}$$

Comparing equation (1) with $$$$\vec{V} = 6.9488 \text{ } \hat{r} + 0.95622 \text{ }\hat{\theta} - 0.89445 \text{ }\hat{\phi}$$ \tag{2}$$

and, using the values of r, $$\theta$$ and $$\phi$$, We get $$v^r = 6.9488, v^\theta = 0.25567, v^\phi = -0.4$$

Therefore, the velocity in the contravariant form is

$$\vec{V} = 6.9488\text{ } e_r + 0.25567\text{ } e_{\theta} -0.4\text{ } e_{\phi}$$

One important point to note here is that when using spherical coordinates, only the components of unit vectors $$\hat{r}, \hat{\theta}, \hat{\phi}$$ represent the physical velocity. This is the velocity you would measure with the help of a speedometer. You can check this fact by computing the magnitude of velocity from the equation (2) and observing that it equals the magnitude in cartesian form.

$$\sqrt{6.9488^2 + 0.95622^2 + 0.89445^2} = \sqrt{50} = 7.071$$