**3D Transformations in Computer Graphics-**

We have discussed-

- Transformation is a process of modifying and re-positioning the existing graphics.
- 3D Transformations take place in a three dimensional plane.

In computer graphics, various transformation techniques are-

In this article, we will discuss about 3D Rotation in Computer Graphics.

**3D Rotation in Computer Graphics-**

In Computer graphics, 3D Rotation is a process of rotating an object with respect to an angle in a three dimensional plane. |

Consider a point object O has to be rotated from one angle to another in a 3D plane.

Let-

- Initial coordinates of the object O = (X
_{old}, Y_{old}, Z_{old}) - Initial angle of the object O with respect to origin = Φ
- Rotation angle = θ
- New coordinates of the object O after rotation = (X
_{new}, Y_{new}, Z_{new})

In 3 dimensions, there are 3 possible types of rotation-

- X-axis Rotation
- Y-axis Rotation
- Z-axis Rotation

**For X-Axis Rotation-**

This rotation is achieved by using the following rotation equations-

- X
_{new}= X_{old} - Y
_{new}= Y_{old}x cosθ – Z_{old}x sinθ - Z
_{new}= Y_{old}x sinθ + Z_{old}x cosθ

In Matrix form, the above rotation equations may be represented as-

**For Y-Axis Rotation-**

This rotation is achieved by using the following rotation equations-

- X
_{new}= Z_{old}x sinθ + X_{old}x cosθ - Y
_{new}= Y_{old} - Z
_{new}= Y_{old}x cosθ – X_{old}x sinθ

In Matrix form, the above rotation equations may be represented as-

**For Z-Axis Rotation-**

This rotation is achieved by using the following rotation equations-

- X
_{new}= X_{old}x cosθ – Y_{old}x sinθ - Y
_{new}= X_{old}x sinθ + Y_{old}x cosθ - Z
_{new}= Z_{old}

In Matrix form, the above rotation equations may be represented as-

**PRACTICE PROBLEMS BASED ON 3D ROTATION IN COMPUTER GRAPHICS-**

**Problem-01:**

Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y and Z axis and find out the new coordinate points.

**Solution-**

Given-

- Old coordinates = (X
_{old}, Y_{old}, Z_{old}) = (1, 2, 3) - Rotation angle = θ = 90º

**For X-Axis Rotation-**

Let the new coordinates after rotation = (X_{new}, Y_{new}, Z_{new}).

Applying the rotation equations, we have-

- X
_{new}= X_{old}= 1 - Y
_{new}= Y_{old}x cosθ – Z_{old}x sinθ = 2 x cos90° – 3 x sin90° = 2 x 0 – 3 x 1 = -3 - Z
_{new}= Y_{old}x sinθ + Z_{old}x cosθ = 2 x sin90° + 3 x cos90° = 2 x 1 + 3 x 0 = 2

Thus, New coordinates after rotation = (1, -3, 2).

**For Y-Axis Rotation-**

Let the new coordinates after rotation = (X_{new}, Y_{new}, Z_{new}).

Applying the rotation equations, we have-

- X
_{new}= Z_{old}x sinθ + X_{old}x cosθ = 3 x sin90° + 1 x cos90° = 3 x 1 + 1 x 0 = 3 - Y
_{new}= Y_{old}= 2 - Z
_{new}= Y_{old}x cosθ – X_{old}x sinθ = 2 x cos90° – 1 x sin90° = 2 x 0 – 1 x 1 = -1

Thus, New coordinates after rotation = (3, 2, -1).

**For Z-Axis Rotation-**

Let the new coordinates after rotation = (X_{new}, Y_{new}, Z_{new}).

Applying the rotation equations, we have-

- X
_{new}= X_{old}x cosθ – Y_{old}x sinθ = 1 x cos90° – 2 x sin90° = 1 x 0 – 2 x 1 = -2 - Y
_{new}= X_{old}x sinθ + Y_{old}x cosθ = 1 x sin90° + 2 x cos90° = 1 x 1 + 2 x 0 = 1 - Z
_{new}= Z_{old}= 3

Thus, New coordinates after rotation = (-2, 1, 3).

To gain better understanding about 3D Rotation in Computer Graphics,

**Next Article-****3D Scaling in Computer Graphics**

Get more notes and other study material of **Computer Graphics**.

Watch video lectures by visiting our YouTube channel **LearnVidFun.**