This document summarizes the process of 2D transformations and window to viewport transformation in computer graphics. It describes basic 2D transformations including translation, rotation, scaling and their equation representations. It also explains the concept of composite transformations and discusses translation, rotation and scaling as composite transformations. Finally, it provides details about the window to viewport transformation including translating and scaling the window to fit within the viewport boundaries.
ICT Role in 21st Century Education & its Challenges.pptx
2D Transformation
1. Assignment No.2
Submitted To:
Ma’am Aqsa Naeem
Subject:
Computer Graphics
Topics:
Transformation
2D transformation
Basic Types of transformation
Translation
Rotation
Scaling
Composite Transformation
Window to viewport Transformation
Submitted By
Name:
Asma Tehseen
Roll No
1823110013 (319)
Class
BSCS-IV
Submission Date:
18th
may, 2020
Department of Computer Science
2. Transformation
“In graphics, transformation means to change described
object by moving, rotating or scaling that object while following
some specific rules.”
Or
“A transformation is any operation on a point in a space (x,y)
that maps the point’s coordinates into a new set of coordinates
i. e; (x1,y1).”
Simply moves an object from one position to another following this
equation:
dyyy
dxxx
oldnew
oldnew
2D Transformation
“The transformation takes place in 2D plane to re-position
graphics, size or orientation of an object on screen is known as
2D Transformation.”
Types of Transformation:
There are several types of basic transformations:
Translation
Rotation
Scale
Translation:
“A translation is applied to an object by re-positioning it along a
straight line path from one coordinate location to another.”
In 2D Translation, a point moves to a specified distance in the x or y
direction.
It is performed by adding translation distances,tx and ty to the original
coordinate position (x,y) to move the point to a new position (x’,y’)
3. yty
x
'
x
'
y
tx
The translation distance pair (tx, ty) is called a translation vector or
shift vector.
In translation, deformation of image does not occur as every point on the
object is translated by the same amount.
Translation equation in matrix form is represented as:
2
1
x
x
P
2
1
'
'
'
x
x
P
y
x
t
t
T
Row vector form:
yxP yx ttT
P=(x,y)
P1=(2,3) , P2=(1,1) , P3=(3,1)
While translation T=(tx,ty) is at (5,3)
For P = (2,3)
P’1= (2,3) + (5,3) = (7,6)
P’2= (1,1) + (5,3) = (6,4)
P’3= (3,1) + (5,3) = (8,4)
y
X
(0,0)
1
1
2
2
3 4 5 6 7 8 9 1
3
4
5
6P1(2,3)
P2(1,1) P3(3,1)
y
x
1
2
3
4
5
6
(6,4)
(8,4)
(7,6)
Where
P’ = P + T
Translated by (5, 3)
X’ = x + dx
y’ = y + dy
P’ = (x’ , y’)
x’ = x + tx
y’ = y + ty
4. Rotation:
“A two dimensional rotation is applied on an object by
re-positioning it along a circular path in the xy plane.”
It causes a point to be moved relative to a central point, without changing
the distance of r from the central point. While, Rotation angle θ and
Rotation point (xr,yr) are specified to generate rotation.
Rotation point is the point about which the object will rotate also known
as pivot point.
Positive values of rotation angle define counterclockwise rotations about
the rotation point and Negative values indicate the rotation in clockwise
direction.
For the equation of rotation, r is the constant distance of the point form
the origin, angle Φ is the original angular position and θ is the rotational
angle.
sinsincoscos)cos(' rrrx
cossinsincos)sin(' rrry
Original coordinates of the point are:
cosrx sinry
By equation 1
cossin'
sincos'
yxy
yxx
In column vector form rotation is defined as: P’=R.P
Where rotation matrix is:
cossin
sincos
R
For positive rotation it becomes: For negative rotation:
cossin
sincos
R
cossin-
sincos
R
1
5. (x,y)
(x’,y’)
r
r
Φ
θ
Rotation is also a rigid body transformation, as image deformation doesn't
occur. Since, every point on the object is rotated through the same angle.
Scaling
“This transformation alters the size and possibly the position of object.”
Scaling operation is performed by multiplying the coordinate values (x,y)
of each vertex by scaling factors sx and sy to produce the transformed
coordinates (x’,y’).
y
x
syy
sxx
.'
.'
sx scales the object in x direction and sy scales the object in y direction
P’ = S.P
Scaling factors(sx, sy)can be assigned any +ve numeric values.
Values less than 1deduce the size of the objects
Values greater than 1 produce an enlargement
1 value for both does not make any changes to the size of the object
In Matrix form:
y
x
s
s
y
x
y
x
.
0
0
'
'
The location of a scaled object can be controlled by choosing a position,
called the fixed point, that is to remain unchanged after the scaling
transformation.while,the Coordinates for the fixed point (xf, yf) can be
chosen as one of the vertices, the object centroid, or any other position.
Object is rotated at
Rotational angle θ
from
Original angle Φ
6. Scale by (2, 2)
P = (x, y) P’=(x’,y’) ; S = (2,2)
P1=(2,3) P’1 =(2,3).(2,2)=(4,6)
P2=(1,1) P’2=(1,1).(2,2) =(2,2)
P3=(3,1) P’3=(3,1).(2,2)=(6,2)
Composite Transformation
Composite transformation is achieved by concatenation of two
or more transformation matrices to obtained a combined
transformation matrix.
i. e; composite Transformation matrix.matrix
Operations perform in Composite transformation:
Rotate about an arbitrary point translate,rotate,translate
Scale about an arbitrary point translate, scale,translate
Change Co-ordinate system translate, rotate, scale
y
0 1
1
2
2
3 4 5 6 7 8 9 1
3
4
5
6
(2, 3)
(1, 1) (3,1)
x’ = sx*x
y’ = sy*y
y
0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(2, 2) (6, 2)
(4,6)
7. Since, the composite transformations are as follows:
Composite Translation:
The two successive translation vectors (tx1, tyl) and (tx2, ty2)
are applied to a coordinate position P, the final transformed location
P' is calculated as
P’=[T{tx2,ty2}.T{tx1,ty1}].P
In matrix form
100
tyty10
txtx01
100
ty10
tx01
.
100
ty10
tx01
12
12
1
1
2
2
Hence, two successive translations are additive.
Composite Rotation
Two successive rotations applied to point p product the transformed
position
P' = {R(θ2) . R(θ1) }. P
By multiplying the two rotation matrices, we can verify that two
successive rotations are additive
PRP
PRRP
)..('
).().('
12
12
so that the final rotated coordinates with the composite rotation matrix is
100
0)21cos()21sin(
0)21sin(-)21cos(
Composite Scaling
Concatenating transformation matrices for two successive scaling
operations produces the following composite scaling matrix:
100
0Sy.Sy0
00Sx.Sx
100
0Sy0
00Sx
.
100
0Sy0
00Sx
1
1
2
2
OR
).,.().()..( 21211122 sysysxsxSsysxSsysxS
The resulting matrix indicates that successive scaling operations are
multiplicative. To triple the size of an object twice in succession, then the
final size would be nine times of original object.
8. Window to Viewport Transformation
“The process of transforming a two dimensional, world
coordinate scene into device coordinates.”
In particular, object inside world or clipping window are
mapped to viewport.
Clipping window Viewport
Purpose:
The purpose of this transformation is to convert the size of clipping
window to size of viewport by using some mathematical computations.
Steps for window to viewport transformation:
1. Translate window towards origin i.e; lower left corner and upper
left corner of window become negative.
2. Resize window to viewport size applying following computation
minmax
minmax
x
XWXW
XVXV
S
&
minmax
minmax
ywyw
yvyv
Sy
3. Translate window I.e; position of window and viewport is same.
i. if viewport is at(0,0) then don’t translate because window is
already at origin.
ii. If viewport is not at (0,0) take translation factor positive.
World port/clipping window:
The part of world
coordinate to be displayed on
screen.
Viewport:
Rectangular region
selected for displaying image
on computer screen.
YW-max
YW-min
XW-min XW-max
Viewport Coordinate
YV-max
YV-min
XV-min XV-max
Window in
world coordinate
Window translated
to Origin
Window scaled to size
of viewport
Translated by (xmin,ymin)
to final position
(Xmax,Ymax)
(Xmin,Ymin)
(Xmin,Ymin)
(Xmax.Ymax)