**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 Shearing in Computer Graphics.

**3D Shearing in Computer Graphics-**

In Computer graphics, 3D Shearing is an ideal technique to change the shape of an existing object in a three dimensional plane. |

In a three dimensional plane, the object size can be changed along X direction, Y direction as well as Z direction.

So, there are three versions of shearing-

- Shearing in X direction
- Shearing in Y direction
- Shearing in Z direction

Consider a point object O has to be sheared in a 3D plane.

Let-

- Initial coordinates of the object O = (X
_{old}, Y_{old}, Z_{old}) - Shearing parameter towards X direction = Sh
_{x} - Shearing parameter towards Y direction = Sh
_{y} - Shearing parameter towards Z direction = Sh
_{z} - New coordinates of the object O after shearing = (X
_{new}, Y_{new}, Z_{new})

**Shearing in X Axis-**

Shearing in X axis is achieved by using the following shearing equations-

- X
_{new}= X_{old} - Y
_{new}= Y_{old}+ Sh_{y}x X_{old} - Z
_{new}= Z_{old}+ Sh_{z}x X_{old}

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

**Shearing in Y Axis-**

Shearing in Y axis is achieved by using the following shearing equations-

- X
_{new}= X_{old}+ Sh_{x}x Y_{old} - Y
_{new}= Y_{old} - Z
_{new}= Z_{old}+ Sh_{z}x Y_{old}

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

**Shearing in Z Axis-**

Shearing in Z axis is achieved by using the following shearing equations-

- X
_{new}= X_{old}+ Sh_{x}x Z_{old} - Y
_{new}= Y_{old}+ Sh_{y}x Z_{old} - Z
_{new}= Z_{old}

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

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

**Problem-01:**

Given a 3D triangle with points (0, 0, 0), (1, 1, 2) and (1, 1, 3). Apply shear parameter 2 on X axis, 2 on Y axis and 3 on Z axis and find out the new coordinates of the object.

**Solution-**

Given-

- Old corner coordinates of the triangle = A (0, 0, 0), B(1, 1, 2), C(1, 1, 3)
- Shearing parameter towards X direction (Sh
_{x}) = 2 - Shearing parameter towards Y direction (Sh
_{y}) = 2 - Shearing parameter towards Y direction (Sh
_{z}) = 3

**Shearing in X Axis-**

**For Coordinates A(0, 0, 0)**

Let the new coordinates of corner A after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}= 0 - Y
_{new}= Y_{old}+ Sh_{y}x X_{old}= 0 + 2 x 0 = 0 - Z
_{new}= Z_{old}+ Sh_{z}x X_{old}= 0 + 3 x 0 = 0

Thus, New coordinates of corner A after shearing = (0, 0, 0).

**For Coordinates B(1, 1, 2)**

Let the new coordinates of corner B after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}= 1 - Y
_{new}= Y_{old}+ Sh_{y}x X_{old }= 1 + 2 x 1 = 3 - Z
_{new}= Z_{old}+ Sh_{z}x X_{old}= 2 + 3 x 1 = 5

Thus, New coordinates of corner B after shearing = (1, 3, 5).

**For Coordinates C(1, 1, 3)**

Let the new coordinates of corner C after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}= 1 - Y
_{new}= Y_{old}+ Sh_{y}x X_{old}= 1 + 2 x 1 = 3 - Z
_{new}= Z_{old}+ Sh_{z}x X_{old}= 3 + 3 x 1 = 6

Thus, New coordinates of corner C after shearing = (1, 3, 6).

Thus, New coordinates of the triangle after shearing in X axis = A (0, 0, 0), B(1, 3, 5), C(1, 3, 6).

**Shearing in Y Axis-**

**For Coordinates A(0, 0, 0)**

Let the new coordinates of corner A after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Y_{old}= 0 + 2 x 0 = 0 - Y
_{new}= Y_{old}= 0 - Z
_{new}= Z_{old}+ Sh_{z}x Y_{old}= 0 + 3 x 0 = 0

Thus, New coordinates of corner A after shearing = (0, 0, 0).

**For Coordinates B(1, 1, 2)**

Let the new coordinates of corner B after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Y_{old}= 1 + 2 x 1 = 3 - Y
_{new}= Y_{old}= 1 - Z
_{new}= Z_{old}+ Sh_{z}x Y_{old}= 2 + 3 x 1 = 5

Thus, New coordinates of corner B after shearing = (3, 1, 5).

**For Coordinates C(1, 1, 3)**

Let the new coordinates of corner C after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Y_{old}= 1 + 2 x 1 = 3 - Y
_{new}= Y_{old}= 1 - Z
_{new}= Z_{old}+ Sh_{z}x Y_{old}= 3 + 3 x 1 = 6

Thus, New coordinates of corner C after shearing = (3, 1, 6).

Thus, New coordinates of the triangle after shearing in Y axis = A (0, 0, 0), B(3, 1, 5), C(3, 1, 6).

**Shearing in Z Axis-**

**For Coordinates A(0, 0, 0)**

Let the new coordinates of corner A after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Z_{old}= 0 + 2 x 0 = 0 - Y
_{new}= Y_{old}+ Sh_{y}x Z_{old}= 0 + 2 x 0 = 0 - Z
_{new}= Z_{old}= 0

Thus, New coordinates of corner A after shearing = (0, 0, 0).

**For Coordinates B(1, 1, 2)**

Let the new coordinates of corner B after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Z_{old}= 1 + 2 x 2 = 5 - Y
_{new}= Y_{old}+ Sh_{y}x Z_{old}= 1 + 2 x 2 = 5 - Z
_{new}= Z_{old}= 2

Thus, New coordinates of corner B after shearing = (5, 5, 2).

**For Coordinates C(1, 1, 3)**

Let the new coordinates of corner C after shearing = (X_{new}, Y_{new}, Z_{new}).

Applying the shearing equations, we have-

- X
_{new}= X_{old}+ Sh_{x}x Z_{old}= 1 + 2 x 3 = 7 - Y
_{new}= Y_{old}+ Sh_{y}x Z_{old}= 1 + 2 x 3 = 7 - Z
_{new}= Z_{old}= 3

Thus, New coordinates of corner C after shearing = (7, 7, 3).

Thus, New coordinates of the triangle after shearing in Z axis = A (0, 0, 0), B(5, 5, 2), C(7, 7, 3).

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

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

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