<p>Upon further thinking, I realized that I could just differentiate the conversions of the coordinates. So the result is:</p>
<p><strong>Rectangular from spherical</strong>:
<span class="math-container">$$
\begin{bmatrix}
X' \\
Y' \\
Z' \\
\end{bmatrix}
=
\begin{bmatrix}
\cos{B} \cos{L} &amp; -R \sin{B} \cos{L} &amp; -R \cos{B} \sin{L} \\
\cos{B} \sin{L} &amp; -R \sin{B} \sin{L} &amp;  R \cos{B} \cos{L} \\
\sin{B}         &amp;  R \cos{B}         &amp;  0
\end{bmatrix}
\begin{bmatrix}
R' \\
B' \\
L'
\end{bmatrix}
$$</span></p>
<p><em>Note</em>: It would be helpful to save the sine and cosine of B and L beforehand computationwise.</p>
<p><strong>Spherical from rectangular</strong>:</p>
<p><span class="math-container">$$
\begin{bmatrix}
R'_h \\
B'_h \\
L'_h
\end{bmatrix}
=
\begin{bmatrix}
X &amp; Y &amp; Z \\
-XZ &amp; -YZ &amp; X^2 + Y^2 \\
-Y &amp; X &amp; 0
\end{bmatrix}
\begin{bmatrix}
X' \\
Y' \\
Z' \\
\end{bmatrix}
$$</span>
<span class="math-container">$$
R' = \frac{R'_h}{R} \space ; \space
B' = \frac{B'_h}{R^2 \sqrt{X^2 + Y^2}} \space ; \space 
L' = \frac{L'_h}{X^2 + Y^2}
$$</span></p>
<p><em>Note</em>: <span class="math-container">$R'_h$</span> etc are just helpers to avoid clutter within the matrix so that the division can be done at the end.</p>
<p><strong>Footnotes</strong>:</p>
<ol>
<li><p>There seemed to be one response pointing me to <a href="https://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#3-dimensional" rel="nofollow noreferrer">the 3D section of the Wikipedia article on coordinate transformations</a> but that response seems to have been deleted. Anyhow I did the derivatives myself with the help of SymPy, compared with Wikipedia (which uses a different notation) and finally tested with an astro library which provides speeds in either spherical or rectangular form (whose code I couldn't dig into so easily to find my answer).</p>
</li>
<li><p>If people feel that a question here is a HW question asked out of laziness, they can simply ignore it, or write a one-line response saying “try differentiating it yourself” if they don't want to work out the answer. Writing a comment implying that it seems to be asked out of laziness doesn't encourage people to ask questions. Thanks for understanding.</p>
</li>
</ol>

CC BY-SA 4.0
2024-11-19T13:13:49.683Z
It helps to make use of the definition of the triplet of unit vectors $\boldsymbol{\hat{r}}$,$\boldsymbol{\hat{\varphi}}$, $\boldsymbol{\hat{\theta}}$. After working with them a bit, you end up remembering how their time derivatives relate and their form in cartesian coordinates. Then this kind of conversion becomes easier to carry out. See for example [this](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Integration_and_differentiation_in_spherical_coordinates) and [this section in Wikipedia](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Kinematics)
Amit
CC BY-SA 4.0
2024-11-21T21:07:44.670Z
Your solution has the drawback that it requires knowledge of the position vector as well in order to transform the velocity vector. But you may not know this if for instance the velocity is determined experimentally through the Doppler effect. See my own answer below for the coordinate transformation requiring only the velocity vector.
Thomas
CC BY-SA 4.0
2024-11-19T11:31:47.073Z
2024-11-19T11:31:47.073Z
jamadagni
<p>Vector transformations do not care about the physical units. For any orthogonal system of coordinates the form of your transformation equations apply (see <a href="https://en.wikipedia.org/wiki/Orthogonal_coordinates" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Orthogonal_coordinates</a> ), regardless of the physical interpretation of the variables. So the same relationships hold for the transformation of velocities as well, i.e.</p>
<ol>
<li>Polar to rectangular</li>
</ol>
<p><span class="math-container">$$V_x = V \cos B_V \cos L_V$$</span>
<span class="math-container">$$V_y = V \cos B_V \sin L_V$$</span>
<span class="math-container">$$V_z = V \sin B_V$$</span></p>
<ol start="2">
<li>Rectangular to polar</li>
</ol>
<p><span class="math-container">$$V = \sqrt{V_x ^ 2 + V_y ^ 2 + V_z ^ 2}$$</span>
<span class="math-container">$$L_V = atan2(V_y, V_x)$$</span>
<span class="math-container">$$B_V = asin(V_z ÷ V)$$</span></p>
<p>Note though that in general you can not identify <span class="math-container">$V$</span> here as the derivative of <span class="math-container">$R$</span>, as the former relates to velocity space, the latter to real space. So you can not take it as the radial velocity with regard to the origin of your real space. Any velocity vector <span class="math-container">$\vec{V}$</span> represents an infinite number of possible trajectories in real space, which in general do not pass through the origin of the latter. If you want to know the radial velocity with regard to the origin of your real space (e.g.the center of the Earth), you would have to find the component of <span class="math-container">$\vec{V}$</span> along <span class="math-container">$\vec{R}$</span> (e.g. by taking the scalar product of both).</p>
<p>Edit: for clarification, see the following two graphics showing the position  vector and velocity vector in real and velocity space respectively (for simplicity restricted to 2 dimensions, and using conventional designation for the polar angle)</p>
<p><a href="https://i.sstatic.net/yrgP8zx0.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yrgP8zx0.jpg" alt="position vector coordinates" /></a></p>
<p><a href="https://i.sstatic.net/XpLoPbcg.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XpLoPbcg.jpg" alt="velocity vector coordinates" /></a></p>
<p>My equations above refer to the second graphic i.e. to the velocity vector, which is completely independent of the position vector (after all, the velocity is a separate degree of freedom). One velocity vector can in fact refer to an arbitrary number of position vectors (if all particles throughout space move with the same velocity). Both the velocity and the position vector transform by the same equations between the Cartesian and spherical coordinate systems.</p>
<p>The advantage with doing the coordinate transformation in a separate velocity space is that no position coordinates are needed for this (in contrast to the other answer based on the derivative of the transformation in real space). This transformation can be done therefore also in cases where the positions are not known (e.g. if the velocities are experimentally determined through the Doppler effect).</p>

CC BY-SA 4.0
2024-11-22T18:26:25.383Z
@Amit In spherical coordinates $V$ consists of a radial as well as a tangential component. For a circular motion for instance the former is $0$ so $dR/dt=0$. $V$ as defined by my expression above has in this case only a tangential component (i.e. $R$=const.)
Thomas
CC BY-SA 4.0
2024-11-22T18:38:41.850Z
@Amit There is no limitation involved with the transformation equations I gave above. They hold for any velocity vector. I just gave the special case of circular motion in my comment to make it easier for you to see that your statement above claiming $V$ is the derivative of $R$ is incorrect.
Thomas
CC BY-SA 4.0
2024-11-22T19:03:21.053Z
@Amit $dR/dt \neq |d\vec r/dt|=V $ (taking $R$ as defined by the OP), which is the point I have been trying to explain to you.
Thomas
CC BY-SA 4.0
2024-11-22T19:35:24.963Z
@Amit Because for a circular motion $d\vec r/dt$ is perpendicular to $\hat R$ so $dR/dt=\hat R   \cdot d\vec r/dt= 0$. You have $dR/dt=|d\vec r/dt|=V$ only for a radial motion (no tangential velocity component).
Thomas
CC BY-SA 4.0
2024-11-23T21:48:08.143Z
@Amit If you do a coordinate transformation, you obviously assume the coordinates in one of the systems as given. There is nothing circular about it. Otherwise the equations the OP gave in the opening post would be circular as well. My equations are just the corresponding equations in velocity space.
Thomas
CC BY-SA 4.0
2024-11-23T21:56:45.750Z
@Thomas If you're working in spherical coordinates, you have your vectors, whether position, velocity, acceleration, or higher derivatives, written in terms of the basis vectors $\hat{r} , \hat{\varphi}, \hat{\theta}$. *That's the meaning of working in spherical coordinates*. and these vectors are the basis vectors for the position space. Therefore, your answer is only meaningful if you would also explain how exactly OP can first translate his vector to "velocity space" as you say. Otherwise, how is it helpful?
Amit
CC BY-SA 4.0
2024-11-25T23:47:02.283Z
@Amit The basis vectors for the velocity are not $\hat{r}, \hat{\phi}, \hat{\theta}$ but $\hat{v}, \hat{\phi_v}, \hat{\theta_v}$. See my edited answer for a graphic illustration of this.
Thomas
CC BY-SA 4.0
2024-11-25T23:54:50.280Z
@Thomas I got it, but I never seen this become really useful. How for example would you carry out an integral of a force over some trajectory to calculate work? You need the second derivative of position in the position basis. Every computation I know of ends up being expressed in terms of position coordinates, even in differential geometry contexts like GR, while position is not a vector you have to pick a position based coordinate system, even if a local one, to make computations.
Amit
CC BY-SA 4.0
2024-11-26T19:34:39.183Z
@Amit The concepts of velocity and acceleration have been developed for a reason. If you are reducing everything to the position vectors again you are just kind of trying to re-invent the wheel. Have a look at answer that the OP gave himself. The transformation is not only unnecessarily complicated but misleadingly suggests that, apart from the velocity vector, you need also the position vector to do the transformation. My transformation above is much simpler as it only requires a velocity vector (which in some cases is the only thing you may have).
Thomas
CC BY-SA 4.0
2024-11-26T19:41:42.180Z
@Thomas Well, I've never seen your approach used anywhere, much less do I understand how it can be useful in practice. For one thing, there's no mention of it [in the Wikipedia's page on spherical coordinates - Kinematics section](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Kinematics). Instead what you can see there is essentially the same thing OP wrote in his own answer with the one main difference that OP wrote out everything in terms of the cartesian basis vectors, which results in a much longer expression.
Amit
CC BY-SA 4.0
2024-11-27T18:27:54.193Z
@Amit Well, then tell me how you transform the velocity vector $(v_x, v_y, v_z)$ to spherical coordinates (assume you have measured these values from the Doppler shift of the radiation emitted by the object and don't know its position coordinates)
Thomas
CC BY-SA 4.0
2024-11-27T21:01:12.073Z
In actuality, if you examine your own answer closely, you'll see it's not really a statement related to coordinate transformation at all. The only real statement you make is essentially, that a vector can be either represented via $n$ components where $n$ is the dimensionality of the space, or via a magnitude and a direction. Since you're resolving that direction by taking the *components of the vector themselves to be the directions your axes* it becomes almost a tautological statement too, and unrelated to transformation between coordinate systems where other relevant vectors "live".
Amit
CC BY-SA 4.0
2024-12-01T15:48:54.707Z
@Amit It seems that I still did not quite manage to get my point across. So let me ask you the following: assume you have 2 equal vectors $\vec{v_1}=\vec{v_2}$ in the cartesian coordinate system, would you not agree that this also requires $\vec{v_1}=\vec{v_2}$ after transforming both vectors to the spherical coordinate system?
Thomas
CC BY-SA 4.0
2024-12-01T16:14:53.470Z
a real vector is the same object regardless of the basis you write it in. I am not arguing that you can't concoct a completely different basis for each and every $\vec{v}$ and write $\vec{v}$ with respect to that basis. Here, let's invent a basis for our vector $\vec{v}$, it will have two basis vectors $\hat{v}_\perp$ and $\hat{v}_\parallel$, so we can always write it in components like $\vec{v} = v_n\hat{v}_\perp + v_p\hat{v}_\parallel $... great, we can do that. That's what you're doing. I am not doubting it's possible, I'm doubting its usefulness.
Amit
CC BY-SA 4.0
2024-12-02T18:28:46.527Z
@Amit If the vector must be the same object regardless of the basis, then writing the derivatives in terms of $\hat{r}, \hat{\phi},\hat{\theta}$ is mathematically incorrect: 

assume two cartesian vectors ${{r_1}}=(v\cdot t,0)$ and ${r_2}=(v\cdot t,y_0)$ i.e. $\dot{{r_1}}=\dot{{r_2}} =(v,0)$ (same in polar coordinates). Yet if you transform $r_1, r_2$ to polar coordinates first you get ${r_1}=(v\cdot t,0)$ and  ${r_2}=(\sqrt{y_0^2+v^2\cdot t^2}, \arctan(y_0/v/t))$  so $\dot{{r_1}}=(v,0)$ but $\dot{{r_2}}=(v^2t/\sqrt{y_0^2+v^2\cdot t^2},-y_0v/(v^2t^2+y_0^2))$ i.e. $\dot{{r_1}}\neq\dot{r_2}$
Thomas
CC BY-SA 4.0
2024-12-02T19:07:47.820Z
You have a basic misunderstanding, the coordinates are just labels, they are not the full vector. You are comparing the labels and because they are different you say the vector is different. Not sure if you even computed the correct coordinates, this is irrelevant because it's a conceptual point. In polar coordinates, the unit vectors are not constant. *All* position vectors have the form $\vec{r}=r\hat{r}$. and in fact the same value of $r$ can correspond to different vectors because $\hat{r}$ is a function of $\theta$! That's why we sometimes write explicitly:
$$\vec{r}=r\hat{r}(\theta)$$
Amit
CC BY-SA 4.0
2024-12-03T23:23:05.383Z
@Amit *the coordinates are just labels, they are not the full vector* Where did you get this one from? This would contradict the fundamental definition of vectors which implies that two vectors are equal if and only if their components are equal, whether it is the Cartesian or the polar reference frame  (this should be evident for instance from https://www.grc.nasa.gov/www/k-12/airplane/vectpart.html ).  You may have been confused by the fact that I left out the arrows over the vectors (they took up too many characters), but it really should be obvious from the context that these are vectors.
Thomas
CC BY-SA 4.0
2024-12-04T00:10:00.133Z
The components uniquely define the vector only if you're comparing vectors with the same basis. I thought you were comparing between the different coordinate systems, but I see now the issue with what you wrote is a bit different. The issue is that you're differentiating the components and thinking that's the derivative of the vector. So my point is still relevant: since in general coordinates the basis vectors are not constant, for example in 2d polar coordinates if the vector has components $(r,\theta)$, its derivative is *not* $(\dot{r},\dot{\theta})$, so what you wrote is just wrong
Amit
CC BY-SA 4.0
2024-12-04T00:16:52.350Z
Here's a tip: for 2d polar coordinates, you can verify that the relation of the cartesian basis vectors to the polar ones is: $$ \hat{x} = \cos\theta\hat{r}-\sin\theta\hat{\theta} , \ \hat{y}=\sin\theta\hat{r}+\cos\theta\hat{\theta}, $$ so for the case of $\vec{r}_2=vt\hat{x}+k\hat{y}$, try substituting the above first for $\hat{x}$ and $\hat{y}$ and then work out the derivative, all the time recalling that $\dot{\hat{r}}=\dot{\theta}\hat{\theta}$ and $\dot{\hat{\theta}}=-\dot{\theta}\hat{r}$. if you do this, you'll find the time derivative is the same as for $\vec{r}_1$, in both coordinates
Amit
CC BY-SA 4.0
2024-12-04T01:18:51.370Z
Incidentally, one more note... the notation for components that works for cartesian coordinates e.g. $(x,y,z)$, is *terrible* for general coordinate systems. In cartesian coordinates, for a vector $\vec{A}$ it is correct that $\vec{A}\cdot\hat{x}=A_x$, so that writing $\vec{A}=(A_x,A_y,A_z)$ makes sense. In polar coordinates, the same vector is $\vec{A}=A_r\hat{r}$. so we see that $\vec{r}\cdot\hat{r}=A_r$, $\vec{r}\cdot\hat{\theta}=0$. But $\theta$ is in general *not* zero. So identifying $(r,\theta)$ with $r\hat{r}$ becomes very confusing. So I prefer to write the explicit basis vectors
Amit
CC BY-SA 4.0
2024-12-13T08:07:18.383Z
@Amit the result for the calculation of  $\dot r$ and $\dot \theta$ in my comment above is correct. It is exactly the same you get from the matrix equation in the answer by jamadagni (the OP) above. Just insert $X=vt$, $Y=y_0$ and $X'=v$ there. I only derived it differently from the Pythagorean theorem and the trigonometrical relations. And it is obvious that the result for the two vectors must be different here as it depends on the positions of the objects. However, this contradicts in principle the concept of a vector which should only have magnitude and direction but not depend on location.
Thomas
CC BY-SA 4.0
2024-12-13T08:09:17.810Z
@Amit You seem to be having some wrong ideas about vectors here. The vector components are *scalars* not vectors themselves as you seem to imply. And each set of these scalar components define the vector uniquely, whether it is Cartesian, spherical/polar or any other basis. There is no such thing as different vectors having the same components. See again https://www.grc.nasa.gov/www/k-12/airplane/vectpart.html and links in there for more. See also Eq.5.5.21 in http://www.physicsbootcamp.org/Motion-in-Polar-Coordinates.html which confirms that $v_r=\dot r$.
Thomas
CC BY-SA 4.0
2024-12-13T10:39:48.323Z
You're just wrong, a vector can depend on location. The polar basis is in fact a vector *field*, not a fixed pair of vectors
Amit
CC BY-SA 4.0
2024-12-13T11:11:52.770Z
So just to show you how to do it properly, here is the calculation you refused to do. Start with the cartesian vectors you've written:
$$ \vec{r}_1 = vt\hat{x} $$
$$ \vec{r}_2 = vt\hat{x}+y_0\hat{y} $$
rewrite them in cartesian coordinates by the relation I gave above (which again, you can easily verify):
$$ \vec{r}_1 = vt(\cos\theta\hat{r}-\sin\theta\hat{\theta})$$
\begin{align*}
 \vec{r}_2 &= vt(\cos\theta\hat{r}-\sin\theta\hat{\theta})+y_0(\sin\theta\hat{r}+\cos\theta\hat{\theta})
\\ &= (vt\cos\theta+y_0\sin\theta)\hat{r}+(y_0\cos\theta-vt\sin\theta)\hat{\theta}
\end{align*}
Amit
CC BY-SA 4.0
2024-12-13T11:12:23.913Z
For this one we clearly have $\theta=0$ because $(\vec{r}_1)_y=0$, so:
\begin{align*}
\dot{\vec{r}}_1 &= v(\cos\theta\hat{r}-\sin\theta\hat{\theta})+\require{cancel}\cancel{vt(-\sin\theta\dot{\theta}\hat{r}-\cos\theta\dot{\theta}\hat{\theta})}
\\&= v(\cos\theta\hat{r}-\sin\theta\hat{\theta})
\\&= v\hat{x}
\end{align*}
Now you're probably misled, by the fact that for $\vec{r}_2$ we have $\theta\neq 0$. But now observe:
Amit
CC BY-SA 4.0
2024-12-13T11:12:34.397Z
\begin{align*}
\dot{\vec{r}_2} &= (v\cos\theta-\color{red}{{vt\sin\theta\dot{\theta}}}+\color{blue}{y_0\cos\theta\dot{\theta}})\hat{r}+(\color{green}{vt\cos\theta\dot{\theta}}+\color{magenta}{y_0\sin\theta\dot{\theta}})\hat{\theta}+(\color{magenta}{-y_0\sin\theta\dot{\theta}}-v\sin\theta-\color{green}{vt\cos\theta\dot{\theta}})\hat{\theta}-(\color{blue}{y_0\cos\theta\dot{\theta}}-\color{red}{vt\sin\theta\dot{\theta}})\hat{r}
\\&= v(\cos\theta\hat{r}-\sin\theta\hat{\theta})
\\&= v\hat{x}
\\&= \dot{\vec{r}_1}
\end{align*}
Amit
CC BY-SA 4.0
2024-12-13T11:12:53.377Z
The color coded pairs of terms clearly cancel, and the time derivative is the same. With this, I'll be done with this comment section, who has gone for way too long anyway. I hope you'll take the time to really study the subject, before talking so authoritatively about things that you clearly don't even bother to check.
Amit
CC BY-SA 4.0
2024-12-15T20:01:59.693Z
@Amit  *I'll be done with this comment section* Just as well. You should take a lengthy timeout and try to get a proper grip on the issue here. You may have acquired some basic knowledge somewhere, but your application of it is all over the place. For instance, what on earth have you been thinking when doing the calculation above? Even though inserting polar coordinates, the initial  and final vectors are just Cartesian coordinates, and as I showed myself earlier these are of course equal. You did not calculate $\dot r$ and $\dot \theta$ at all, and these are different in the two cases.
Thomas
CC BY-SA 4.0
2024-11-16T18:24:06.387Z
2024-11-25T23:46:25.753Z
2024-11-25T23:46:25.753Z
Thomas
<p>If I am not mistaken, position vectors (celestial coordinates) in polar form (L longitude, B latitude, R distance) can be converted into rectangular form X,Y,Z and back as follows:</p>
<ol>
<li>Polar to rectangular</li>
</ol>
<p><span class="math-container">$$X = R \cos B \cos L$$</span>
<span class="math-container">$$Y = R \cos B \sin L$$</span>
<span class="math-container">$$Z = R \sin B$$</span></p>
<ol start="2">
<li>Rectangular to polar</li>
</ol>
<p><span class="math-container">$$R = \sqrt{X ^ 2 + Y ^ 2 + Z ^ 2}$$</span>
<span class="math-container">$$L = atan2(Y, X)$$</span>
<span class="math-container">$$B = asin(Z ÷ R)$$</span></p>
<p>I hope this is correct. I would now like to know how to convert the <em>derivatives</em> of these vectors between the two forms. That is, velocity in longitude, latitude and distance to/from velocity along the three axes.</p>

CC BY-SA 4.0
2024-11-17T03:57:38.587Z
I could provide an answer, but I'm not going to do so as this looks way too much like a "do my homework for me" type of question.
David Hammen
CC BY-SA 4.0
2024-11-18T09:52:44.130Z
@DavidHammen I'm sorry you should feel that way. I am a Ph D in my own discipline which is Sanskrit. It is not to be expected that I am an expert at mathematics. My question stems from my research into astronomy texts written in Sanskrit. I did check Meeus' Astronomical Algorithms but didn't find any formulae there. I also googled first but I found only two dimensional solutions.
jamadagni
CC BY-SA 4.0
2024-11-18T09:57:50.963Z
https://github.com/ytliu0/ElpMpp02/issues/2 and other issues I filed on that library just last week should show that I have been working on this very matter. I was told by that author to “simple transform the final rectangular coordinates to the spherical coordinates” which is what I am looking for a way to do. Thanks.
jamadagni
CC BY-SA 4.0
2024-11-18T10:28:50.427Z
I had already found [this question on Physics Forums](https://www.physicsforums.com/threads/converting-velocity-formula-polar-to-cartesian.978591/) and [other](https://math.stackexchange.com/q/2362700/41584) [questions](https://physics.stackexchange.com/q/411579/95401) on SE but they all speak only about 2 dimensions and I am not sure how to adapt that to my requirement here.
jamadagni
<velocity><coordinate-systems>
How to convert the derivatives of position vectors in polar form to/from rectangular form
jamadagni
# How to convert the derivatives of position vectors in polar form to/from rectangular form

(Asked by: username_0 on 2024-11-15)

If I am not mistaken, position vectors (celestial coordinates) in polar form (L longitude, B latitude, R distance) can be converted into rectangular form X,Y,Z and back as follows:

1. Polar to rectangular

$$X = R \cos B \cos L$$
$$Y = R \cos B \sin L$$
$$Z = R \sin B$$

2. Rectangular to polar

$$R = \sqrt{X ^ 2 + Y ^ 2 + Z ^ 2}$$
$$L = atan2(Y, X)$$
$$B = asin(Z ÷ R)$$

I hope this is correct. I would now like to know how to convert the *derivatives* of these vectors between the two forms. That is, velocity in longitude, latitude and distance to/from velocity along the three axes.

**Tags:** velocity, coordinate-systems
> **Comments:**
> **username_1**: I could provide an answer, but I'm not going to do so as this looks way too much like a "do my homework for me" type of question.  
> **username_0**: @DavidHammen I'm sorry you should feel that way. I am a Ph D in my own discipline which is Sanskrit. It is not to be expected that I am an expert at mathematics. My question stems from my research into astronomy texts written in Sanskrit. I did check Meeus' Astronomical Algorithms but didn't find any formulae there. I also googled first but I found only two dimensional solutions.  
> **username_0**: https://github.com/ytliu0/ElpMpp02/issues/2 and other issues I filed on that library just last week should show that I have been working on this very matter. I was told by that author to “simple transform the final rectangular coordinates to the spherical coordinates” which is what I am looking for a way to do. Thanks.  
> **username_0**: I had already found [this question on Physics Forums](https://www.physicsforums.com/threads/converting-velocity-formula-polar-to-cartesian.978591/) and [other](https://math.stackexchange.com/q/2362700/41584) [questions](https://physics.stackexchange.com/q/411579/95401) on SE but they all speak only about 2 dimensions and I am not sure how to adapt that to my requirement here.  

---

## 2 answers

### Answer by username_0 on 2024-11-19. Score: 3

Upon further thinking, I realized that I could just differentiate the conversions of the coordinates. So the result is:

**Rectangular from spherical**:
$$
\begin{bmatrix}
X' \\
Y' \\
Z' \\
\end{bmatrix}
=
\begin{bmatrix}
\cos{B} \cos{L} & -R \sin{B} \cos{L} & -R \cos{B} \sin{L} \\
\cos{B} \sin{L} & -R \sin{B} \sin{L} & R \cos{B} \cos{L} \\
\sin{B} & R \cos{B} & 0
\end{bmatrix}
\begin{bmatrix}
R' \\
B' \\
L'
\end{bmatrix}
$$

*Note*: It would be helpful to save the sine and cosine of B and L beforehand computationwise.

**Spherical from rectangular**:

$$
\begin{bmatrix}
R'\_h \\
B'\_h \\
L'\_h
\end{bmatrix}
=
\begin{bmatrix}
X & Y & Z \\
-XZ & -YZ & X^2 + Y^2 \\
-Y & X & 0
\end{bmatrix}
\begin{bmatrix}
X' \\
Y' \\
Z' \\
\end{bmatrix}
$$
$$
R' = \frac{R'\_h}{R} \space ; \space
B' = \frac{B'\_h}{R^2 \sqrt{X^2 + Y^2}} \space ; \space
L' = \frac{L'\_h}{X^2 + Y^2}
$$

*Note*: $R'\_h$ etc are just helpers to avoid clutter within the matrix so that the division can be done at the end.

**Footnotes**:

1. There seemed to be one response pointing me to [the 3D section of the Wikipedia article on coordinate transformations](https://en.wikipedia.org/wiki/List_of_common_coordinate_transformations#3-dimensional) but that response seems to have been deleted. Anyhow I did the derivatives myself with the help of SymPy, compared with Wikipedia (which uses a different notation) and finally tested with an astro library which provides speeds in either spherical or rectangular form (whose code I couldn't dig into so easily to find my answer).
2. If people feel that a question here is a HW question asked out of laziness, they can simply ignore it, or write a one-line response saying “try differentiating it yourself” if they don't want to work out the answer. Writing a comment implying that it seems to be asked out of laziness doesn't encourage people to ask questions. Thanks for understanding.

> **Comments:**
> **username_2**: It helps to make use of the definition of the triplet of unit vectors $\boldsymbol{\hat{r}}$,$\boldsymbol{\hat{\varphi}}$, $\boldsymbol{\hat{\theta}}$. After working with them a bit, you end up remembering how their time derivatives relate and their form in cartesian coordinates. Then this kind of conversion becomes easier to carry out. See for example [this](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Integration_and_differentiation_in_spherical_coordinates) and [this section in Wikipedia](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Kinematics)  
> **username_3**: Your solution has the drawback that it requires knowledge of the position vector as well in order to transform the velocity vector. But you may not know this if for instance the velocity is determined experimentally through the Doppler effect. See my own answer below for the coordinate transformation requiring only the velocity vector.  

---

### Answer by username_3 on 2024-11-16. Score: -3

Vector transformations do not care about the physical units. For any orthogonal system of coordinates the form of your transformation equations apply (see <https://en.wikipedia.org/wiki/Orthogonal_coordinates> ), regardless of the physical interpretation of the variables. So the same relationships hold for the transformation of velocities as well, i.e.

1. Polar to rectangular

$$V\_x = V \cos B\_V \cos L\_V$$
$$V\_y = V \cos B\_V \sin L\_V$$
$$V\_z = V \sin B\_V$$

2. Rectangular to polar

$$V = \sqrt{V\_x ^ 2 + V\_y ^ 2 + V\_z ^ 2}$$
$$L\_V = atan2(V\_y, V\_x)$$
$$B\_V = asin(V\_z ÷ V)$$

Note though that in general you can not identify $V$ here as the derivative of $R$, as the former relates to velocity space, the latter to real space. So you can not take it as the radial velocity with regard to the origin of your real space. Any velocity vector $\vec{V}$ represents an infinite number of possible trajectories in real space, which in general do not pass through the origin of the latter. If you want to know the radial velocity with regard to the origin of your real space (e.g.the center of the Earth), you would have to find the component of $\vec{V}$ along $\vec{R}$ (e.g. by taking the scalar product of both).

Edit: for clarification, see the following two graphics showing the position vector and velocity vector in real and velocity space respectively (for simplicity restricted to 2 dimensions, and using conventional designation for the polar angle)

[![position vector coordinates](https://i.sstatic.net/yrgP8zx0.jpg)](https://i.sstatic.net/yrgP8zx0.jpg)

[![velocity vector coordinates](https://i.sstatic.net/XpLoPbcg.jpg)](https://i.sstatic.net/XpLoPbcg.jpg)

My equations above refer to the second graphic i.e. to the velocity vector, which is completely independent of the position vector (after all, the velocity is a separate degree of freedom). One velocity vector can in fact refer to an arbitrary number of position vectors (if all particles throughout space move with the same velocity). Both the velocity and the position vector transform by the same equations between the Cartesian and spherical coordinate systems.

The advantage with doing the coordinate transformation in a separate velocity space is that no position coordinates are needed for this (in contrast to the other answer based on the derivative of the transformation in real space). This transformation can be done therefore also in cases where the positions are not known (e.g. if the velocities are experimentally determined through the Doppler effect).

> **Comments:**
> **username_3**: @Amit In spherical coordinates $V$ consists of a radial as well as a tangential component. For a circular motion for instance the former is $0$ so $dR/dt=0$. $V$ as defined by my expression above has in this case only a tangential component (i.e. $R$=const.)  
> **username_3**: @Amit There is no limitation involved with the transformation equations I gave above. They hold for any velocity vector. I just gave the special case of circular motion in my comment to make it easier for you to see that your statement above claiming $V$ is the derivative of $R$ is incorrect.  
> **username_3**: @Amit $dR/dt \neq |d\vec r/dt|=V $ (taking $R$ as defined by the OP), which is the point I have been trying to explain to you.  
> **username_3**: @Amit Because for a circular motion $d\vec r/dt$ is perpendicular to $\hat R$ so $dR/dt=\hat R   \cdot d\vec r/dt= 0$. You have $dR/dt=|d\vec r/dt|=V$ only for a radial motion (no tangential velocity component).  
> **username_3**: @Amit If you do a coordinate transformation, you obviously assume the coordinates in one of the systems as given. There is nothing circular about it. Otherwise the equations the OP gave in the opening post would be circular as well. My equations are just the corresponding equations in velocity space.  
> **username_2**: @Thomas If you're working in spherical coordinates, you have your vectors, whether position, velocity, acceleration, or higher derivatives, written in terms of the basis vectors $\hat{r} , \hat{\varphi}, \hat{\theta}$. *That's the meaning of working in spherical coordinates*. and these vectors are the basis vectors for the position space. Therefore, your answer is only meaningful if you would also explain how exactly OP can first translate his vector to "velocity space" as you say. Otherwise, how is it helpful?  
> **username_3**: @Amit The basis vectors for the velocity are not $\hat{r}, \hat{\phi}, \hat{\theta}$ but $\hat{v}, \hat{\phi_v}, \hat{\theta_v}$. See my edited answer for a graphic illustration of this.  
> **username_2**: @Thomas I got it, but I never seen this become really useful. How for example would you carry out an integral of a force over some trajectory to calculate work? You need the second derivative of position in the position basis. Every computation I know of ends up being expressed in terms of position coordinates, even in differential geometry contexts like GR, while position is not a vector you have to pick a position based coordinate system, even if a local one, to make computations.  
> **username_3**: @Amit The concepts of velocity and acceleration have been developed for a reason. If you are reducing everything to the position vectors again you are just kind of trying to re-invent the wheel. Have a look at answer that the OP gave himself. The transformation is not only unnecessarily complicated but misleadingly suggests that, apart from the velocity vector, you need also the position vector to do the transformation. My transformation above is much simpler as it only requires a velocity vector (which in some cases is the only thing you may have).  
> **username_2**: @Thomas Well, I've never seen your approach used anywhere, much less do I understand how it can be useful in practice. For one thing, there's no mention of it [in the Wikipedia's page on spherical coordinates - Kinematics section](https://en.wikipedia.org/wiki/Spherical_coordinate_system#Kinematics). Instead what you can see there is essentially the same thing OP wrote in his own answer with the one main difference that OP wrote out everything in terms of the cartesian basis vectors, which results in a much longer expression.  
> **username_3**: @Amit Well, then tell me how you transform the velocity vector $(v_x, v_y, v_z)$ to spherical coordinates (assume you have measured these values from the Doppler shift of the radiation emitted by the object and don't know its position coordinates)  
> **username_2**: In actuality, if you examine your own answer closely, you'll see it's not really a statement related to coordinate transformation at all. The only real statement you make is essentially, that a vector can be either represented via $n$ components where $n$ is the dimensionality of the space, or via a magnitude and a direction. Since you're resolving that direction by taking the *components of the vector themselves to be the directions your axes* it becomes almost a tautological statement too, and unrelated to transformation between coordinate systems where other relevant vectors "live".  
> **username_3**: @Amit It seems that I still did not quite manage to get my point across. So let me ask you the following: assume you have 2 equal vectors $\vec{v_1}=\vec{v_2}$ in the cartesian coordinate system, would you not agree that this also requires $\vec{v_1}=\vec{v_2}$ after transforming both vectors to the spherical coordinate system?  
> **username_2**: a real vector is the same object regardless of the basis you write it in. I am not arguing that you can't concoct a completely different basis for each and every $\vec{v}$ and write $\vec{v}$ with respect to that basis. Here, let's invent a basis for our vector $\vec{v}$, it will have two basis vectors $\hat{v}_\perp$ and $\hat{v}_\parallel$, so we can always write it in components like $\vec{v} = v_n\hat{v}_\perp + v_p\hat{v}_\parallel $... great, we can do that. That's what you're doing. I am not doubting it's possible, I'm doubting its usefulness.  
> **username_3**: @Amit If the vector must be the same object regardless of the basis, then writing the derivatives in terms of $\hat{r}, \hat{\phi},\hat{\theta}$ is mathematically incorrect:   assume two cartesian vectors ${{r_1}}=(v\cdot t,0)$ and ${r_2}=(v\cdot t,y_0)$ i.e. $\dot{{r_1}}=\dot{{r_2}} =(v,0)$ (same in polar coordinates). Yet if you transform $r_1, r_2$ to polar coordinates first you get ${r_1}=(v\cdot t,0)$ and  ${r_2}=(\sqrt{y_0^2+v^2\cdot t^2}, \arctan(y_0/v/t))$  so $\dot{{r_1}}=(v,0)$ but $\dot{{r_2}}=(v^2t/\sqrt{y_0^2+v^2\cdot t^2},-y_0v/(v^2t^2+y_0^2))$ i.e. $\dot{{r_1}}\neq\dot{r_2}$  
> **username_2**: You have a basic misunderstanding, the coordinates are just labels, they are not the full vector. You are comparing the labels and because they are different you say the vector is different. Not sure if you even computed the correct coordinates, this is irrelevant because it's a conceptual point. In polar coordinates, the unit vectors are not constant. *All* position vectors have the form $\vec{r}=r\hat{r}$. and in fact the same value of $r$ can correspond to different vectors because $\hat{r}$ is a function of $\theta$! That's why we sometimes write explicitly: $$\vec{r}=r\hat{r}(\theta)$$  
> **username_3**: @Amit *the coordinates are just labels, they are not the full vector* Where did you get this one from? This would contradict the fundamental definition of vectors which implies that two vectors are equal if and only if their components are equal, whether it is the Cartesian or the polar reference frame  (this should be evident for instance from https://www.grc.nasa.gov/www/k-12/airplane/vectpart.html ).  You may have been confused by the fact that I left out the arrows over the vectors (they took up too many characters), but it really should be obvious from the context that these are vectors.  
> **username_2**: The components uniquely define the vector only if you're comparing vectors with the same basis. I thought you were comparing between the different coordinate systems, but I see now the issue with what you wrote is a bit different. The issue is that you're differentiating the components and thinking that's the derivative of the vector. So my point is still relevant: since in general coordinates the basis vectors are not constant, for example in 2d polar coordinates if the vector has components $(r,\theta)$, its derivative is *not* $(\dot{r},\dot{\theta})$, so what you wrote is just wrong  
> **username_2**: Here's a tip: for 2d polar coordinates, you can verify that the relation of the cartesian basis vectors to the polar ones is: $$ \hat{x} = \cos\theta\hat{r}-\sin\theta\hat{\theta} , \ \hat{y}=\sin\theta\hat{r}+\cos\theta\hat{\theta}, $$ so for the case of $\vec{r}_2=vt\hat{x}+k\hat{y}$, try substituting the above first for $\hat{x}$ and $\hat{y}$ and then work out the derivative, all the time recalling that $\dot{\hat{r}}=\dot{\theta}\hat{\theta}$ and $\dot{\hat{\theta}}=-\dot{\theta}\hat{r}$. if you do this, you'll find the time derivative is the same as for $\vec{r}_1$, in both coordinates  
> **username_2**: Incidentally, one more note... the notation for components that works for cartesian coordinates e.g. $(x,y,z)$, is *terrible* for general coordinate systems. In cartesian coordinates, for a vector $\vec{A}$ it is correct that $\vec{A}\cdot\hat{x}=A_x$, so that writing $\vec{A}=(A_x,A_y,A_z)$ makes sense. In polar coordinates, the same vector is $\vec{A}=A_r\hat{r}$. so we see that $\vec{r}\cdot\hat{r}=A_r$, $\vec{r}\cdot\hat{\theta}=0$. But $\theta$ is in general *not* zero. So identifying $(r,\theta)$ with $r\hat{r}$ becomes very confusing. So I prefer to write the explicit basis vectors  
> **username_3**: @Amit the result for the calculation of  $\dot r$ and $\dot \theta$ in my comment above is correct. It is exactly the same you get from the matrix equation in the answer by jamadagni (the OP) above. Just insert $X=vt$, $Y=y_0$ and $X'=v$ there. I only derived it differently from the Pythagorean theorem and the trigonometrical relations. And it is obvious that the result for the two vectors must be different here as it depends on the positions of the objects. However, this contradicts in principle the concept of a vector which should only have magnitude and direction but not depend on location.  
> **username_3**: @Amit You seem to be having some wrong ideas about vectors here. The vector components are *scalars* not vectors themselves as you seem to imply. And each set of these scalar components define the vector uniquely, whether it is Cartesian, spherical/polar or any other basis. There is no such thing as different vectors having the same components. See again https://www.grc.nasa.gov/www/k-12/airplane/vectpart.html and links in there for more. See also Eq.5.5.21 in http://www.physicsbootcamp.org/Motion-in-Polar-Coordinates.html which confirms that $v_r=\dot r$.  
> **username_2**: You're just wrong, a vector can depend on location. The polar basis is in fact a vector *field*, not a fixed pair of vectors  
> **username_2**: So just to show you how to do it properly, here is the calculation you refused to do. Start with the cartesian vectors you've written: $$ \vec{r}_1 = vt\hat{x} $$ $$ \vec{r}_2 = vt\hat{x}+y_0\hat{y} $$ rewrite them in cartesian coordinates by the relation I gave above (which again, you can easily verify): $$ \vec{r}_1 = vt(\cos\theta\hat{r}-\sin\theta\hat{\theta})$$ \begin{align*}  \vec{r}_2 &= vt(\cos\theta\hat{r}-\sin\theta\hat{\theta})+y_0(\sin\theta\hat{r}+\cos\theta\hat{\theta}) \\ &= (vt\cos\theta+y_0\sin\theta)\hat{r}+(y_0\cos\theta-vt\sin\theta)\hat{\theta} \end{align*}  
> **username_2**: For this one we clearly have $\theta=0$ because $(\vec{r}_1)_y=0$, so: \begin{align*} \dot{\vec{r}}_1 &= v(\cos\theta\hat{r}-\sin\theta\hat{\theta})+\require{cancel}\cancel{vt(-\sin\theta\dot{\theta}\hat{r}-\cos\theta\dot{\theta}\hat{\theta})} \\&= v(\cos\theta\hat{r}-\sin\theta\hat{\theta}) \\&= v\hat{x} \end{align*} Now you're probably misled, by the fact that for $\vec{r}_2$ we have $\theta\neq 0$. But now observe:  
> **username_2**: \begin{align*} \dot{\vec{r}_2} &= (v\cos\theta-\color{red}{{vt\sin\theta\dot{\theta}}}+\color{blue}{y_0\cos\theta\dot{\theta}})\hat{r}+(\color{green}{vt\cos\theta\dot{\theta}}+\color{magenta}{y_0\sin\theta\dot{\theta}})\hat{\theta}+(\color{magenta}{-y_0\sin\theta\dot{\theta}}-v\sin\theta-\color{green}{vt\cos\theta\dot{\theta}})\hat{\theta}-(\color{blue}{y_0\cos\theta\dot{\theta}}-\color{red}{vt\sin\theta\dot{\theta}})\hat{r} \\&= v(\cos\theta\hat{r}-\sin\theta\hat{\theta}) \\&= v\hat{x} \\&= \dot{\vec{r}_1} \end{align*}  
> **username_2**: The color coded pairs of terms clearly cancel, and the time derivative is the same. With this, I'll be done with this comment section, who has gone for way too long anyway. I hope you'll take the time to really study the subject, before talking so authoritatively about things that you clearly don't even bother to check.  
> **username_3**: @Amit  *I'll be done with this comment section* Just as well. You should take a lengthy timeout and try to get a proper grip on the issue here. You may have acquired some basic knowledge somewhere, but your application of it is all over the place. For instance, what on earth have you been thinking when doing the calculation above? Even though inserting polar coordinates, the initial  and final vectors are just Cartesian coordinates, and as I showed myself earlier these are of course equal. You did not calculate $\dot r$ and $\dot \theta$ at all, and these are different in the two cases.  

---

