0% found this document useful (0 votes)
68 views7 pages

2D Transformations in Computer Graphics

The document outlines an assignment for a Computer Graphics Lab course, focusing on implementing various transformations (translation, shear, rotation, and scaling) on geometric shapes like triangles and rhombuses. It explains the importance of 2D transformations and the use of homogeneous coordinates for efficient computation. Additionally, it includes theoretical explanations, transformation matrices, and a set of oral questions related to the topic.

Uploaded by

abhinavsargar1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views7 pages

2D Transformations in Computer Graphics

The document outlines an assignment for a Computer Graphics Lab course, focusing on implementing various transformations (translation, shear, rotation, and scaling) on geometric shapes like triangles and rhombuses. It explains the importance of 2D transformations and the use of homogeneous coordinates for efficient computation. Additionally, it includes theoretical explanations, transformation matrices, and a set of oral questions related to the topic.

Uploaded by

abhinavsargar1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

Regularity Content Viva-voce Timely Total Dated Sign of


submission Subject Teacher
2 4 2 2 10

Date of Performance:..................................... Date of Completion:.............................

----------------------------------------------------------------------------------------------------------------

Assignment No: 4
----------------------------------------------------------------------------------------------------------------

Title of the Assignment: Implement translation, shear, rotation and scaling transformations
on equilateral triangle and rhombus.
----------------------------------------------------------------------------------------------------------------
Objective of the Assignment: To understand the concept of transformation.
---------------------------------------------------------------------------------------------------------------
Prerequisite:
1. Library function of OpenGL
2. Graphical Characteristics of triangle and rhombus.
---------------------------------------------------------------------------------------------------------------

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

Theory:
4.1 2D transformation:

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. Transformations play an important role in computer graphics to reposition
the graphics on the screen and change their size or orientation.

4.2 Need of Homogeneous Coordinate System:

To perform a sequence of transformation such as translation followed by rotation and


scaling, we need to follow a sequential process −

Translate the coordinates,


Rotate the translated coordinates, and then
Scale the rotated coordinates to complete the composite transformation.

To shorten this process, we have to use 3×3 transformation matrix instead of 2×2
transformation matrix. To convert a 2×2 matrix to 3×3 matrix, we have to add an extra
dummy coordinate W.

In this way, we can represent the point by 3 numbers instead of 2 numbers, which is called
Homogenous Coordinate system. In this system, we can represent all the transformation
equations in matrix multiplication. Any Cartesian point P(X, Y) can be converted to
homogenous coordinates by P’ (Xh, Yh, h).

4.3 2D transformation matrices for:


a. Translation
b. Shear (x Shear and Y Shear)
c. Rotation about origin( Anti clock wise)
d. Scaling

a. Translation:

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

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’).

X’ = X + tx
Y’ = Y + ty
The pair (tx, ty) is called the translation vector or shift vector. The above equations can also
be represented using the column vectors.

We can write it as −

P’ = P + T

b. Shear (x Shear and Y 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.

Fig 4.1 Original object & Object after X-shear


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

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

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.

Fig 4.2 Original object & Object after Y-shear

c. Rotation about origin( Anti clock wise)

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’).

Representing the above equation in matrix form,

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

Where R is the rotation matrix

The rotation angle can be positive and negative.

d. 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, SY),
and the produced coordinates are (X’, Y’). This can be mathematically represented as
shown below −

X' = X . SX and Y' = Y . SY

The scaling factor SX, SY scales the object in X and Y direction respectively. The
above equations can also be represented in matrix form as below –

Composite Transformations:

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

If a transformation of the plane T1 is followed by a second plane transformation T2, then the
result itself may be represented by a single transformation T which is the composition of T1 and
T2 taken in that order. This is written as T = T1∙T2.

Composite transformation can be achieved by concatenation of transformation matrices to obtain


a combined transformation matrix.

A combined matrix −

[T][X] = [X] [T1] [T2] [T3] [T4] …. [Tn]

Where [Ti] is any combination of

Translation
Scaling
Shearing
Rotation
Reflection

4.4 Conclusion:
One of the most common and important tasks in computer graphics is to transform the
coordinates ( position, orientation, and size ) of either objects within the graphical
scene or the camera that is viewing the scene. It is also frequently necessary to
transform coordinates from one coordinate system to another, ( e.g. world coordinates
to viewpoint coordinates to screen coordinates. ) All of these transformations can be
efficiently and succintly handled using some simple matrix representations, which we
will see can be particularly useful for combining multiple transformations into a single
composite transform matrix

4.5 Oral Questions:


1. What is the matrix for scaling?
2. What is the matrix for translation?
3. What is the matrix for rotation (clockwise & anticlockwise)?
4. What is the matrix for shear (x-shear, y-shear)?
5. What is matrix for relection (about X-axis and Y-axis)?

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS


Department of Information Technology Subject : Computer Graphics Lab (2018-19 SEM-II)

SNJB’s Late Sau. K B Jain College of Engineering, Chandwad Dist. Nashik, MS

You might also like