We are learning how to work with different coordinate systems in my Mechanics class (spherical and cylindrical mainly), and about form factors, general formulas for the gradient, the curl, the divergence, the Laplacian and general knowledge related to vector calculus in curvilinear coordinates. My problem is that I have worked (that is, solved problems which required extensive computation) very little with any coordinate system other than Cartesian, and I need to straighten this out before I start solving problems in spherical or cylindrical coordinates.
My doubt is the following. Suppose we want to construct a transformation matrix to convert a certain 3D vector $\vec{a}=(a_x,a_y,a_z)$ from spherical coordinates to Cartesian coordinates. (I will use the convention $(r,\theta,\phi)$ for spherical coordinates: radial distance, polar angle and azimuthal angle). A possibility would be to find out the expression for the unit vectors of the spherical coordinate system $(e_r,e_\theta,e_\phi)$ in Cartesian coordinates:
$$\hat{e_r}=\sin\theta \cos \phi \hat{i}+ \sin \theta \sin \phi \hat{j}+\cos\theta\hat{k}$$ $$\hat{e_\theta}=\cos\theta \cos \phi \hat{i}+ \cos \theta \sin \phi \hat{j}-\sin\theta\hat{k}$$ $$\hat{e_\phi}=-\sin\phi \hat{i}+ \cos \phi \hat{j}$$
And then construct a matrix $A$ given by:
$$\begin{bmatrix} \hat{e_r}\cdot\hat{i} & \hat{e_r}\cdot\hat{j} & \hat{e_r}\cdot\hat{k} \\ \hat{e_\theta}\cdot\hat{i} & \hat{e_\theta}\cdot\hat{j} & \hat{e_\theta}\cdot\hat{k} \\ \hat{e_\phi}\cdot\hat{i} & \hat{e_\phi}\cdot\hat{j} & \hat{e_\phi}\cdot\hat{k} \\ \end{bmatrix}$$
Which equals to
$$\begin{bmatrix} \sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta \\ \cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta \\ -\sin\phi & \cos\phi & 0 \end{bmatrix}$$
This is all class material, I haven't said anything we haven't learned in class. I also know that, since in both coordinate systems the unit vectors are orthogonal, the matrix for the inverse conversion ($A^{-1}$) equals to the transposed matrix ($A^t$). So, the matrix for converting from Cartesian to Spherical could be easily computed from $A$.
Here are my questions. How do formulas like $r=\sqrt{x^2+y^2+z^2}$, or $\phi=\arctan(\frac{y}{x})$ relate to these matrices? If given a point like $(1,\pi/2,\pi/2)_{spherical}$ I know you have the info to go from spherical to Cartesian using the matrix, but how could you go backwards (let's say from $(0,1,0)_{Cartesian}$) by using a matrix comprised of trigonometric functions?
Thanks everyone very much.