Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Transformation in Computer Graphics

Transformation in Computer Graphics is utilized to modify the position, orientation, or size of objects within a graphical scene. By employing mathematical operations, vertices or points in a 3D or 2D space are manipulated to achieve the desired changes.

Download Transformation in Computer Graphics Notes PDF Download PDF

In this article, we cover Transformation in Computer Graphics explaining 2d Transformation, rotation, translation, scaling, reflection, shearing and the difference between 2d and 3d Transformation.

What is 2d Transformation in Computer Graphics?

2d Transformation in Computer Graphics is utilized to modify the position, orientation, or size of objects within a two-dimensional space. These transformations involve applying mathematical operations to the coordinates of points or vertices in order to achieve the desired changes.

These transformations can be applied in a sequence to achieve more complex effects. For example, a combination of translation, rotation, and scaling operations can be used to animate an object’s movement, rotation, and resizing in a 2D animation.

The various 2d Transformation in Computer Graphics examples include object manipulation, computer-aided design (CAD), image processing, and graphical user interfaces (GUIs). By manipulating the position, orientation, and size of objects within a 2D space, these transformations enable a wide range of visual effects and graphical applications.

The fundamental geometrical 2d Transformation in Computer Graphics include:

  • Rotation
  • Translation
  • Scaling

The derived geometrical 2d Transformation in Computer Graphics are:

  • Reflection
  • Shearing

2D Rotation in Computer Graphics

2D rotation is a fundamental concept that involves changing the orientation of an object or a coordinate system in a 2D plane. It enables us to rotate graphical elements around a specified point or axis by a certain angle.

Transformation in Computer Graphics Image 1

To perform a 2D rotation, we need to consider two key components: the rotation angle and the rotation center. The rotation angle, denoted as θ (in radians), represents the amount of rotation to be applied. The rotation center, represented as (cx, cy), defines the point around which the rotation will occur.

The original coordinates of points P, A, and B can be represented using standard trigonometric functions.

Transformation in Computer Graphics Image 2

Similarly, the points P’, A’, and B’ can be represented as follows:

Transformation in Computer Graphics Image 3

Upon substituting equations (1) and (2) into equations (3) and (4) correspondingly, we obtain the following expressions:

Transformation in Computer Graphics Image 4

In matrix form, the above equation can be represented as follows:

Transformation in Computer Graphics Image 5

P′ = P . R

Where R is the rotation matrix, the equation can be represented in matrix form as follows:

Transformation in Computer Graphics Image 6

The above matrix can be used in the case of a rotation angle which is positive, however for a rotation angle which is negative, the matrix is shown below:

Transformation in Computer Graphics Image 7

Transformation in Computer Graphics Image 8

2D Translation

2D Translation is a transformation technique that changes the position of each point in an object or a coordinate system by a specified distance in the x and y axes. Transformation in Computer Graphics Image 9 Applying 2D translation, we can say:

X’ = X + tx

Y’ = Y + ty

(tx, ty) represents the shift or the translation vector. The equations can be expressed using column vectors for efficient representation and computation.

P=[X]/[Y] p’ = [X′]/[Y′] T = [tx]/[ty]

This can also be written as:

P’ = P + T

2D Scaling in Computer Graphics

2D Scaling in Computer Graphics involves resizing objects or coordinate systems in a 2D plane. It allows us to change the size of each point in the object or coordinate system by applying scaling factors in the x and y directions.

To perform 2D scaling, we utilize scaling factors: sx for the x-axis and sy for the y-axis. These factors determine how much each coordinate should be scaled along its respective axis.

If the scaling factor (SX and SY) is greater than 1, the object is enlarged and moves away from the origin. A scaling factor of 1 leaves the object unchanged, while a scaling factor less than 1 shrinks the object and moves it closer to the origin.

The equations for scaling are X’ = X * SX and Y’ = Y * SY, where X and Y are the original coordinates of a point, and X’ and Y’ are the scaled coordinates after the transformation.

These equations can also be represented in matrix form as:

Transformation in Computer Graphics Image 10

OR

P’ = P . S

The scaling process is depicted using the scaling matrix S in the given figure:

Transformation in Computer Graphics Image 11

Transformation in Computer Graphics Image 12

2D Reflection in Computer Graphics

2D reflection is a transformation technique that involves flipping or mirroring an object or coordinate system across a specific axis in a 2D plane. It allows us to change the orientation of each point in the object or coordinate system in relation to the reflection axis.

The figures depict the X and Y axes and the origin:

Transformation in Computer Graphics Image 13

2D Shearing in Computer Graphics

2D Shearing transformation slants or distorts an object or coordinate system along either the x-axis or y-axis in a 2D plane. It involves shifting the position of points in a specific direction based on their original coordinates.

To shear the given image along the x-axis, we use the shearing parameter shx.

Transformation in Computer Graphics Image 14

The equation will be:

X’= X + Y.shx

Y’ = X

The shearing matrix along with the x-axis is:

Transformation in Computer Graphics Image 15

The shearing matrix along with the y-axis is:

To shear the provided image along the Y-axis, we utilize the shearing parameter shy.

Transformation in Computer Graphics Image 16

The equation is now:

Y’= X.shy + Y

X’ = X

The shearing matrix along with the x-axis is:

Transformation in Computer Graphics Image 17

Difference between 2d and 3d Transformation in Computer Graphics

The difference between 2D and 3D transformations in computer graphics lies in the dimensionality of the space in which the transformations are applied. The prime difference between 2d and 3d Transformation in Computer Graphics are listed in the table below:

2D Transformations

3D Transformations

Dimension

Two-dimensional space (x and y axes)

Three-dimensional space (x, y, and z axes)

Representation

Objects are represented on a flat surface (e.g., a computer screen)

Objects are represented in a 3D environment

Types

Translation, rotation, scaling, shearing, reflection

Translation, rotation, scaling, shearing, reflection, perspective projection, etc.

Coordinates Affected

Only x and y coordinates

x, y, and z coordinates

Depth

No depth information (z-coordinate is constant)

Depth information allows objects with volume and depth

Realism

Limited to flat, 2D representations

Enables more realistic 3D graphics and animations

Applications

GUIs, image processing, 2D animations, CAD

3D modeling, animation, virtual reality, simulations, game development.

The Transformation in Computer Graphics can be combined and applied in a specific order to achieve more complex effects. They serve as fundamental operations in computer graphics, enabling the manipulation of objects, creation of animations, simulation of virtual environments, and various other graphical tasks.

Frequently Asked Questions on Transformation in Computer Graphics

Q1

What is Transformation in Computer Graphics?

Transformation in computer graphics involves modifying objects’ position, orientation, or size using mathematical operations.

Q2

What is 2D Transformation in Computer Graphics?

2D transformations modify objects in a 2D space, including translation, rotation, scaling, reflection, and shearing, while 3D transformations operate in a 3D environment, adding depth and realism.

Q3

What are the fundamental 2D Transformations in Computer Graphics?

The fundamental 2D transformations in computer graphics are translation (moving objects in a specific direction), rotation (changing orientation around a point or axis), and scaling (resizing objects by applying scaling factors to coordinates).

Q4

What are some examples of 2d Transformation in Computer Graphics?

Some examples of 2D transformations in computer graphics include moving objects (translation), rotating objects around a point (rotation), scaling objects (resizing), flipping objects (reflection), and distorting objects along an axis (shearing).