# Coordinate transformation from spherical to rectangular

Tags:
1. Jan 10, 2016

### TheArun

Iam having trouble understanding how one arrives at the transformation matrix for spherical to rectangular coordinates.
I understand till getting the (x,y,z) from (r,th
ie.,
z = rcos@
y = rsin@sin#
x = rsin@cos#

Note:
@ - theta (vertical angle)
# - phi (horizontal angle)

Please show me how to get the transformation matrix. Thanks in advance!

2. Jan 10, 2016

### blue_leaf77

First use the definitions of unit vectors
$$\hat e_r = \frac{\frac{\partial \vec r}{\partial r}}{ \left | \frac{\partial \vec r}{\partial r} \right |}, \hat e_\theta = \frac{\frac{\partial \vec r}{\partial \theta}}{ \left | \frac{\partial \vec r}{\partial \theta} \right |}, \;\; \hat e_\phi = \frac{\frac{\partial \vec r}{\partial \phi}}{ \left | \frac{\partial \vec r}{\partial \phi} \right |}$$
to arrive at a system of linear equations relating the unit vectors in spherical and in Cartesian coordinates. Then define an arbitrary vector $\mathbf{A}$ written in spherical coordinate, $\mathbf{A} = A_r \hat{e}_r + A_\theta \hat{e}_\theta + A_\phi \hat{e}_\phi$. Substitute the spherical coordinate unit vectors in terms of the Cartesian unit vectors using the relations you just derived.

3. Jan 11, 2016

### TheArun

Which relation to use to find the partial derivatives for finding each unit vectors?
Is it r^2 = x^2 + y^2 + z^2 ?

4. Jan 11, 2016

### blue_leaf77

$\mathbf{r}$ is a position vector, thus $\mathbf{r} = x\hat{e}_x + y\hat{e}_y + z\hat{e}_z$. Then express $x$, $y$, and $z$ in terms of $r$, $\theta$, and $\phi$.

5. Jan 11, 2016

### TheArun

Sorry, Iam not able to reach a such relations. Can u please tell what the relations are?

6. Jan 11, 2016

### blue_leaf77

Which relations can you not reach? If you mean the definitions of unit vectors in post #2, as I hinted before, $\mathbf{r}$ is a position vector. Taking derivative like $\frac{\partial \mathbf{r}}{\partial r}$ is done by simply substituting the component-expanded expression of $\mathbf{r}$ as given in post #4 into the derivative. Thus
$$\frac{\partial \mathbf{r}}{\partial r} = \frac{\partial}{\partial r} \left( x\hat{e}_x + y\hat{e}_y + z\hat{e}_z \right)$$
First try to calculate $\frac{\partial \mathbf{r}}{\partial r}$ and let's see what you will get.

7. Jan 11, 2016

### TheArun

Ya thanks.
So here is what i have done,
Taking r = rcos@cos# ex + rsin@sin# ey + rcos@ ez
I calculated the partials with respect to r, @ and # from these.

r/∂r = cos@cos# ex + sin@sin# ey + cos@ ez
|∂r/∂r| = √cos2@cos2# +sin2sin2# + cos2@

Likewise, i have arrived at the partials and magnitude of other components...
As the next step, i guess i have to substitute this into the A vector expression you have mentioned in post#2 after finding unit vector er,e@, and e#...i hope im not missing anything?

8. Jan 11, 2016

### blue_leaf77

Check again whether there should be sine or cosine.
After incorporating the correction I suggested above, you should get a simple answer for the magnitude.
Yes.
Then group the resulting terms according to the Cartesian unit vectors they contain.

9. Jan 11, 2016

### TheArun

So here is what i got after grouping the terms acc to cartesian unit vectors...whats next?
A = (Arsin@cos# + A@cos@cos# - A#sin#) ex + (Arsin@sin# + A@cos@sin# + A#cos#) ey + (Arcos@ -A@sin@) ez

Edit: Thanks i was able to complete the solution myself. Thanks for providing me hints and making me do it myself!

Can u also explain the meaning of unit vector in a particular direction being equal to derivative of the vector in that direction divided by the magnitude of that derivative
ie., er = ∂r/∂r / |∂r/∂r|

Thanks a lot for your help. I was not able to find the derivation of that transformation matrix from my books and couldnt find it online too..

Last edited: Jan 11, 2016
10. Jan 11, 2016

### blue_leaf77

Please check again the terms marked as red.

11. Jan 11, 2016

### TheArun

I was actually studying this inorder to find the spherical coordinates representation of the 'laplacian' of a vector( scalar electric potential)...how to reach into that form for here?
laplacian ∇2V = Vxx +Vyy + Vzz
must be converted to ∇2V = 1/r2 ∂/∂r(r2∂V/∂r) + ...

Last edited: Jan 11, 2016
12. Jan 11, 2016

### TheArun

Yeah checked it again from a book where only the matrix is given. The transformation matrix is actually same as that comes from the above expression.

13. Jan 11, 2016

### blue_leaf77

If you follow the derivation I suggested above, you will find something different. Could you possibly confuse the matrix transformation for the unit vectors with that of the components in that book? The two transformation matrices indeed look alike except for the third column.

14. Jan 11, 2016

### TheArun

I followed the method u suggested only but still getting the same expression.
Here are equations cocerning the relevant terms:
dr/d# =-rsin#sin@ ex +rsin@cos# ey + 0 ez
|dr/d#| = rsin@
which gives,
e# = -sin# ex +cos# ey
And the matrix is,

[Ax] [sin@cos# cos@cos# -sin#] [Ar]
[Ay] = [sin@sin# cos@sin# cos#] [A@]
[Az] [cos@ -sin# 0] [A#]

15. Jan 11, 2016

### blue_leaf77

Sorry, my bad. I was switching to a different definition of unit vectors without realizing that it is different than the one I was previously using for writing the equations in post #2. So, you are correct.
If you fix two coordinates among $(r,\theta,\phi)$ and let the last one varies, you will get the so-called "space curve" or the more technical term "3D curve". For example fix $r$ and $\theta$, then you will get a space curve $\mathbf{r}(\phi)$ which forms a circle of radius $r\sin \theta$ "floating" horizontally above the $xy$ plane at a height of $r\cos\theta$. Now, define a vector $\mathbf{u} = \frac{d \mathbf{r}}{d s}$, where $ds = r\sin\theta d\phi$ is an element of arc length along the circle. Vector $\mathbf{u}$ is tangent to the circle, and its explicit expression is
$$\mathbf{u} = \frac{d \mathbf{r}}{d s} = \frac{1}{r\sin\theta} \frac{d \mathbf{r}}{d\phi }$$
But $r\sin\theta$ is the length of the vector $\frac{d \mathbf{r}}{d\phi }$ itself. Therefore one can write
$$\mathbf{u} = \frac{\frac{d\mathbf{r}}{d\phi}}{ \left | \frac{d\mathbf{r}}{d\phi} \right |}$$
Because $\mathbf{u}$ is tangent to the circle at any given point and it has unit length, this vector must be the unit vector in the direction of increasing $\phi$.
Such a task is of course doable but tedious. I suggest that you read "Mathematical Methods for Physics and Engineering" by K. F. Riley, Hobson, and Bence subchapter 10.10.