Composite Transformation in 2-D graphics
Prerequisite – Basic types of 2-D Transformation :
Composite Transformation :
As the name suggests itself Composition, here we combine two or more transformations into one single transformation that is equivalent to the transformations that are performed one after one over a 2-D object.
Example :
Consider we have a 2-D object on which we first apply transformation T1 (2-D matrix condition) and then we apply transformation T2(2-D matrix condition) over the 2-D object and the object get transformed, the very equivalent effect over the 2-D object we can obtain by multiplying T1 & T2 (2-D matrix conditions) with each other and then applying the T12 (resultant of T1 X T2) with the coordinates of the 2-D image to get the transformed final image.
Problem :
Consider we have a square O(0, 0), B(4, 0), C(4, 4), D(0, 4) on which we first apply T1(scaling transformation) given scaling factor is Sx=Sy=0.5 and then we apply T2(rotation transformation in clockwise direction) it by 90*(angle), in last we perform T3(reflection transformation about origin).
Ans : The square O, A, C, D looks like :

Square_given(Fig.1)
First, we perform scaling transformation over a 2-D object :
Representation of scaling condition :
For coordinate O(0, 0) : ![Rendered by QuickLaTeX.com O\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}0.5&0\\0&0.5\end{bmatrix}*\begin{bmatrix}0\\0\end{bmatrix}\\\\[1ex]O\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-9239e2812aa04726aaa25bc0f7c496b7_l3.png)
For coordinate B(4, 0) : ![Rendered by QuickLaTeX.com B\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}0.5&0\\0&0.5\end{bmatrix}*\begin{bmatrix}4\\0\end{bmatrix}\\\\[1ex]B\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}2\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-1d6d6b8d64b9a9194195e9ce2140e1e2_l3.png)
For coordinate C(4, 4) : ![Rendered by QuickLaTeX.com C\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}0.5&0\\0&0.5\end{bmatrix}*\begin{bmatrix}4\\4\end{bmatrix}\\\\[1ex]C\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}2\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-249a9f25b97f63cfba493ac3802c1a7a_l3.png)
For coordinate D(0, 4) : ![Rendered by QuickLaTeX.com D\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}0.5&0\\0&0.5\end{bmatrix}*\begin{bmatrix}0\\4\end{bmatrix}\\\\[1ex]D\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-dafdc4df5f487c81a4c203f4da4fc2dc_l3.png)
2-D object after scaling :

Fig.2
*Now, we’ll perform rotation transformation in clockwise-direction on Fig.2 by 90θ:
The condition of rotation transformation of 2-D object about origin is :
For coordinate O(0, 0) : ![Rendered by QuickLaTeX.com O\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&1\\-1&0\end{bmatrix}*\begin{bmatrix}0\\0\end{bmatrix}\\\\[1ex]O\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-8740ed087701f3ce398b335299627933_l3.png)
For coordinate B(2, 0) : ![Rendered by QuickLaTeX.com B\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&1\\-1&0\end{bmatrix}*\begin{bmatrix}2\\0\end{bmatrix}\\\\[1ex]B\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\-2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-e7f35253c4fb6aee12938f21431e4fab_l3.png)
For coordinate C(2, 2) : ![Rendered by QuickLaTeX.com C\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&1\\-1&0\end{bmatrix}*\begin{bmatrix}2\\2\end{bmatrix}\\\\[1ex]C\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}2\\-2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-8b78d52bda514f6ab43f58932a7a55b2_l3.png)
For coordinate D(0, 2) : ![Rendered by QuickLaTeX.com D\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&1\\-1&0\end{bmatrix}*\begin{bmatrix}0\\2\end{bmatrix}\\\\[1ex]D\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}2\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-ecba0668932cbbb328e74174cae068a6_l3.png)
2-D object after rotating about origin by 90* angle :

Fig.3
*Now, we’ll perform third last operation on Fig.3, by reflecting it about origin :
The condition of reflecting an object about origin is
For coordinate O(0, 0) : ![Rendered by QuickLaTeX.com O\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&-1\end{bmatrix}*\begin{bmatrix}0\\0\end{bmatrix}\\\\[1ex]O\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-088a48b8b3992714fb34cd14b42307a4_l3.png)
For coordinate B'(0, 0) : ![Rendered by QuickLaTeX.com B'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&-1\\-1&0\end{bmatrix}*\begin{bmatrix}0\\2\end{bmatrix}\\\\[1ex]B'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-2\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-0b8202f778ded8e91429128f4fee45fa_l3.png)
For coordinate C'(0, 0) : ![Rendered by QuickLaTeX.com C'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&-1\end{bmatrix}*\begin{bmatrix}2\\-2\end{bmatrix}\\\\[1ex]C'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-2\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-2e030f22127cf3bf4522d3d76d07f211_l3.png)
For coordinate D'(0, 0) : ![Rendered by QuickLaTeX.com D'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&-1\end{bmatrix}*\begin{bmatrix}0\\-2\end{bmatrix}\\\\[1ex]D'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-fa606e19a2242f4569fe8af659c73f22_l3.png)
The final 2-D object after reflecting about origin, we get :

Fig.4
Note : The above finale result of Fig.4, that we get after applying all transformation one after one in a serial manner. We could also get the same result by combining all the transformation 2-D matrix conditions together and multiplying each other and get a resultant of multiplication(R). Then, applying that 2D-resultant matrix(R) at each coordinate of the given square(above). So, you will get the same result as you have in Fig.4.
Solution using Composite transformation :
*First we multiplied 2-D matrix conditions of Scaling transformation with Rotation transformation :
![Rendered by QuickLaTeX.com \begin{bmatrix}R_1\end{bmatrix}=\begin{bmatrix}0.5&0\\0&0.5\end{bmatrix}*\begin{bmatrix}0&1\\-1&0\end{bmatrix}\\\\[1ex]\begin{bmatrix}\\R_1\end{bmatrix}=\begin{bmatrix}0&0.5\\-0.5&0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-fc06ff59b45aec3a1b211b5f00afc5a0_l3.png)
*Now, we multiplied Resultant 2-D matrix(R1) with the third last given Reflecting condition of transformation(R2) to get Resultant(R) :
![Rendered by QuickLaTeX.com \begin{bmatrix}R\end{bmatrix}=\begin{bmatrix}0&0.5\\-0.5&0\end{bmatrix}*\begin{bmatrix}-1&0\\0&-1\end{bmatrix}\\\\[1ex]\begin{bmatrix}\\R\end{bmatrix}=\begin{bmatrix}0&-0.5\\0.5&0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-3702a7fb6fa94e918a50902daaa208ce_l3.png)
Now, we’ll applied the Resultant(R) of 2d-matrix at each coordinate of the given object (square) to get the final transformed or modified object.
First transformed coordinate O(0, 0) is : ![Rendered by QuickLaTeX.com O\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&-0.5\\0.5&0\end{bmatrix}*\begin{bmatrix}0\\0\end{bmatrix}\\\\[1ex]O\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-0ceec7e6792efb2480348cbaa6343a0e_l3.png)
Second, transformed coordinate B'(4, 0) is : ![Rendered by QuickLaTeX.com B'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&-0.5\\0.5&0\end{bmatrix}*\begin{bmatrix}4\\0\end{bmatrix}\\\\[1ex]B'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}0\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-7c5b550ae29ae7e9f52628fc76b315c4_l3.png)
Third transformed coordinate C'(4, 4) is : ![Rendered by QuickLaTeX.com C'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&-0.5\\0.5&0\end{bmatrix}*\begin{bmatrix}4\\4\end{bmatrix}\\\\[1ex]C'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-2\\2\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-3a896885609690c5a5d593d222b868cd_l3.png)
Fourth transformed coordinate D'(0, 4) is : ![Rendered by QuickLaTeX.com D'\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}0&-0.5\\0.5&0\end{bmatrix}*\begin{bmatrix}0\\4\end{bmatrix}\\\\[1ex]D'\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-2\\0\end{bmatrix}](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-a6b4c5371a89ee47e5abe1b8e03adb8c_l3.png)
The final result of the transformed object that you get would be same as above :




![Rendered by QuickLaTeX.com \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}cosθ&sinθ\\-sinθ&cosθ\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix}\\\\[1ex] Cos90 = 0 \\ sin90=1](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-8bfaaf61941ba27ae54a0dedbbb875ac_l3.png)
![Rendered by QuickLaTeX.com \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&-1\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix}\\\\[1ex]](https://web.archive.org/web/20221116223709im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-25d20077701c3efca8bb06909f27af60_l3.png)

Please Login to comment...