# Is there an easy way to transform unit vectors from spherical to Cartesian coordinates? [duplicate]

Is there a built-in function on Mathematica that will transform unit vectors from one coordinate system to another? I have a vector expressed in spherical coordinates, and I would like to find the Cartesian components of the vector, but still express those Cartesian components using $(r,\theta,\phi)$. The transformation I am trying to generate is listed below:

$$\hat{x}=\sin\theta\cos\phi\,\hat{r}+\cos\theta\cos\phi\,\hat{\theta}-\sin\phi\,\hat{\phi}$$ $$\hat{y}=\sin\theta\sin\phi\,\hat{r}+\cos\theta\sin\phi\,\hat{\theta}+\cos\phi\,\hat{\phi}$$ $$\hat{z}=\cos\theta\,\hat{r}-\sin\theta\,\hat{\theta}$$

The above uses the physics convention where $\theta$ is the polar angle. So basically I would like Mathematica to automatically generate a matrix which looks like this:

$$\left(\begin{array}{ccc} \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{array}\right)$$

If I act this matrix on my vector (expressed in spherical coordinates) I will get what I want. Of course I could just type this matrix in myself, but that is not very elegant... The JacobianMatrix command is close, but not quite what I am looking for.

• I would suggest opening up the Wolfram Documentation and search for "Changing Coordinate Systems" for functions and tutorials. – bobthechemist Feb 25 '15 at 16:21
• The answer to this question is part of the answer to the following: How to change coordinates of a differential operator?, so I think this is a duplicate. – Jens Feb 25 '15 at 17:14

CoordinateTransformData[

• I set r = 1 just to conform to your example. You can just use r. – Taiki Feb 25 '15 at 16:22