Open In App

Computer Graphics – 3D Rotation Transformations

Improve
Improve
Like Article
Like
Save
Share
Report

Rotation in 3D is more nuanced as compared to the rotation transformation in 2D, as in 3D rotation we have to deal with 3-axes (x, y, z). 

Rotation about an arbitrary axis           

There are three kinds of arbitrary rotation, here we can rotate an object just parallel(or along) a specific axis so that the coordinate about which the object rotates, remains unchanged and the rest two of the coordinates get changes. There are three kinds of such rotations that are possible:

  • Rotation about the X-axis,
  • Rotation about the Y-axis,
  • Rotation about the Z-axis.

1) Rotation about the x-axis: In this kind of rotation, the object is rotated parallel to the x-axis (principal axis), where the x coordinate remains unchanged and the rest of the two coordinates y and z only change.  Consider a point with initial coordinate P(x,y,z) in 3D space is made to rotate parallel to the principal axis(x-axis). The coordinate position would change to P'(x,y,z). 

A rotation transformation matrix is used to calculate the new position coordinate P’, which shown as below:

\large\hspace{4cm}\R_x=\left[\begin{matrix}1&0&0&0\\ 0&cos(\theta)&sin(\theta)&0\\ 0&-sin(\theta)&cos(\theta)&0\\ 0&0&0&1\end{matrix}\right]\\ \newline \\\,\,\hspace{5cm}where\, \theta\, is\, rotation\,angle.\\            \\ \large\hspace{5cm}\mathbf{P'[x_n\,\,y_n\,\,z_n\,\,1]=P[x\,y\,z\,1].R_x}\newline \newline\hspace{5cm}X_n = X_o \hspace{2cm} \textbf{no\,\,change\,\,in\,\,x-coordinate}\\ \hspace{5cm} Y_n = Y_o\,.cosθ\,-\,Z_o\,.sinθ \newline \hspace{5cm} Z_n = Y_o\,.sinθ + Z_o\,.cosθ\\ \\\\ \hspace{3cm}\mathbf{P'[x_n\,\,y_n\,\,z_n\,\,1]\hspace{0.2cm}is\hspace{0.2cm}the\hspace{0.2cm}new\hspace{0.2cm}position\hspace{0.2cm}of\hspace{0.2cm}coordinate\hspace{0.2cm}P[x\,\,y\,\,x\,\,1].}

Rotation along x-axis


 

2) Rotation about the y-axis: In this kind of rotation, the object is rotated parallel to the y-axis (principal axis), where the y coordinate remains unchanged and the rest of the two coordinates x and z only change.


\large\hspace{4cm}\R_y=\left[\begin{matrix}cos(\theta)&0&-sin(\theta)&0\\ 0&1&0&0\\ sin(\theta)&0&cos(\theta)&0\\ 0&0&0&1\end{matrix}\right]\\ \newline \\\,\,\hspace{5cm}where\, \theta\, is\, rotation\,angle.\\ \newline \newline

Rotation along y-axis


 Consider a point with initial coordinate P(x,y,z) in 3D space is made to rotate parallel to the principal axis(y-axis). The coordinate position would change to P'(x,y,z).


\large\hspace{5cm}\mathbf{P'[x\,y\,z\,1]=P[x\hspace{0.2cm}y\hspace{0.2cm} z\hspace{0.2cm}1].R_y}\\\\ \hspace{5cm} X_n =  x_o\,.cosθ+z_o\,.sinθ \newline \hspace{5cm} Y_n = y_o \hspace{2cm} \textbf{no\,\,change\,\,in\,\,y-coordinate}\\ \newline \hspace{5cm} Z_n = z_o\,.cos(θ)\,-\,x_o\,.sin(θ)\\ \,\, \hspace{3cm}\mathbf{P'[x_n\hspace{0.2cm}y_n\hspace{0.2cm}z_n\hspace{0.2cm}1]\hspace{0.2cm}is\hspace{0.2cm}the\hspace{0.2cm}new\hspace{0.2cm}position\hspace{0.2cm}of\hspace{0.2cm}coordinate\hspace{0.2cm}P[x\hspace{0.2cm}y\hspace{0.2cm}z\hspace{0.2cm}1].} \\
 

3) Rotation about the z-axis: In this kind of rotation, the object is rotated parallel to the z-axis (principal axis), where the z coordinate remains unchanged and the rest of the two coordinates x and y only change.
\large\hspace{4cm}\R_z=\left[\begin{matrix}cos(\theta)&sin(\theta)&0&0\\ -sin(\theta)&cos(\theta)&0&0\\ 0&0&1&0\\ 0&0&0&1\end{matrix}\right]\\ \newline \\\,\,\hspace{5cm}where\, \theta\, is\, rotation\,angle. \\ \newline \newline

Rotation along z-axis


 Consider a point with initial coordinate P(x,y,z) in 3D space is made to rotate parallel to the principal axis(y-axis). The coordinate position would change to P'(x,y,z).


\large\hspace{5cm}\mathbf{P'[x_n\hspace{0.2cm}y_n\hspace{0.2cm}z_n\hspace{0.2cm}1]=P[x\hspace{0.2cm}y\hspace{0.2cm}z\hspace{0.2cm}1].R_z}\\\\ \newline \hspace{5cm} X_n = x_o\,.cosθ\,-\,y_o\,.sinθ \\ \hspace{5cm} Y_n = x_o\,.sinθ + y_o\,.cosθ \newline \hspace{5cm} Z_n = z_o \hspace{2cm} \textbf{no\,\,change\,\,in\,\,Z-coordinate}\\ \hspace{3cm}\mathbf{P'[x_n\hspace{0.2cm}y_n\hspace{0.2cm}z_n\hspace{0.2cm}1]\hspace{0.2cm}is\hspace{0.2cm}the\hspace{0.2cm}new\hspace{0.2cm}position\hspace{0.2cm}of\hspace{0.2cm}coordinate\hspace{0.2cm}P[x\hspace{0.2cm}y\hspace{0.2cm}x\hspace{0.2cm}1].}

Note: Rotation angle in Counter-clockwise direction is always considered +ve, while in the clockwise direction rotation angle is always considered -ve. It is a common convention that is always followed in 3D rotation.

Perform Rotation transformation over a cube ‘OABCDEFG’ and rotate it through 45* in the anticlockwise direction about the y-axis.

We are given with the following figure:
 

Fig.1

Now, We’ll apply Rotational transformation along(parallel to) y-axis which is: 


\large\hspace{2cm}\R_y=\left[\begin{matrix}cos(\theta)&0&-sin(\theta)&0\\ 0&1&0&0\\ sin(\theta)&0&cos(\theta)&0\\ 0&0&0&1\end{matrix}\right]\\ \hspace{4cm}where\, \theta\, is\, rotation\,angle.\\ \newline
 

Coordinate O after applying Rotational transformation, becomes:


\newline \mathbf{\large\hspace{2cm}\ O'[x\,\,y\,\,z\,\,1]=[0\hspace{0.1cm}0\hspace{0.1cm}0\hspace{0.1cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[0\hspace{0.1cm}0\hspace{0.1cm}0\hspace{0.1cm}1]} \newline \hspace{2cm}\mathbf{O'[x,y,z]=[0,0,0]} \newline
 

Coordinate A after applying Rotational transformation, becomes:


\newline \mathbf{\large\hspace{2cm}\ A'[x\,\,y\,\,z\,\,1]=[0\hspace{0.2cm}4\hspace{0.2cm}0\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[0\hspace{0.2cm}4\hspace{0.2cm}0\hspace{0.2cm}1]} \newline \textbf{Here you can see that the Y-coordinate remains unchanged, \\i.e A[0,4,0]=A'[0,4,0].} \newline
 

Coordinate B after applying Rotational transformation, becomes:


\newline \large \mathbf{\hspace{2cm}\ B'[x\,\,y\,\,z\,\,1]=[0\hspace{0.2cm}4\hspace{0.2cm}4\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[\frac{4}{\sqrt{2}}\hspace{0.2cm}4\hspace{0.2cm}\frac{4}{\sqrt{2}}\hspace{0.2cm}1]} \newline \hspace{2cm}\mathbf{B'[x,y,z]=[2\sqrt{2},4,2\sqrt{2}]} \\
 

Coordinate C after applying Rotational transformation, becomes:


\newline \large \mathbf{\hspace{2cm}\ C'[x\,\,y\,\,z\,\,1]=[4\hspace{0.2cm}4\hspace{0.2cm}0\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[\frac{4}{\sqrt{2}}\hspace{0.3cm}4\hspace{0.3cm}\frac{-4}{\sqrt{2}}\hspace{0.3cm}1]} \newline \hspace{2cm}\mathbf{C'[x,y,z]=[2\sqrt{2},4,-2\sqrt{2}]} \\
 

Coordinate D after applying Rotational transformation, becomes:


\newline \large \mathbf{\hspace{2cm}\ D'[x\,\,y\,\,z]=[4\hspace{0.2cm}4\hspace{0.2cm}4\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[(\frac{4}{\sqrt{2}}+\frac{4}{\sqrt{2}})\hspace{0.3cm}4\hspace{0.3cm}(\frac{4}{\sqrt{4}}-\frac{4}{\sqrt{2}})\hspace{0.3cm}1]}\newline \hspace{2cm}\mathbf{D'[x,y,z]=[4\sqrt{2},4,0]} \\
 

Coordinate E after applying Rotational transformation, becomes:


\newline \large {\hspace{2cm}\mathbf{ E'[x\,\,y\,\,z\,\,1]=[4\hspace{0.2cm}0\hspace{0.2cm}0\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[\frac{4}{\sqrt{2}}\hspace{0.3cm}0\hspace{0.3cm}\frac{-4}{\sqrt{2}}\hspace{0.3cm}1]}} \\ \hspace{2cm}\mathbf{E'[x,y,z]=[2\sqrt{2},0,-2\sqrt{2}]} \newline
 

Coordinate F after applying Rotational transformation, becomes:


\newline \large\mathbf{\hspace{2cm}\ F'[x\,\,y\,\,z\,\,1]=[0\hspace{0.2cm}0\hspace{0.2cm}4\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[\frac{4}{\sqrt{2}}\hspace{0.3cm}0\hspace{0.3cm}\frac{4}{\sqrt{2}}\hspace{0.3cm}1]} \newline \hspace{2cm}\mathbf{F'[x,y,z]=[2\sqrt{2},0,2\sqrt{2}]} \newline
 

Coordinate G after applying Rotational transformation, becomes:


\newline \large \mathbf{\hspace{2cm}\ G'[x\,\,y\,\,z\,\,1]=[4\hspace{0.2cm}0\hspace{0.2cm}4\hspace{0.2cm}1]\left[\begin{matrix}\frac{1}{\sqrt{2}}&0&\frac{-1}{\sqrt{2}}&0\\\\ 0&1&0&0\\\\ \frac{1}{\sqrt{2}}&0&\frac{1}{\sqrt{2}}&0\\\\ 0&0&0&1\end{matrix}\right] \hspace{0.1cm} =[(\frac{4}{\sqrt{2}}+\frac{4}{\sqrt{2}})\hspace{0.3cm}0\hspace{0.3cm}(\frac{4}{\sqrt{2}}-\frac{4}{\sqrt{2})}\hspace{0.3cm}1]} \newline \hspace{2cm}\mathbf{G'[x,y,z]=[4\sqrt{2},0,0]}\newline
 

So, the resultant cube that we get after successfully performing Rotational transformation on the cube ‘OABCDEF’ will look like:



 



Last Updated : 14 Feb, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads