Skip to content
Related Articles

Related Articles

Improve Article

Reflection In 2D Graphics

  • Last Updated : 12 Oct, 2020

Reflection deals with obtaining a mirror image of the 2D object. 

About x-axis: 
If P(x, y) is the point on x-y plane then P’(x’, y’) is the reflection about x-axis given as x’=x ; y’=-y 

 

Matrix Form: 



 

\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}1&0\\0&-1\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix} \\P'=P.R_x

About y-axis : 
If P(x, y) is the point on x-y plane then P’(x’, y’) is the reflection about y-axis given as x’=-x ; y’=y 

 

 

\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix} \\P'=P.R_y

Along origin : 
If P(x, y) is the point on x-y plane then P’(x’, y’) is the reflection about origin given as x’=-x ; y’=-y 



 

 

\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&-1\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix} \\P'=P.R_xy

About x=y line : To do this move x=y line to any of the axis. In the given diagram the angle of rotation is 45o as the points are plotted as (0, 0), (1, 1), (2, 2), and so on. 

 

Imposing the line clockwise (-45o) imposing it on the x-axis we have, 
 

R_{\theta-}=\begin{bmatrix}\cos\theta&\sin\theta\\-\sin\theta&\cos\theta\end{bmatrix}=\begin{bmatrix}\cos(-45)&\sin(-45)\\-\sin(-45)&\cos(-45)\end{bmatrix}

We know, 
 



\cos(-\theta)=\cos\theta

and 
 

\sin(-\theta)=-\sin\theta

 

\\R_{\theta-}=\begin{bmatrix}\cos(45)&-\sin(45)\\ \sin(45)&\cos(45)\end{bmatrix}

Now perform reflection along x-axis, 
 

R_x=\begin{bmatrix}1&0\\0&-1\end{bmatrix}

Now rotate the line back 45o in an anticlockwise direction, 
 

R_{\theta+}=\begin{bmatrix}\cos(45)&\sin(45)\\-\sin(45)&\cos(45)\end{bmatrix}

Now if P(x, y) is the point on x-y plane then P’(x’, y’) is the reflection about x=y line given as x’=y ; y’=x  
Matrix Form: 
 



\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}x&y\end{bmatrix}.\begin{bmatrix}R_{\theta-}\end{bmatrix}.\begin{bmatrix}R_x\end{bmatrix}.\begin{bmatrix}R_{\theta+}\end{bmatrix} \\\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}x&y\end{bmatrix}\begin{bmatrix}1&0\\0&-1\end{bmatrix}

Problem: A triangle is given with the coordinates p (5 4), q (2 2), r (5 6) we need to reflect it along Y-axis.

Ans: We are given with coordinate p, q, r as shown in figure-

Triangle reflection in 2-d graphics

Now, we apply the condition of reflecting a 2-d object along Y-axis:

\begin{bmatrix}x'&y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}*\begin{bmatrix}x\\y\end{bmatrix} \\P'=P.R_y

First coordinate p, becomes p’ after reflection:

\begin{bmatrix}x&y\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}*\begin{bmatrix}5\\4\end{bmatrix}\\\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-5\\4\end{bmatrix}

Second coordinate q, becomes q’ after reflection:

\begin{bmatrix}x&y\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}*\begin{bmatrix}2\\2\end{bmatrix}\\\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-2\\2\end{bmatrix}

Third coordinate r of the triangle becomes r’ after reflection:

\begin{bmatrix}x&y\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}*\begin{bmatrix}5\\6\end{bmatrix}\\\begin{bmatrix}\\x'\\y'\end{bmatrix}=\begin{bmatrix}-5\\6\end{bmatrix}

After reflecting the triangle about the Y-axis point p, q, r becomes p’, q’, r’ :

p(5, 4) = p'(-5, 4) , q(2, 2) 
= q'(-2, 2) , r(5, 6) 
= r'(-5, 6) 

The reflecting object would appear as :




My Personal Notes arrow_drop_up
Recommended Articles
Page :