I am trying to create an Illustrator style selection box for geometric objects in java.

When an object is selected, a border is drawn, and you can drag small rectangles to resize the object. I would also like to be able to rotate the window by dragging it.
While I can scale the box, and I can rotate the box, but I can not do these two together. Imagine the box is at an angle of 45 degrees. When you drag an angle to enlarge the window in the x direction, it will increase the width and height of the window due to the angle.
I can make it work using:
dx = dx*cos(theta) - dy*sin(theta); dy = dy*cos(theta) + dx*sin(theta);
But this only works when the pivot point is in the upper left corner. I want to be able to move the axis of rotation, and then scale and rotate. This problem had to be solved many times before. Is there a way that I can use affine transformation to transform the mouse into the coordinate space of a rotated object? I would rather not delve into trigonometry! Thanks in advance.
source share