To calculate the angle you have to know two things:

1. Dot product of two vectors...

$\vec{a} \cdot \vec{b}$

Which is

$(a_{x} + a_{y} + a_{z}) \times (b_{x} + b_{y} + b_{z})$

2. The magnitude of the vectors...

$\parallel \vec{a} \parallel$

Which is

$\sqrt{a_{x}^{2} + a_{y}^{2} + a_{z}^{2}}$

Then you can compute the cosinus of the angle, which is reversible...

$\cos(\theta) = \frac{\vec{a} \cdot \vec{b}} { ||\vec{a}|| \times ||\vec{b}||}$

---

In 2D space it is much more simple:

$\cos(\theta) = \vec{a} \cdot \vec{b}$