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:

$${}$$

You can drag the red dot to see how the length changes by changing the vector endpoint

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:

$${}$$

You can drag the red dot to see how the direction vector changes by changing the vector endpoint