# 2D Shearing in Computer Graphics

--

We can denote shearing with **‘SHx’ **and** ‘SHy.’ **These ‘**SHx’ **and** ‘SHy’ **are called** “Shearing factor.”**

We can perform shearing on the object in two ways-

**Shearing along x-axis:**In this, wecan store the y coordinate and only change the x coordinate. It is also called**“Horizontal Shearing.”**

We can represent Horizontal Shearing by the following equation-

**X1 = X0 + SHx. Y0**

**Y1 = Y0**

**We can represent Horizontal shearing in the form of matrix**–

**Homogeneous Coordinate Representation: **The 3 x 3 matrix for Horizontal Shearing is given below-

**2**. **Shearing along y-axis: **In this, wecan store the x coordinate and only change the y coordinate. It is also called **“Vertical Shearing.”**

We can represent Vertical Shearing by the following equation-

**X1 = X0**

**Y1 = Y0 + SHy. X0**

**We can represent Vertical Shearing in the form of matrix**–

**Homogeneous Coordinate Representation: **The 3×3 matrix for Vertical Shearing is given below-

**Example: **A Triangle with (2, 2), (0, 0) and (2, 0). Apply Shearing factor 2 on X-axis and 2 on Y-axis. Find out the new coordinates of the triangle?

**Solution:** We have,

The coordinates of triangle = P (2, 2), Q (0, 0), R (2, 0)

Shearing Factor for X-axis = 2

Shearing Factor for Y-axis = 2

Now, apply the equation to find the new coordinates.

**Shearing for X-axis:**

**For Coordinate P (2, 2)-**

Let the new coordinate for P = (X1, Y1)

X1 = X0 + SHx. Y0 = 2 + 2 x 2 = 6

Y1 = Y0 = 2

**The New Coordinates = (6, 2)**

**For Coordinate Q (0, 0)-**

Let the new coordinate for Q = (X1, Y1)

X1 = X0 + SHx. Y0 = 0 + 2 x 0 = 0

Y1 = Y0 = 0

**The New Coordinates = (0, 0)**

**For Coordinate R (2, 0)-**

Let the new coordinate for R = (X1, Y1)

X1 = X0 + SHx. Y0 = 2 + 2 x 0 = 2

Y1 = Y0 = 0

**The New Coordinates = (2, 0)**

The New coordinates of triangle for x-axis = (6, 2), (0, 0), (2, 0)

**Shearing for y-axis:**

**For Coordinate P (2, 2)-**

Let the new coordinate for P = (X1, Y1)

X1 = X0 = 2

Y1 = Y0 + Shy.X0 = 2 + 2 x 2 = 6

**The New Coordinates = (2, 6)**

**For Coordinate Q (0, 0)-**

Let the new coordinate for Q = (X1, Y1)

X1 = X0 = 0

Y1 = Y0 +Shy. X0 = 0 + 2 x 0 =0

**The New Coordinates = (0, 0)**

**For Coordinate R (2, 0)-**

Let the new coordinate for R = (X1, Y1)

X1 = X0 = 2

Y1 = Y0 + Shy. X0 = 0 +2 x 2 = 4

**The New Coordinates = (2, 4)**

The New coordinates of triangle for y-axis = (2, 6), (0, 0), (2, 4)