2

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.

Charlie
  • 53
  • 7

1 Answers1

5
CoordinateTransformData[
    "Spherical" -> "Cartesian", 
    "OrthonormalBasisRotation",
    {1, θ, φ}
] // MatrixForm
shrx
  • 7,807
  • 2
  • 22
  • 55
Taiki
  • 5,259
  • 26
  • 34