Given the Cartesian coordinates of any point $p$ on the surface of a sphere in $\Bbb R ^3$, how do I calculate the angles between each axis $(x, y, z)$ and the vector $n$ defined by origin $o$ and $p$.
For convenience sake I'll say that origin $o$ equals $(0,0,0)$ so that $n = p$
I begun my attempt by calculating the direction cosines, but now that I want to calculate the angles using inverse cosines, I realize that a sphere has eight octants and that cosines have 2 angles in some of them.
Is there a more elegant way to solve this? And if so, how do I approach this?
Compute the scalar product and divide by the norms of the vectors: in your case, this would be $\frac 1 {\| p \|} (p_x x + p_y y + p_z z)$ (assuming $\|(x,y,z)\| = 1$). This gives you the cosine of the angle you are looking for, so now apply $\arccos$ and that is your angle (between $0$ and $\pi$).