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:
Similar Reads
Computer Graphics - 3D Scaling Transformation
Prerequisite: Computer Graphics â 3D Translation Transformation Scaling Transformation : It is performed to resize the 3D-object that is the dimension of the object can be scaled(alter) in any of the x, y, z direction through Sx, Sy, Sz scaling factors. Matrix representation of Scaling transformatio
3 min read
Computer Graphics - 3D Shearing Transformation
Shearing transformation is the same as we see in 2D space, but here we have to deal with the x, y, and z axes whereas in 2D we deal with the only x and y axes. Shearing is the process of slanting an object in 3D space either in x, y, or in the z-direction. Shearing changes(or deformed) the shape of
4 min read
Computer Graphics - Reflection Transformation in 3D
Reflection in 3D space is quite similar to the reflection in 2D space, but a single difference is there in 3D, here we have to deal with three axes (x, y, z). Reflection is nothing but a mirror image of an object. Three kinds of Reflections are possible in 3D space: Reflection along the X-Y plane.Re
3 min read
Computer Graphics - 3D Translation Transformation
3-D Transformation: In very general terms a 3D model is a mathematical representation of a physical entity that occupies space. In more practical terms, a 3D model is made of a description of its shape and a description of its color appearance.3-D Transformation is the process of manipulating the vi
3 min read
Composite Transformation in 2-D graphics
Prerequisite - Basic types of 2-D Transformation :Â Â TranslationScalingRotationReflectionShearing of a 2-D objectComposite Transformation :Â As the name suggests itself Composition, here we combine two or more transformations into one single transformation that is equivalent to the transformations th
3 min read
Computer Graphics - 3D Composite Transformation
3-D Transformation is the process of manipulating the view of a three-D object with respect to its original position by modifying its physical attributes through various methods of transformation like Translation, Scaling, Rotation, Shear, etc. Types of Transformation: Translation TransformationScal
6 min read
Computer Graphics Rotation
Rotation is one of the part of computer graphic's transformation, Transformation means to change some graphics into something else with the help of rules. There are various types of transformations like translation, scaling, rotation, shearing, reflection etc. it helps to change the object's positio
3 min read
Translation of objects in computer graphics
In computer graphics, we have seen how to draw some basic figures like line and circles. In this post we will discuss on basics of an important operation in computer graphics as well as 2-D geometry, which is transformation. In computer graphics, transformation of the coordinates consists of three m
7 min read
Projections in Computer Graphics
Representing an n-dimensional object into an n-1 dimension is known as projection. It is process of converting a 3D object into 2D object, we represent a 3D object on a 2D plane {(x,y,z)->(x,y)}. It is also defined as mapping or transforming of the object in projection plane or view plane. When g
5 min read
C++ Implementation of Scaling in Computer Graphics
In terms of computer graphics, Scaling is a process used for altering the size of objects. It changes the coordinate point of the original object. Modifying the object's size with the help of the object's dimension is dependent on the scaling factor(S). The scaling factor determines whether the obje
2 min read