I searched on internet and I saw lots of posts about how to rotate a matrix or an image by 90 or 180 degrees.But how can I rotate a matrix with 12 degrees or 162 degrees?
From:

To:

This image is rotated with ~35 degrees.
As you can see my matrix is the horse image and the circle is the rotation path, and the big rectangle is the new matrix created after rotation.
How can i achieve this? Thanks!
PS: This does not work
int angle=35*Math.PI/180;
int x1 = (int)(x * cos(angle)) - (y * sin(angle));
int y1 = (int)(y * cos(angle)) + (x * sin(angle));