# How to project 3D vector on unit sphere to 2D in $xz$ plane?

I'm trying to use Python to do something that I thought would be simple geometry, but I don't understand the math behind what I'm computing.

I want to project a 3D vector on the unit sphere to 2D on the xz plane, and then compute the 2D projected angle of the projected vector on the xz plane (say, relative to the z-axis). I already know the spherical angles $\theta$ (the 3D polar angle relative to z-axis) and $\phi$ (the 3D azimuthal angle, relative to the x-axis for the 3D vector projected onto the xy plane).

I was told that the 2D projected angle $\psi$ (in the xz plane, relative to the z-axis) can be computed via

tan($\psi$) = tan($\theta$)cos($\phi$)

but it's not obvious to me how to derive that. How do I verify that formula?

• Is what you're looking for the angle that the projected vector makes with the $z$ axis? – user438666 May 7 '18 at 18:59
• @user438666 yes exactly! – quantumflash May 7 '18 at 19:04

Say your point has coordinates $(x,y,z) = (r \sin\theta \cos \phi, r \sin \theta \sin \phi, r \cos \theta)$. Then, $$\tan \psi = \frac{x}{z} = \frac{r \sin \theta \cos \phi}{r \cos \theta} = \tan \theta \cos \phi$$
• @quantumflash Orthogonal projection onto the $x$-$z$ plane simply sets $y$ to zero. – amd May 7 '18 at 19:44
• @quantumflash No. Once you’ve eliminated the $y$ coordinate, you’re just working in two dimensions, with the $z$- and $x$-axes playing the roles of the 2-D $X$- and $Y$-axes, respectively. – amd May 7 '18 at 19:49