0% found this document useful (0 votes)
17 views6 pages

9278 Et 5 ET

This document introduces fundamental 2D transformations in computer graphics, including Translation, Rotation, and Scaling, and explains their mathematical representations. It also discusses the concept of Homogeneous coordinates, which simplify the process of performing multiple transformations by allowing them to be represented as matrix multiplications. The advantages of using Homogeneous coordinates include reduced matrix operations and the elimination of intermediate storage requirements.
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)
17 views6 pages

9278 Et 5 ET

This document introduces fundamental 2D transformations in computer graphics, including Translation, Rotation, and Scaling, and explains their mathematical representations. It also discusses the concept of Homogeneous coordinates, which simplify the process of performing multiple transformations by allowing them to be represented as matrix multiplications. The advantages of using Homogeneous coordinates include reduced matrix operations and the elimination of intermediate storage requirements.
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
You are on page 1/ 6

MODULE - 5

e-PGPathshala
Subject: Computer Science
Paper: Computer Graphics and Visualization
Module: Basic 2D Transformations
Module No: CS/CGV/5
Quadrant 1 – e-text
Objectives:

 To get introduced to the fundamental transformations Translation, Rotation, Scaling


 To understand the use of Homogeneous coordinates that make transformations
simpler.

Discussion:
Any changes done to the properties of objects are called transformations.
Transformations can be classified as ‘Geometric’, and ‘Attribute’. Geometric Transformations
involve changes to the structural properties of objects, while attribute transformations involve
changes to color, style and so on. For Ex: consider a line, whose geometric properties are
position, size, shape, and orientation while its attributes arecolor, style (dashed, dot-dash
patterns etc.).

Basic Transformations are classified as


– Translation(change is position)
– Rotation(change in orientation)
– Scaling(change in size)
There are other transformations which are less often performed, and they are
classified as below. Many complex transformations can be broken into a series of simple or
basic transformations.
Other Transformations
– Reflection
– Shearing
– Transformations Between Coordinate Systems
The other transformations are such that they can be represented assome
combination of basic transformations.Let’s start our discussion with the first basic
transformation, the Translation.
Translation (change in position):

As shown in the diagram above, Translation involves change in position of an object.


Assume a point initially positioned at P(x,y), It is moved to a new position P’(x’,y’). To reach
point P’ from point P, the amount of horizontal distance travelled along x-axis would be (x’-x)
and the amount of vertical distance travelled along y-axis would be (y’-y). These two
distances can be called as translational distances Tx and Tyrespectively along X-axis and Y-
axis. Now we can represent the transformation, Translation in simple equations as

x’=x+Tx
y’=y+Ty

For convenience of implementation in a program, these are converted to matrix


equivalent representations as below.

The notation for Translation can be given as

P’=P+T

where P’ represents the final position of the point P and T is the translation matrix.

Rotation (change in orientation):

Let’s understand how Rotation transformation is performed. Rotation is a


transformation that is performed with respect to a pivot point by some angle.After rotation,
the object is placed at a new position. A standard rotation is generally performed with
respect to origin. We can choose any random point in space as pivot point and perform
rotation.

As shown, Let P(x,y) be the point to be rotated about origin (pivot point), by an
angle (rotation angle), so that the point P, after rotation is at P’ (x’,y’) position. Let r be the
radius vector.Here the direction from origin along P is identified as position vector of point P.
Let  be the angle between position vectors of the points P and P’. Let Øbe the angle made
by position vector of point P with X-axis. So the angle made by position vector point P’ with
X-axis will be (Ø + ). Our aim is compute the coordinates of P’ in terms of other parameters
P, r, Ø, .
By completing the triangle (by dropping perpendicular on X-axis) for the position
vector of point P, and considering the cosine of angle Ø, we have

x = r cos Ø
y = r sin Ø

By completing the triangle (by dropping perpendicular on X-axis) for the position vector of
point P’, and considering the cosine of angle Ø+, we have

x’ = r cos (Ø + )
y’ = r sin (Ø + )

After expanding for cos (Ø +) we have

x’ = r cosØcos – r sinØ sin


y’ = r cosØ sin + r sinØcos

Substituting the equations for x and y, in the above equations for x’ and y’ , we have

x’ = x cos() - y sin()
y’ = x sin() + y cos()

The matrix equivalent representation for the above equations is given by

Notational representation for this is given by

P’=R ().P
Where R() is the rotation matrix.

Important Note:θ is +ve for CCW (counter Clockwise) rotations and –ve for CW (Clockwise
rotations. If the rotations, are done about any other pivot point other than origin, the
equations would be different, which we will derive later.
_________________
Example: suppose that you have a point P (2,0) to be rotated about origin by 90° CCW, what
is the new position?
Answer: The rotation matrix is given by [ ]=[ ]

Now multiply the point (2,0) with this matrix to obtain the new position,

[ ][ ] = [ ]
Thus the new position is (2,0)
__________________
Scaling (change in size):

Consider a rectangular object (The filled blue square as shown in the middle in the
above figure), which is to be scaled.Increase in size is considered as ‘upscaling’ while
decrease in size is considered as ‘down scaling’. The farthest object is the up scaled object
and the object close to origin is the down scaled version of the original object. If you observe
scaling closely, it involves two transformations (change in size and change in position), as
evident from the figure above, the up scaled object has moved to a new position away from
the origin while the down scaled object has moved close to origin. Scaling is simply
multiplying the object with values one along X-axis and one along Y-axis, i.e.,

x’=x.Sx
y’=y.Sy

whereSx, Sy are scaling factors along x and y axes respectively.

Sx= Sy = 1 (No Scaling)


Sx= Sy (Uniform Scaling)
Sx≠Sy (Non-Uniform Scaling)
Sx ,Sy> 1 (Up scaling)
Sx ,Sy< 1 (Down scaling)

Thus scaling transformation can be represented in matrix form as

The notation representation for scaling transformation is given by

P=S(Sx,Sy).P

Imp. Note:Scaling for point is meaningless (since it is dimensionless quantity), for


lines,scaling is less relevant, because, it is one dimensional (length) and so scaling may be
understood as increase or decrease inlength.Scaling is relevant for 2D and higher dimension
objects.

Scaling can also be understood as holding the object and stretching or squeezing it
along x-direction and y-direction by the scaling factors Sx,Syrespectively. Scaling involves
not only change in size but also change in position. Standard scaling is performed with
respect to origin and the above equations are valid only in this case. If scaling is to be
performed with respect to another fixed position, then the equations would be different. Also
observe, for a rectangular object if scaling is to be performed with respect to its left corner
vertex, then the objects size changes, the positions of other vertices would also change
except the left corner vertex. Similarly if scaling has to be performed with respect to say
midpoint, then the object expands or contracts with respect to its mid-point.
Now putting all the three transformations together we have

P’=P+T
P’=R().P
P’=S(Sx,Sy).P

When transformations are performed, with respect to points other than origin, the
equations would be different than what we have already derived, and they will assume a
form as below i.e., for rotation, and scaling an additional 2x1 matrix whose elements (shown
as ? in the matrices below) will be derived later.

Let the additional matrix for rotation, scaling transformations performed with respect
to any other point in space be denoted as Mr and Ms respectively.So we can rewrite the
notations for the three basic transformations as shown below, intentionally, the notation for
translation is altered to include a 2x2 identity matrix multiplying P.

P’=I.P+T
P’=R().P+Mr
P’=S(Sx,Sy).P+Ms

Intentionally, the notation for translation is altered to include a 2x2 Identity matrix
multiplying P, such that all the three transformations have one common form, i.e.,each
transformation involves a matrix multiplication and a matrix addition.

Homogeneous coordinates:

When a series of transformations are to be performed (ex:animation) say T, R,S,T in


succession on an object, We have to give the initial coordinates for T, perform a
multiplication and an addition, store the result and pass it to R and repeat the process. So
there are 8 matrix operations and 3 intermediate storages.This is simplified by
Homogeneous coordinatesand Homogeneous transformation matrices.
A Homogeneous coordinate system is an imaginary 3 dimensional coordinate
system, with the three coordinates as (Xh, Yh, h), where h is called the homogeneous
coordinate and h can take any numerical value.
To convert between Cartesian and Homogeneous coordinates, the relation is given
by
(X, Y) ↔ (Xh, Yh, h)
,
When h=1, X=Xhand Y=Yh and the relation becomes
(X, Y) ↔ (X, Y, 1)

That is when h=1, the Cartesian coordinates in 2D can be represented as homogeneous


coordinates with an additional 1 for the homogeneous coordinates.
Our aim is to simplify transformations, by representing data in homogeneous
coordinates, performall computations, and while plotting the results are converted back to
the Cartesian domain. But by choosing ‘h’ as 1, the conversion from homogeneous to
Cartesian is as simple as discarding the third coordinate 1.

Advantages of Homogeneous representation:


 A series of transformations can be represented as matrix multiplications.
 Given the initial coordinates, the final coordinates can be computed easily by using
composite matrix.
 No. of matrix operations are reduced.
 Storage of intermediate results is not required.

Let’s have a closer look at the advantages mentioned above. The first one, says that,
when many transformations are to be performed in succession, we can simply multiply them
in that order. This matrix obtained by multiplying many matrices is called a ‘composite
matrix’.Now get the initial coordinates, multiply with composite matrix, and get final
coordinates in just one multiplication step. Thus the other advantages mentioned become
obvious.

Summary:
• Learnt how basic 2D transformations viz., Translation, Rotation, Scaling are
performed
• Also understood how homogeneous coordinates help reduce no. of matrix
operations.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy