Rotate and transforming in one step

120 Views Asked by At

This comes from a programming problem from CodeAbbey, however, I cannot figure out the mathematical formula to solve the problem. Within the problem here we have a graph, then the same graph afterwards with all the points SHIFTED and ROTATED by an ambiguous amount, with some going off the graph as well, with only ONE point that does NOT go off the graph not following the same pattern

I know that there is a rotation formula: $$\begin{bmatrix}x'\\y'\end{bmatrix} =\begin{bmatrix}\cos \theta &-\sin \theta \\\sin \theta &\cos \theta \end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}. $$ (from Wikipedia's Rotation Article)

I also know you can easily solve tranformation: Simply calculate the change within distance...

However, when you are given only the before and afterimage of what points exist following both rotation and transformation (rather than one step at a time), how do I do this? Plug in distances into the rotation formula? Guess and check? Is there an easier way to do this?

1

There are 1 best solutions below

4
On

Given any translation (shift) followed by a rotation, you can achieve the same effect using just a rotation, although it will usually be a rotation around a different center. (If you combine the transformations in the other order, rotation then translation, they have the same effect as a mere rotation around yet another center.)

If you can identify the "before" and "after" locations of two points that undergo the same transformation(s), and if you know the coordinates of those points accurately enough, you (usually) can find the center and angle of an equivalent rotation as follows.

Find the perpendicular bisector of the line segment between the "before" and "after" locations of one of the points. The center of the rotation is on this line. Now find the perpendicular bisector of the segment between the "before" and "after" locations of the other point. The intersection of the two bisectors is the center of the rotation.

Now that you have the center of the (combined) rotation, you can determine the angle of rotation by constructing the segments from the center of rotation to the "before" and "after" images of a point and measuring the angles between those segments. If the center of the rotation is the point $(h,k)$ and the angle is $\theta$, the entire transformation then is described by this formula:

$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{bmatrix} \begin{bmatrix} x - h \\ y - k \end{bmatrix} + \begin{bmatrix} h \\ k \end{bmatrix}. $$

If it is really necessary to find one rotation around $(0,0)$ and one translation that have this same effect when one is followed by the other, they can be obtained through a little algebra. (The exact answer depends on whether you want the translation to occur before the rotation or after.)

This does not work when you happen to pick two points such that both pairs of "before" and "after" locations have the same perpendicular bisector. In that case you don't find the center of the rotation, only a line it is on. If the lines are distinct but the angle between them is small, theoretically you can find the center of the rotation but any inaccuracies in the coordinates of the points is likely to be magnified. A better choice is two points whose "motions" are nearly perpendicular to each other.