# How do I get this transformation matrix?

I've just started taking a robotics course and I am having a little problem. I need to rotate the $O_i-1$ coordinate system into a position, where $X_i-1$ will be parallel with $X_i$.

The transformation matrix is given, but I have no idea how I can figure out this transformation matrix from the picture that can be found below.

Actually, I know why the last vector is [0 0 0 1] and the previous vector is [0 0 1 0], but I can't figure out why the first vector is [$\cos q_i$ $\sin q_i$ 0 0] and the second [$-\sin q_i$ $\cos q_i$ 0 0].