Just look
here at the affine transformations
If you want to remember it EVERY time here it is how you figure it out
the basic vectors are ex(1,0) ey(0,1) and if you rotate it by angle a the new vectors are ex'(cosa,sina) ey'(-sina,cosa). To figure out the new coordinates just draw the trigonometric cycle and you will find easily the new coordinates (unfortunately i cannot draw it here)
Now the matrix
| a1 a2 |
| |*ex = ex' from there you have a1 and a3 and from
| a3 a4 |
| a1 a2 |
| |*ey = ey' from there you have a2 and a2
| a3 a4 |
basically if you name ex'T the transposed ex' vector (make the row a column) then
A = |ex'T ey'T|