I am trying to place the cutting handles on the four corners of a rectangle, which you can drag to resize the rectangle. I'm having trouble calculating the new width, new height and new points of the rectangle after I dragged one of the rectangular points.
If the rectangle had not been rotated, it would obviously be very simple, because the width and height would change the same as the mouse offset X and offsetY. However, this CAN rectangle can be rotated, so offsetX and offsetY do not correspond to changes in width / height.

In the image above, I presented the information that I already have in black and the information I want to find in light gray. I tried to show how the rectangle should change if I dragged the a1 corner up and to the right.
Can someone help me figure out how to calculate the missing information?
Thanks for any help! It is very much appreciated.
-
EDIT: I have drag and drop, drag and drop end callbacks to each handle. My current code just gets a new point (in this example, a2). Unfortunately, this simply moves the handle, which we are now dragging to a new position, but obviously does not affect the width / height of the rectangle and the position of its other points. What I hope to get help with is how to calculate the new width and height, as well as the new position of the other points based on this resistance.
Handle coordinates (before dragging)
handles: { a: { x: 11, y: 31 }, b: { x: 44, y: 12 }, c: { x: 39, y: 2 }, d: { x: 6, y: 21 } };
Callbacks:
// Save the original x and original y coordinates // of the handle, before dragging onDragStart: function(x, y, handle) { handle.data({ ox: x, oy: y }); } // While dragging the handle, update it coordinates to // reflect its new position onDragMove: function(dx, dy, handle) { handle.attr({ x: handle.data('ox') + dx, y: handle.data('oy') + dy }); } // Not currently using the drag end callback onDragEnd: function(x,y,handle) {}