See also: Why is my image rotation algorithm not working?
This question isn\'t language specific, and is a math problem. I will however use
Note there's another solution apart from rotation matrices, that doesn't loose image information through aliasing. You can separate 2D image rotation into skews and scalings, which preserve the image quality.
Here's a simpler explanation