I have a transformation in Java:
AffineTransform transform = new AffineTransform();
transform.translate(x, y);
transform.rotate(Math.toRadians(rotation));
transform.translate(-x, -y);
I’m using it on four points that make up a rectangle. The transformation rotates around the origin (x, y) as expected, but I want the most left point to stay where the origin x was, and the most top point to stay where the origin y was.
Any ideas how to modify the transformation to achieve this?
I solved this by searching through all the points, finding the extreme left point, and the extreme upper point, and then offsetting all the points in the transformation by these coordinates. It’s really messy though, so if anyone happens to have a better solution, I’m all ears.