0
787views
Concept of 2-D Transformation
1 Answer
0
4views

Transformation means changing some graphics into something else by applying rules. We can have various types of transformations such as translation, scaling up or down, rotation, shearing, etc. When a transformation takes place on a 2D plane, it is called 2D transformation.

Translation

A translation moves an object to a different position on the screen. You can translate a point in 2D by adding translation coordinate $(t_x, ty)$ to the original coordinate (X, Y) to get the new coordinate (X’, Y’).

enter image description here

From the above figure, you can write that -

$\mathbf{X}^{\prime}=\mathbf{X}+\mathbf{t}_{\mathbf{x}}$

$\mathbf{Y}^{\prime}=\mathbf{Y}+\mathbf{t}_{\mathbf{y}}$

We can write it as

$\mathbf{P}^{\prime}=\mathbf{P}+\mathbf{T}$

Rotation

In rotation, we rotate the object at particular angle θ (theta) from its origin. From the following figure, we can see that the point P(X, Y) is located at angle φ from the horizontal X coordinate with distance r from the origin.

Let us suppose you want to rotate it at the angle θ. After rotating it to a new location, you will get a new point P’ (X’, Y’).

enter image description here

Using standard trigonometric the original coordinate of point P(X, Y) can be represented as

$X=r \cos \phi \ldots \ldots(1)$

$Y=r \sin \phi \ldots \ldots(2)$

Same way we can represent the point P’ (X’, Y’) as -

$\mathrm{x}^{\prime}=\operatorname{rcos}(\phi+\theta)=\operatorname{rcos} \phi \cos \theta-\mathrm{r} \sin \phi \sin \theta \ldots (3)$

$\mathrm{y}^{\prime}=\operatorname{sin}(\phi+\theta)=\operatorname{rcos} \phi \sin\theta-\mathrm{r} \sin \phi \cos \theta \ldots (4)$

Substituting equation (1) & (2) in (3) and (4) respectively, we will get

$x^{\prime}=x \cos \theta-y \sin \theta$

$y^{\prime}=x \sin \theta+y \cos \theta$

Representing the above equation in matrix form,

$$\left[X^{\prime} Y^{\prime}\right]=[X Y]\left[\begin{array}{cc}{\cos \theta} & {\sin \theta} \\ {-\sin \theta} & {\cos \theta}\end{array}\right]$$

OR

$$\mathrm{P}^{\prime}=\mathrm{P} \cdot \mathrm{R}$$

Where R is the rotation matrix

$$ R=\left[\begin{array}{cc}{\cos \theta} & {\sin \theta} \\ {-\sin \theta} & {\cos \theta}\end{array}\right] $$

Scaling

To change the size of an object, scaling transformation is used. In the scaling process, you either expand or compress the dimensions of the object. Scaling can be achieved by multiplying the original coordinates of the object with the scaling factor to get the desired result.

Let us assume that the original coordinates are (X, Y), the scaling factors are $(S_X, S_Y)$, and the produced coordinates are (X’, Y’). This can be mathematically represented as shown below-

$\mathbf{X}^{\prime}=\mathbf{X} \cdot \mathbf{S}_\mathbf{x}$ and $\mathbf{Y}^{\prime}=\mathbf{Y} \cdot \mathbf{S}_\mathbf{y}$

The scaling factor $S_X, S_Y$ scales the object in X and Y direction respectively. The above equations can also be represented in matrix form as below -

$$\left(\begin{array}{l}{X^{\prime}} \\ {Y^{\prime}}\end{array}\right)=\left(\begin{array}{l}{X} \\ {Y}\end{array}\right)\left[\begin{array}{ll}{S_{x}} & {0} \\ {0} & {S_{y}}\end{array}\right]$$

OR

$$ \mathbf{P}=\mathbf{P} . \mathbf{S} $$

Where S is the scaling matrix. The scaling process is shown in the following figure.

enter image description here

If we provide values less than 1 to the scaling factor S, then we can reduce the size of the object. If we provide values greater than 1, then we can increase the size of the object.

Reflection

It is a transformation which produces a mirror image of an object. The mirror image can be either about x-axis or y-axis. The object is rotated by $180^°$

Types of Reflection

  1. Reflection about the x-axis
  2. Reflection about the y-axis
  3. Reflection about an axis perpendicular to xy plane and passing through the origin
  4. Reflection about line y=x

1. Reflection about x-axis: The object can be reflected about x-axis with the help of the following matrix

$$\left[\begin{array}{ccc}{1} & {0} & {0} \\ {0} & {-1} & {0} \\ {0} & {0} & {1}\end{array}\right]$$

In this transformation value of x will remain same whereas the value of y will become negative. Following figures shows the reflection of the object axis. The object will lie another side of the x axis.

enter image description here

2. Reflection about y-axis: The object can be reflected about y-axis with the help of following transformation matrix.

$$\left[\begin{array}{ccc}{-1} & {0} & {0} \\ {0} & {1} & {0} \\ {0} & {0} & {1}\end{array}\right]$$

enter image description here

3. Reflection about an axis perpendicular to xy plane and passing through origin: In the matrix of this transformation is given below

$\left[\begin{array}{ccc}{-1} & {0} & {0} \\ {0} & {-1} & {0} \\ {0} & {0} & {1}\end{array}\right]$

enter image description here

In this value of x and y both will be reversed. This is also called as half revolution about the origin.

4. Reflection about line y=x: The object may be reflected about line y = x with the help of following transformation matrix.

enter image description here

Here the values of x will be reversed, whereas the value of y will remain the same. The object will lie another side of the y-axis.

The following figure shows the reflection about the y-axis

$$\left[\begin{array}{lll}{0} & {1} & {0} \\ {1} & {0} & {0} \\ {0} & {0} & {1}\end{array}\right]$$

5. Reflection About An Arbitrary Line

Reflection about any line y= mx + c can be accomplished with a combination of translate rotate-reflect transformations. Steps are as follows

  1. Translate the working coordinate system (WCS) so that the line passes through the origin.
  2. Rotate the WCS such that one of the coordinate axis lies onto the line.
  3. Reflect about the aligned axis
  4. Restore the WCS back by using the inverse rotation and translation transformation.

Shear

A transformation that slants the shape of an object is called the shear transformation. There are two shear transformations X-Shear and Y-Shear. One shifts X coordinates values and other shifts Y coordinate values. However; in both the cases only one coordinate changes its coordinates and other preserves its values. Shearing is also termed as Skewing.

X-Shear

The X-Shear preserves the Y coordinate and changes are made to X coordinates, which causes the vertical lines to tilt right or left as shown in below figure.

enter image description here

The transformation matrix for X-Shear can be represented as -

$$X_{s h}=\left[\begin{array}{ccc}{1} & {0} & {0} \\ {\operatorname{sh} x} & {1} & {0} \\ {0} & {0} & {1}\end{array}\right]$$

$$X^{\prime}=X+\operatorname{Sh}_{X} \cdot Y$$

$$Y^{\prime}=Y$$

Y-Shear

The Y-Shear preserves the X coordinates and changes the Y coordinates which causes the horizontal lines to transform into lines which slopes up or down as shown in the following figure.

enter image description here

The Y-Shear can be represented in matrix from as-

$$Y_{s h}=\left[\begin{array}{ccc}{1} & {s h y} & {0} \\ {0} & {1} & {0} \\ {0} & {0} & {1}\end{array}\right]$$

$$Y^{\prime}=Y+\operatorname{Sh}_{y} \cdot x$$

$$X^{\prime}=X$$

Please log in to add an answer.