# Direction ratio of a vector in 3d?

Suppose I have a vector whose starting end is the origin & the other end can be in any of the 8 quadrants (in 3d).

I can easily get direction ratios for the vector & also know in which quadrant the vector ends (from ($x$, $y$, $z$) value of end point).

From this I think we can calculate the inclination of the vector with the three axes. but it gets very complicated because $\cos(A) = \cos(-A)$ & $\cos(A) = -\cos(\pi + A)$. I just want the inclination of the vector with positive direction of $x$-, $y$- and $z$-axis.

Actually I am needing this in my software project. so, it would be kind if u could provide me with a general formula or algorithm. Thank you.

-
If $v=(x,y,z)$ is the given vector, then the angles $\alpha$, $\beta$ and $\gamma$ between $v$ and, respectively, the positive $x$-, $y$- and $z$-axis verify the following equations $$\begin{equation*} \cos \alpha =\frac{x}{r},\quad \cos \beta =\frac{y}{r},\quad \cos \gamma =\frac{z}{r},\end{equation*}$$ where $r=\sqrt{x^{2}+y^{2}+z^{2}}$. You can then compute $\tan \alpha$, $\tan \beta$ and $\tan \gamma$. – Américo Tavares Mar 25 '12 at 15:00