Recall the dot product formula $\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| \, |\mathbf{b}| \cos \theta$, which is often used to find angles between two vectors $\mathbf{a}$ and $\mathbf{b}$. If we want to find the angle $\mathbf{a}$ makes with the $x$-axis, then we can use the direction vector of the $x$-axis $\mathbf{i} = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}$.
Let $\mathbf{a} = \begin{pmatrix} x \\ y \\ z \end{pmatrix}$ and $\theta_x$ be the angle $\mathbf{a}$ makes with the $x$-axis. The dot product formula then gives us $$ \begin{pmatrix} x \\ y \\ z \end{pmatrix} \cdot \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix} = \left | \begin{pmatrix} x \\ y \\ z \end{pmatrix} \right | \, \left | \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix} \right | \cos \theta_x$$ Simplifying gives us $\cos \theta_x = \displaystyle \frac{x}{\sqrt{x^2+y^2+z^2}}$. We call $\cos \theta_x$ the direction cosine of $\mathbf{a}$ with respect to the $x$-axis and denote it by $\alpha$.
If we repeat the process for the $y$- and $z$-axis, denoting the angles by $\theta_y$ and $\theta_z$ and the direction cosines by $\beta$ and $\gamma$, we get:
It can be easily checked that the three direction cosines satisfy the formula
This means that, once we have two of the direction cosines, we can determine the last one (up to a $\pm$) and can thus deduce the original vector itself. This is illustrated in the second example below.
Solution to examples
Solution:
Direction cosine with respect to the $x$-axis, $\alpha = \frac{-1}{\sqrt{14}} $
Direction cosine with respect to the $y$-axis, $\beta = \frac{2}{\sqrt{14}} $
Direction cosine with respect to the $z$-axis, $\gamma = \frac{3}{\sqrt{14}} $ .
Solution: Since $\alpha^2+\beta^2 + \gamma^2 = 1,$
$\frac{4}{6} + \frac{1}{6} + \gamma^2 = 1$
Hence $\gamma = \pm \frac{1}{\sqrt{6}}$.
Thus $\mathbf{b} = \begin{pmatrix} 2 \\ -1 \\ 1 \end{pmatrix}$ or $\mathbf{b} = \begin{pmatrix} 2 \\ -1 \\ -1 \end{pmatrix}$