Let xc, yc be the coordinates of the center of the rectangle.
-
Translate your points such that the center is the new origin:
xt = x1 - xc; yt = y1 - yc;
-
Rotate around the origin by the angle a:
c = cos(a); // compute trig. functions only once s = sin(a); xr = xt * c - yt * s; yr = xt * s + yt * c;
-
Translate points back:
x2 = xr + xc; y2 = yr + yc;
If you do this for all 4 corners of the rectangle and then draw lines between the transformed corners, you get the rotated rectangle. The rotation angle a is measured from the x-axis ( 0 ) to to the y-axis ( π/2 ). In 2D graphic libraries the x-axis goes to the right and the y-axis goes down, such that the angle +35∘ corresponds to your figure.