I have a problem calculating the corners of a rotated rectangle.

For the calculation I use a rotation matrix but there is somewhere a little mistake in my code.

As you can see the corners have a wrong positions but were rotated correctly.

Code:

1 2 3 4
| corners[0] = translatePoint(x, y); corners[1] = translatePoint(x + width, y); corners[2] = translatePoint(x + width, y + height); corners[3] = translatePoint(x, y + height); |

1 2 3 4 5
| private Point translatePoint(double x, double y) { double xNew = (x * Math.cos(getAngleInRadians()) - y * Math.sin(getAngleInRadians())); double yNew = (x * Math.sin(getAngleInRadians()) + y * Math.cos(getAngleInRadians())); return new Point(xNew, yNew); } |

(x,y) is the left top corner of the unrotated rectangle.

Thank you for your help!