0% found this document useful (0 votes)
18 views36 pages

CGA Unit 2 Class Notes

The document discusses various types of 2D transformations in computer graphics, including translation, rotation, scaling, reflection, and shear. It provides mathematical representations and examples for each transformation type, explaining how to modify and reposition objects in a two-dimensional plane. Additionally, it covers composite transformations and homogeneous coordinates for more complex transformations.

Uploaded by

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

CGA Unit 2 Class Notes

The document discusses various types of 2D transformations in computer graphics, including translation, rotation, scaling, reflection, and shear. It provides mathematical representations and examples for each transformation type, explaining how to modify and reposition objects in a two-dimensional plane. Additionally, it covers composite transformations and homogeneous coordinates for more complex transformations.

Uploaded by

saures319
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

-DATE---

08-02-21
_CGA_Lecture - 12

| 2D Transformation

To computer Graphics, Transformation is a process of | modifying


and repositioning the existing graphics. | 20 Transformations takes
place in a two-dimensional plane
It is helpful in changing the position size, orientation | shape etc of
the objective

tar || 2D transformation types O pbell for


_ i. Translation Basic or finding to
iiRotation Besic mi. Scaling Basice !!
iv. Sheor i la line Ni Reflection

| i- Translation

..It is a process of moving an object to another in


a two-dimensional plane
from one position
oplora

Example
Binah
o' . Initial Coordinates of the object - (Xold, Yoid)
New coordinates of the object = (Xnew knew)
•Translation vector or shift Vector = (Tx. Ir) i t . Give a Translation vector
(Tx, Ty)
• Tx defines the distance the fold XI ! coordinate has be
moved
Knerte jo Ty defines the distance the fold
has be moved.
DATE

LLLL
LL

Matrix Representation
&
Xoew [newed
=Xold all-rold
TX It

|| Given a Circle c Witte radius lo and Center coordinates


|(1,4) Apply the traislation with distance s towards X
axis and I towards Yaxis. Obtain the new Cordinates lof C without
changing its radius

|{Xnew Il Yoew]
Li+ls
4

\ Xnew llo lYnewel is

e. || Gives a Square with coordinate point. A (0,3). :-B(3,3)


(3, 0) oce,o) Apply the translation with distance L towards
X axis and I towards V axis obtain tie new Coordinates of the square :

À = | Xnew.1 - Lol.+fil = 1
too l Yew it. 13.-::L '

B
,

Y new ]

con for meg


18+ 0
0
I new

D'El Xhene - lots i


s
situ
Y new

___
Q. || Translate
and by
a polygon with 3 units in x
coordinates A (2,5), B12,60), C60, 2) direction and 4 units in y
direction
new

ew

Xnew Y new
1 3 1 1 13 il 4 l eo lol
li
Rotation

۲۱۵

• It is a process of rotating an
object with respect to an angle
ab in a two-dimensionel plane --7----- : Consider a point object
o bas to
v i . be rotated from one angle to C i ofanother in a 20 planet
io l.01. Initial coordinatew.of the xnow xold * obiecto = (Xold, Yold)
a se 11. Rotation anglė = 0 DO C . New Cordinates of the object o
after rotation = (Xnewer I crewed
Matrix Representation. In
Xold
Xnews LYnew
.coOSO - Sino | sino cosol
Yold

Do I Givers a line Segment with'_starting point as (0,0) and


| ending poin & as (4,4). Apply 30-degree transformation
rotation anticlockwise direction on the_Segment and find
| out the bew, coordinates of the line

1 Xnew
new
c os o lsin o
sin o 24 cos o 4
=
cos 30 L sin 30
- Sin 30
cos 301

lo +542 1.40 (-2009 5.45

:..-3. | Given a triangle with corner coordinates caelle) and all


- Il Rotate the triangle boy 90 degree anticleckewise directions
and find out new Coordinates

Xnew = Irnew.
cos 90. -Sin 90 | | Sin 90 cosaol lol
DATE

11-02-21
CGA Lecture. 13.

| in
Scaling
l
le
restaurant

Holt is a process of modifying or altering the size of lobiects


colomitovel
• May be used to increase or reduce the size of objects
• Scaling factor determines whether the object size is to be increased or creduced':
i f SF Ylli then the object size is increased - if SF Li theo. the object
size is reduced
L
Matrix Representation
entati

xnew = Sx olx / xold) Ir new lolo (sy) l rold)

|| • Initial coordinates 0 - (Xold, Yold). | SF for X-axistir' = Sxe o el


vient 1. sf for y-aris sy o veni
· New Coordinates 0 = (xnews, Ynew) olte can be
achieved by 'Scaling equations 1 01 · Xnew = Xold x Sac
• Y new - Yold X Sy

2. | Given ä. Saluare object with coordinate points. Aco.3), B(3,3)


| C(3,0), D (0,0). Apply the scaling parameter 2 towards |x ans and 3
towards. Y axis and obtair the new
coordinates of the objecti i
Xnew
Sr

Mynewtó
oll Xold sy 1 Yold I
pe

A' - 12 ol lol = 2xotoxo


10.31.31. Lox 3 + 3x3

c's | 2
o
13x2 3x0
0X3oXo di
0 31
10. || PC1, 4) Q (4,4) R (4,0
T (13.) Scaling
factor 3 on 4-axis
la on y-aris

1.
Sy

1.
Yold
i
P
new

02-02-21
CGA "Lecturc.
14

liv. Reflection :

ult is a kind of rotation where the angle of rotation is the 1.


The reflection object is always formed on the other side
I of mirror,
• The size of reflected object is same as the size of
Original object
La On X - aris

Reflections
O
n
r- anis

Matrix
Representation
:

I
new
rnew
=
o-
lo
X old IX new =
Xold on Yold Xn
ew=-Yold
x-axis

1 Xnew = n
MYnew TO
o xold Xnew=-Xold On Y-anis IT Yold) Ynew = Yold
-

DATE

Q|Given a triangle with co-ordinate_points_A(3,4), B(6) || CCGOL


Apply the reflection_on_the X-aris and obtain
the new co-ordinates of the obiecte
Elite
2

sa -3 -2 -
2
i4
éo
-
-
-

DATE

(ИТ.
. | Given a triangle with co-ordinate points A(3,4), B (5, 4).cls, od
|Apply the reflection on the raris and obtain the new I coordinates of the obiecte
inca
Cill v. Shear
is ille flies
Carte

1. It is a technique to change the shape of an existing


object in a two dimensional plone,
.01
• The object size can be changed along x direction as well as r direction

Fig
X- Shear
Fig: Y-Shear

MATRIX Representation _

1 x new
Ynew
ali shx x xold! 1
lol lYold
B
x-axis

Xnew = Xold + shz. Yold Ynew = Yeld

10 Y- aris
X new
Tynewl
[shy
l
Xold l rold! Yold)
Xnew = Xold. Ymew = Yold tsby Xold
(new
DATE

Q. Givena triangle_with__points (
W 600) and (10) Apply || shear_parameter 2
on x gais. 912d 2 on Lars sind Hout_the_new coordinates of the objecte
On y-anis
A(1,1) - A'ri shr 1 xl xold 1 » 12/ T
lo
( Yold ] o l
aris

Bloo)

On t-axis
On
t-axis
ACL,1)
Xold
.
Ashy
ol
I roid
.
1.2

clo) ME

DATE

MO
22-02-21

CGA Lecture
15 L

-
0 | Homogeneous Co-ordinates

u For Translation
medi
a s

Y
' = 10 , ty 1 X Il lo o il

P'(tx, dyl. P
12. For
Rotation
Her
cos o | = sin o I LO
- Sino O

coso 01x O is

p! =R[0] p_

13. For
Scaling

x'? Svi o o V = Sy olm it loo I

pus[ Sve Sy]. P


DATE

Composite
Transformation, combined
• Sequence 1. Forming
called as
of Transformation of products of transformation matrix is also
concatenation or composition of matrices
up >> t ve
down ay ove CGA Lecture 16
right o> +ve
left » -ve I
DATE

T
25-02-211

O
Give a 3x3 homogencaces coordinate transformation matik for each of the
following franslations
A. Shift the image to right 3 units. B. Shift the image up by 2 units c. Move the
image down by 2 unit and right by 1 unit D. Move the image down by 2/3 unit
and right by 4 unit
Ixl

ao 1 ty X Y
-

A. tre = 13 ty so | B tres o fy = 2: La tx=1


ty=-12 Lo trze ty = -213
1210

A.= Ti 031 | 3:
10

1x3 +0x3 +3xl


3
OX3 + (x3 + oxl OX3 + 0x3 + 1x1

B. Əli o 01 L
6

lco
3
12.5
DAT
lo 1 -2/3 X lo olu

a Find the transformation of triangle A (1,0) Blo, o)


(11) by | A. Rotating 45 degree about the Origin and then
translating Lone unit in x dire'dion and y direction
B. Translating and unit in x direction and y direction
and then rotating 45. degree about the origine

A = (1,0).
ve To DC, 13=(0,0)!!
!ics
c=(1,1)

R = cos 45 -sin 45 ol Vree-yrz


Isin 45 cos 45 o 1.2 12 lo od Loo
olol
RT

I yoz - Ya oli oil Yra Yra o lo i i


DATO'

lyra. - Yra : 07 1 yr Yr . 282

urz
Yuz
YE
-YE
Y
282
vra TOMTOT
ir a Wrze Y2 252 Too Todo

s ir I le
o
yr o ri le 752)
152 22
Ye + Yr21 o
lol )

2/82
-
-
-
-

RTE

CGA_Lecture
26-02 - 21)

Rotation
about an Arbitrary_Point
To rotate an object about an arbitrary_point (repryp) We have
to perform three steps: L. Translate point (ap, yp) to the origin Lii. Rotate it about
the origin ii. Translate the center of rotation back to original Looint.
I Ć

3. l Find the transformation matrix that transforms the given


Square AB CD to half of its size with it's centre I still remaining at the same
position. The Co-ordinates
of the square are ACL), B(3,1), c(3,3), D (1,3) lland centre at (2,2)
also find the resultant Coordinates
of square
T S Tz | nest [] [] ne positie
T» con ime row adoremo popolnom
a

Dor : 0 -2 110.s Oollio 2014


lo 1 -2 || O 0.5 ollo, 21 Hay lo o ilo o il
lool
do
Original

(o.s o -
21 o 21 fois ou Lo 0.5-2
2 1 = Loois / Loo lo o
LO O
DATE

no. of rows in
no. of columns in
2-
5+

‫اا‬
- ‫بن‬
‫ونه ها‬.
‫اے‬
|-|
0
0
‫بر‬
‫انا‬
‫‪3‬‬
‫‪x‬اه ‪3‬‬
‫‪4x 3 .‬‬
‫||‬

‫|‬
‫د‬
‫و‬
‫‪-| 5‬‬
‫اد‪ .‬و‬
‫ه ا=‪5 1‬‬
‫‪3-‬‬
‫در ‪0.5‬‬ ‫و‪-‬‬
‫اس ‪5‬‬
‫‪3‬‬
‫) ی ‪5 10 ٥۰‬‬

‫م‬
‫‪.‬‬
‫م‬
‫و و‬
‫و‬
‫ه‬
‫| رآ‪: , 5‬‬

‫‪|2‬‬
‫ا‪2.‬‬
‫‪.‬‬
‫‪2 -‬‬

‫ا‬
‫داد‬
,‫اا‬
‫ و ا رة ا‬,‫ و‬,‫ر‬
. ‫جي‬
.2 2 ‫کا‬
|
21-03-21
_CGA. Lecture 18

TRI

lo
x It
cos o sino
sino olo on coso o oolanty

r
Icos o I sin o h
0
-şine
cos o
0
n
t (1- Cos 0) + yt sin o yt (1-cos o) å ut sin o
na ilala

|which can be expressed in


the form

L
I(x+y): RCO).. I(-24, -94): = R(x4y4, 0)
o
-
perform anticlock wise rotations of 45 degree to a triangle
A(2,3) B(5,5), C(4,3) about a pivot point (1,1) seillyz -Yvq oli
0-1) lo 1 || Yra Yra olo L-| loi lo o illo o il
[ Yra Yr . L
Yuz Yuz 1-2 Le_b1 @ I
10.7071
0.7071
-0.7071 I
0.7071 -0.4142
»

p'- [2
5 4
3 1 0 .7071 Ś 0.7071 3 | | | 0
-0.7071. 0.7071
0
-0.4142
|| answer not
right ?
DATE

o|| Fixed - Point


Scaling_
o
O
O
!
!

Lu Translate object so that the fixed point coincides with Il


the coordinate origin. || 2. Scale the object with respect to the
coordinates origin.
3. Use the inverse translation of step i to return the
object to its original position
e

Concatenating Hoe required


three operations produces
NU

the matrikes of these


Scaling matrix

o rf ? (sz o ol lio-xf2 Sve o xfll-scal To YF. LO Sy 01/01 -yf


= 0 Sy yell-syll. to o illo o lo o il loo :

T (22f. Yf). S(sx,Sy). T(-xf.*) - 5 (vf, X, Sz, Sy).

3. Magnify the
(5,2) to fixed
triangle with vertices A (0,0) BULL) and twice of its size
while keeping c(5,2) as

7 | Txe = 5
5x=2
Ty = 2 Sy=2
_

||2=le ool | sx oollloo


lo io lo Sy Olle le laf yfillo o i z 'YE L

rio oll2 o ollo o L200 Lo iole 2 Ollo lolo 20 152 illo o J


1.5-2 T5 2T
ALMAUUKUU

OR

‫ه‬
‫ه‬
) ||
‫م‬
‫و=ه‬
0
2
|||0
|
||
‫ وات‬2 ‫او واال‬

‫و‬
.... () 2- ‫يج‬

||
»
‫و‬
DATE'-,

CGA Lecture -19


4-03-21

020 - Transformation
2
:
T2

Il Translation
i
n
ļ S
es 3D Translation is a process of
moving an object from one position to another in a three-dimensional
plane
Consider a point object o has to be mored from one
position to another in 3D plane, Let. Initial Co-ordinates of obiect
o
f (rcoid Yold Zold)
: New co-ordinates of
obiecto o
__ (Xnew, Ynew, Zoewel Translation or Shift
Vector
(Tre, Ty Tz) LEIL -2
SIC
ation

X new - Xold + Tx) Ynew = Yold + Ty Znew =


Zold + Tz

MATRIX :
Xnew
l 'Yoew I Znow I
o o Tx lolo Tylx lool Tzl
xold
Yold Zold

0. Gived a 3D object with coordinate points. A(0,3,1)


|B(3,3, 2), c(3,0,0) and D(0,0,0,0) Apply the translation Witte the distance
I towards X axis, 1 towards Y Qxc15 and 2 towards Z axis and
obtain the new co-ordinates of the object. 2
1

$|| Tx = 1Iyz L
1202

A'ELI

Loo 01

O
O
1
2

Lo 1 2
looo I

o'-lo 0:11. -
lo 10 lx
a process of objects.
12. Scaling ! 0 0
T In Computer graphics, Scaling is I modifying or
altering the Size of Let Initial Co-ordinates o
(Xold, told, Zold) t hg Scaling fuctor:
Xanis = 5x Zans- Sz taxis -
-

DATE

a
I Xnew = Xold x Sze Yoew = Cold & Sy z
pew = Zold X Sz

IS F 7
1
object is object is Uniform
increases decreased o
SiF = 1

Matrix.

Xnew sx ooo olo 3 Xold Ynew / = o syo o o x Yold


owl o o o o Sz o Zold i LO o o i la

2. Given a 3D object with Coordinate points A(0,3,3),


| B(3,3,0) c(3,6,1) D10,0,0). Apply the Scaling parameter 12 towards
x anis 3 towards Y anis and 3 towards
Z axis and obtaing the new co-ordinates of the
Hobject.
x = 2,54 3
52=3

LA's | 2 o ol lo
o 3 olx 3 Lo 0 3 0 1 1 3. lo o o id ,
DATE

[3
Ip- 12 o o o|
Lo 3 oo__x
o o3 의 Loool
3

c' - | 2. 。

。|

To o 3 0 I loo or

p = 12 ooo
lo 3 0 0 1 x IoT To o 3 0 | |
[이이이 -
,
CGA Lecture -20
15-03-
21

I Rotation i bus
30. Rotation is a process | object with
respect to an angle
of
!
rotating an io a 3D - Plane.

11 O'Rotation with
respect
to
X-Axis. vti

Matrix.
xnew) 1 Ynew | Znew
=
[ ro o ol o coso -sino o x o sino coso o
xold.
Yold zold

o Rotation with
respect
to t-AXIS

Matrix.
I Knew l l coso
Ynew 1 = 1 | Znew 1-sin o L : L 0
o sin o ol I o olx o coso ol. 0 0 1
yold | Yold Zold 1

O Rotation with respect to Z-AXIS.

Matrix
Xnew l cos Ynew | = | sin o Znewil! O
o - sin o
cos 0 :0.
ool Xold 0 0 .x tald
Ok l Zold
DATE

2.1. Given a homogeneous point (1, 2, 3). Apply rotation 90


degree towards x r and 2 anis and find out the new Co-ordinate point.
(Do only x for home → || Rotation for X- ariset i

0
0
-1
ololo
1

0
0
0

1-31
Axi to +1X3 +0 Loto -1x3 to
o + 2x1 toto O to toti
2

II Shearing
22
. Bei
30 Shearing is an ideal techinque | shape of
an existing object.in a
plane
_ . Shearing lo xo Aris
to change the three-dimensional

Xnew Ynew l = shy oo olx Z new . | shz o rol


x
Xold !
Yold | Zold
iiShearing__in_Y- Axis_

| Xnew to li Shre o oli Xold


Ynew l = 0 1 0 0 x Yold Zoewo Shaol
Zold

jShearing in
Z - AXIS

Xnew.
Ynew Z neve
lao Shiz ol xold! = o t shy o x- Yold
10 o
0 zeld

Given: a 3D triangle with points (0, 0, 0), ch, 1, 2) and


(1.1, 3) . Apply shear. parameter 2 OD X-azis. 2
on Ix-axis and 3 op z- Axis and find out the new
Coordinates of the object. (only x-oric)
21 A = LL 0
12|3o
0 0
0 0 0 í o olxol
isol 0 1
000-
1
O TWIN
5.
TE

0 0 2 O olx 3 Ölo
=>
3
-

oReflection I It is a kind of rotation where the angle


of rotation is 180 degrees
The reflected object is always formed on the other side of
mirror. a
The Size of reflected object is same as the
size of original object.

#
i

i Reflection relative ji Reflection relative ij


Reflection relative
to XY plane to y z plane

to xz plane
POIS

i XY planet ario
| X new l Oo OL
Ynew l = lo i o.olx | Znew I loo ol
Xold I rold Zold

lli &z
Plane

Xnews
Knew Znew
Xold Yold Zold
L00 Lei
-

ji xz Plane
Finde
r

1 x new
l | Ynew l
= | Znew
o 0 -1
loo
o 0 Lil told 0 0 x
Yold
o
zold

Il
Diagram,
1
o
.

.XY-Plane
il
i
Y Z - Plane
KA

ii. x z - Plane
AL

DATE

Q.Given a 30 triangle with coordinates points


LAG. 4.) BC6, 4, 2)) cls,6,3) Apply the reflection
on the xr plane and find out the new Coordinates
of the object o
n

|| xx
Plane:

TA' -11 0 0
0 1 0
0 0

B =
1 1
0
0
0 1
#1--
16 HNP a
0
lo 0 -1 Looo

ali o
o
o 2

le O -1 0 1 Too e il
DATE
CGA Lecture -21

Widow Terms
TO VIEW PORT TRANSFORMATION - der to
understand

Window : A world co-ordinate arca . It


define's what to be viewed.
Selected for display
verzi

Viewport : An Window is
Viewed
area on a mapped. It
display device to which a defines where
it is to be

A mapping of part of world co-ordinates scene to device co-


ordinates is refered to as 'Viewing
Transformation
TOY

Window

- Window
Window
-
World
Coordinates
Device
Coordinatore

| Sequence of
transformation
1. Perform a scaling transformation using a fixed point position of
CXw min, Yin min) that scoles the Window
area to the size of the Viewport. || 2. Translate the scaled Window
area to the position Hef the Viewport.
DATE

min

Translating Window at the Viewport.


2V = Van + (W = xwmin). Se fyr = av min +
Cyw yw in sy where the Scaling factor are:

szez ZXmany - 20 Vpin ..mala


xwmax - XW min
Max

mo
I sy =
y v max -y min
ha x
min

yw may - yw min

I PROJECTION

I i)
Parallel
Orthographic projection oblique projection
Axonometric projection na Dimetric projection
Trimetric projection

Prespective
A Konishing-Reint Lone point prespective
two-polnt-prespective

You might also like