# Converting cartesian coordinates into latitude and longitude coordinates

I'm trying to convert a position vector on a unit sphere into the latitude and longitude coordinates but I'm not sure how to do it. I know that the formula for converting the latitude and longitude coordinates into cartesian coordinate is: $$V_n=\begin{pmatrix} R\cos(\lambda_n) \cos(\phi_n) \\ R\sin(\lambda_n) \cos(\phi_n) \\ R\sin(\phi_n) \end{pmatrix}$$ where $$\lambda$$ represents the longitude and $$\phi$$ represents the latitude.

Could I get some advice on how to convert cartesian coordinates into latitude and longitude?

Take $$V_n/R$$. The last element, $$z/R=\sin\phi_n$$, can be used to get $$\phi_n$$. You can use $$\arcsin$$ function, since $$\phi_n$$ is between $$-\pi/2$$ and $$\pi/2$$ in radians. You might need to convert to degrees, so the answer will be between $$-90^\circ$$ and $$90^\circ$$. For $$\lambda_n$$, take the ratio of $$y$$ and $$z$$ components, and you can see that you get $$\tan\lambda_n$$. To get the answer in a $$360^\circ$$ range, use the $$\mathrm{arctan2}$$ function