Moving rotated shape

68 Views Asked by At

I have a rotated shape (by α) in a graphic scene. My task is to move its starting point(blue dot) to the red position.

enter image description here

Now, because the shape is rotated, it is not just simply adding (400;150) to its starting point. When I move the shape 'up' by 150 and 'right' by 400, it will move on the its own X and Y axis.

How could I move this shape to the position of red P?

Sorry for my very poor explanation.

1

There are 1 best solutions below

0
On BEST ANSWER

To perform a translation with respect to the global coordinate axes (instead of the rotated local coordinate axes), premultiply the rotation matrix* you used to rotate the shape by a homogeneous transformation matrix that performs only the desired translation (and no rotation).

On the other hand, postmultiplication of your initial rotation matrix* by the pure translation homogeneous transformation matrix mentioned above would perform translation with respect to the local (rotated) coordinate axes.

*expressed as a homogeneous transformation matrix