2
$\begingroup$

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.

$\endgroup$
2
  • 2
    $\begingroup$ I would suggest opening up the Wolfram Documentation and search for "Changing Coordinate Systems" for functions and tutorials. $\endgroup$ Commented Feb 25, 2015 at 16:21
  • $\begingroup$ 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. $\endgroup$
    – Jens
    Commented Feb 25, 2015 at 17:14

1 Answer 1

5
$\begingroup$
CoordinateTransformData[
    "Spherical" -> "Cartesian", 
    "OrthonormalBasisRotation",
    {1, θ, φ}
] // MatrixForm
$\endgroup$
4
  • $\begingroup$ Thanks for the fast reply! Your solution is close, but not quite right -- the third column is not quite right. $\endgroup$
    – Charlie
    Commented Feb 25, 2015 at 16:21
  • $\begingroup$ I set r = 1 just to conform to your example. You can just use r. $\endgroup$
    – Taiki
    Commented Feb 25, 2015 at 16:22
  • $\begingroup$ Sorry. Now the third column is right. $\endgroup$
    – Taiki
    Commented Feb 25, 2015 at 19:05
  • $\begingroup$ Taiki,Thank you very much. This works great. I can even put {r,[Theta],[CurlyPhi]} in there and it works. -Charlie $\endgroup$
    – Charlie
    Commented Feb 25, 2015 at 19:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.