For those who don’t know, MS Paint only has the options to rotate an image by right angles. To carry out an arbitrary rotation (θ∘), the following hack is suggested:

Horizontal skew by θ

Vertical Stretch by 1cos2θ

Vertical Skew by −θ

Horizontal and Vertical Stretch by cosθ

I would like to know how this works.

(I guess one way would be to show that multiplying the above operations represented as matrices should return the 2D rotation matrix, but I do not know what are the matrix representations for the intermediate steps.)

**Answer**

I think the following matrix product gives an explanation.

The first step is given by the matrix

S1=(1tanθ01).

The second step corresponds to

D1=(1001cos2θ).

The second shearing operation corresponds to

S2=(10−tanθ1).

At this point we have done S2D1S1 that after a little bit of matrix manipulation and using the identity sin2θ+cos2θ=1 becomes

S2D1S1=(1tanθ−tanθ1).

The last step amounts to a scalar multiplication by cosθ and gives us the familiar rotation matrix

cosθS2D1S1=(cosθsinθ−sinθcosθ).

Edit: I got to use this as an exercise in a freshman course that just ended. I was actually a bit unhappy with that youtube video, because it doesn’t show the transitions from one step to the other. To fix this problem I made an animation, where the four steps are done gradually: in steps one and three I continuously move the shear (skew) parameter from zero to the desired value. Similarly in steps two and four the scaling parameter changes continuously from one to the proper value. All the steps are done sequentially.

**Attribution***Source : Link , Question Author : kuch nahi , Answer Author : Jyrki Lahtonen*