A vector in 2-dimensional space:
$$\mathbf{a} = (a_1, a_2), \text{ in }\mathbb{R}^2$$
It's magnitude is defined by the root of the sum of the squares of it's components:
$$ \begin{aligned} \lvert\lvert{\mathbf{a}}\lvert\lvert &= \sqrt{(a_1)^2 + (a_2)^2}\\ \end{aligned} $$
A sample:
A vector in 2-dimensional space:
$$\mathbf{a} = (a_1, a_2), \text{ in }\mathbb{R}^2$$
It's direction cosine is defined by the vector of lenght 1 in the same direction is the original vector:
$$\mathbf{v} = (\frac{a_1}{\lvert\lvert{\mathbf{a}}\lvert\lvert}, \frac{a_2}{\lvert\lvert{\mathbf{a}}\lvert\lvert})$$
A sample: