How do I calculate the angles between a point on a sphere and each unit vector in $\Bbb R ^3$?

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?

• how about taking the dot product with each vector in the standard basis? – abel Jun 10 '15 at 15:24
• I think the word you are looking for is "octant". – OnceUponACrinoid Jun 10 '15 at 15:31

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$).

• Then how do I determine the angle between 0 and $2\pi$? Is there any other way than 1.) determining in which octant of the sphere give point lies. 2.) Adjusting said angle accordingly ? – matthiasdv Jun 10 '15 at 15:44
• You've blown my mind. Again. – matthiasdv Jun 10 '15 at 15:59
• @fauxnoir: I have deleted my previous comment as it was somewhat sloppily formulated. Let me try again: imagine two vectors with a common endpoint (visualize them as two arrows stemming from some point); they will form two angles. By definition, the angle between them will be the smaller one; since these two angles sum up to $2 \pi$, the smaller one necessarily will be in $[0, \pi]$. – Alex M. Jun 10 '15 at 21:26

Suppose you have some point $p$ on your sphere. And the vector from the origin to that point is represented by:

$$\vec{p}=\begin{pmatrix}p_1 \\ p_2\\p_3\end{pmatrix}$$

If you want to know the angle between that vector $\vec{p}$ and any other vector $\vec{x}$, you can use the dot product:

$$\vec{p} \cdot \vec{x}=\lvert p\rvert \lvert q\rvert \cos \alpha$$

where $\alpha$ represents the angle between $\vec{p}$ and $\vec{x}$. Solving for $\alpha$:

$$\alpha=\cos^{-1}(\frac{\vec{p} \cdot \vec{x}}{\lvert p\rvert \lvert q\rvert})$$

Hope this helps.