Upload
misteryfollow
View
233
Download
0
Embed Size (px)
Citation preview
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 1/35
COMPUTER GRAPHICS AND
ANIMATION
09 Transformations
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 2/35
Transformations
• Some basic transformations
! Sca"in#
! Rotation
! Trans"ation
• Essentia" to man$ #ra%&ics a%%"ications'
E(am%"e cit$)%"annin# a%%"ication
! Trans"ation for %"acin# s$mbo"s *of trees+ b,i"-in#s+
etc. at a%%ro%riate %ositions
! Sca"in# for si/in# t&e s$mbo"s
! Rotation for orientin# t&e s$mbo"s'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 3/35
Transformations
• Matrices can be ,se- as o%erators to
%erform transformations'
•asica""$P’ 1 P ' T
P 1 ori#ina" %oint
T 1 transformation matri(P’ 1 res,"t %oint
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 4/35
Sca"in#
• Sca"in# base- on*0+0.
• P is sca"e- b$ s x
a"on# t&e ( a(is an-b$ sy a"on# t&e $a(is'
• T&,s x’ = s x . X
y’ = sy . y
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 5/35
Sca"in#
• In matri( form
x’ = s x . x + 0 . y
$2 1 0 ' x 3 s$ ' y T&,s
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 6/35
Rotation
• Center of rotation at
*0+0.'
•P is rotate-
ϑ
-e#rees co,nter)
c"oc45ise'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 7/35
Rotation
• In matri( form
x’ = x cos – y sinϑ ϑ
y’ = x sin + y cosϑ ϑ• T&,s
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 8/35
S&earin#
• I2m "ost at 5or-s+ so
-escribe t&is $o,rse"f'
•dx = dy / m = y / m
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 9/35
S&earin#
• In matri( form
x = x + y/m
y = y
• T&,s
5&ere a = 1/m
• 6&at abo,t s&earin# a"on# t&e $ a(is7
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 10/35
Trans"ation
• Mo8e P -( ,nits
%ara""e" to t&e (
a(is an- -$ ,ntis
%ara""e" to t&e $
a(is
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 11/35
Trans"ation
• 6e #et
x’ = x + dx
y’ = y + dy P’ = P + T
• Ho5 5o,"- t&e transformation matri( be7
P’ = P . T T 1 777
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 12/35
Transformation
• 6e 5ant to ca%t,re a"" t&e tranformations
in t&e form of a matri('
• Ma4e it so t&at P’ = P . T can be a%%"ie-
for a"" 4in-s of transformations+ including
trans"ation'
• Is it %ossib"e to &a8e a transformation
matri( incor%oratin# trans"ation7
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 13/35
Homo#ene,s Coor-inates
• Sca"e+ rotate+ s&ear P’ = P . T
• Trans"ation P’ = P + T
• Transform P*(+$. into a &omo#eneo,s
coor-inate P&*(+$+5.
• T&is coor-inate s$stem &as m,"ti%"e8a",es for same %oints
! E'#' *+:+;. an- *<+;+=. are t&e same %oint'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 14/35
Homo#eneo,s Coor-inates
• At P+ 5 1 =
• P*(>5+ $>5+ =.
• P= an- Pre%resent t&e same
%oint'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 15/35
Homo#eneo,s Coor-inates
• ?et P*(+$+=. an- P2*(2+ $2+ 5.
x’ = ax + by + m
y’ = cy + dy + n
• T&e transformation matri( c&an#es from( to :(:+ t&,s
• P2 *(2+ $2+ =.
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 16/35
Transformation O%erators
Sca"in# S&earin#
S(s x , sy ) Shy (a) Sh x (b)
Rotation Trans"ation
R( θ ) T(dx, dy)
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 17/35
Transformin# ?ines
• To transform a "ine+ $o, on"$ nee- to
transform t&e en- %oints' T&e ot&er %oints
5i"" @fo""o5'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 18/35
Com%osition of Transformations
• T&e %rocess of a%%"$in# se8era"transformations in s,ccession to form oneo8era"" transformation
• If 5e transform a %oint P 5it& M= *res,"tin#in P’ .+ an- t&en transform t&e res,"t ,sin#M 2 *res,"tin# in P’’ .+ 5e #et
P’ 1 P . M1P’’ = P’ . M2
T&,s P’’ = P . M1 . M2
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 19/35
Com%osition of Transformations
• If 5e %erform n s,ccesi8e transformations
on a %oint P + 5e #et
P’ = P . M 1 . M 2 . M . ... . M n
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 20/35
E(am%"e
• Ho5 -o 5e rotate a s&a%e -e#rees fromϑ
an arbitrar$ %oint P7
• Bor eac& %oint in t&e s&a%e Pi+ 5e %erform
t&ese : ste%s
! Trans"ate s,c& t&at P is t&e ori#in *M=.
! Rotate *M9.
! Trans"ate bac4 to ori#ina" %oint *M:.
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 21/35
E(am%"e
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 22/35
E(am%"e
• ?et P*(+$.
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 23/35
E(am%"e
T 1 M= ' M ' M:
1
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 24/35
Data Str,ct,re
• Type TMatrix = array [0 .. 2, 0
.. 2] of real
• Type TPoint
< x : real, y : real>
• Type THC = array [0 .. 2] of
real {hoo!eno"# $oor%inate&• Type THC
< x : real, y : real, ' : real>
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 25/35
Re8ie5 ,estions
• 6&$ -o 5e ,se :(: matrices instea- of (matrices for D transformations7
• Deri8e t&e transformation matri( for sca"in# a %ointfrom *0+0.'
• Deri8e t&e transformation matri( for rotatin# a%oint from *0+0.'
• Deri8e t&e transformation matri( for s&earin# a%oint on t&e ( a(is an- $ a(is'
• Deri8e t&e transformation matri( for trans"atin# a%oint'• In #enera"+ &o5 -o 5e %erform a sca"in# or rotation
o%eration from an arbitrar$ %oint7
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 26/35
E(ercise
• Bin- t&e transformation matrices for t&e
fo""o5in# o%erations
! Trans"ate a %oint b$ *<+ .
! Sca"e t&e ()com%onent of a %oint b$ 0' an- t&e$)com%onent b$ : from *0+0.'
! Rotate a %oint < -e#rees c"oc45ise from *0+0.
! S&ear a %oint on t&e "ine $ 1 ( a"on# t&e ( a(is'• Perform t&e abo8e transformations on t&e
%oint *:+<.
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 27/35
E(ercise
• Define t&e transformation matri( for t&e
fo""o5in# o%erations
! ertica" f"i% *ref"ect to ()a(is.
! Trans%ose %oint *P2*$+(..
! Ref"ection from an arbitrar$ %oint P'
• An obFect is to be ref"ecte- t5ice as far from
t&e "ine ( 1 ' Bor e(am%"e+ if P is *0+0. an- Pis t&e res,"t of t&e transformation+ P is *=+0.'
Deri8e t&e transformation matri('
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 28/35
E(ercise
• Pro8e t&at R *θ 1. R *θ 2 . 1 R *θ 1 + θ 2 .' 6&at
-oes t&is mean7
• Pro8e t&at T*(=+ $=. ' T*(9+ $9. 1 T*(=3(9+
$=3$9.' 6&at -oes t&is mean7
• Pro8e t&at S*(=+ $=. ' S*(9+ $9. 1 S*(=(9+
$=$9.
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 29/35
E(ercise
An ort&o#ona" matri( is a matri( 5&ic&+
5&en m,"ti%"ie- b$ its trans%ose+ res,"ts in
t&e i-entit$ matri(' Hence+ t&e in8erse of an
ort&o#ona" matri( is t&e trans%ose of t&ematri('
•Pro8e t&at rotation matrices are ort&o#ona"'
•6&at -oes t&is mean7
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 30/35
E(ercise
Bin- t&e transformation matri( for t&efo""o5in# o%erations
•Sca"in# an obFect from t&e ori#in %oint b$
in ( an- $+ fo""o5e- b$ a trans"ation b$ *=+=.'•Trans"ation of an obFect b$ *=+=. fo""o5e- b$a sca"in# from t&e ori#in b$ in ( an- $'
•6&$ are t&e t5o res,"tin# matrices-ifferent7
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 31/35
E(ercise
• 6&at D transformations are -one to
transform t&e s&a%e on t&e "eft to t&e
s&a%e on t&e ri#&t7 E(%"ain' Deri8e t&e
transformation matri('
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 32/35
E(ercise
• 6&at D transformations are -one to
transform t&e s&a%e on t&e "eft to t&e
s&a%e on t&e ri#&t7 E(%"ain' Deri8e t&e
transformation matri('
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 33/35
E(ercise
T&e fo""o5in# matri( M is a transformation matri(
?et M= an- M be transformation matrices s,c& t&atM 1 M= M'
Define M= an- M if•M= is a trans"ation o%erator an- M is a sca"in#o%erator'
•M= is a sca"in# o%erator an- M is a trans"iationo%erator'
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 34/35
E(ercise
• A %oint is to be transforme- in s,c& a 5a$ t&at
t&e -istance from t&e %oint *:+ <. is &a"8e-' Bor
e(am%"e+ if P is *=+ . *-istance 1 √ from *:+
<.. an- P is t&e res,"t of t&e transformation+ P is*+ :. *-istance 1 √ from *:+ <..' Deri8e t&e
transformation matri('
7/26/2019 Computer Graphics and Animation - 09 Transformations
http://slidepdf.com/reader/full/computer-graphics-and-animation-09-transformations 35/35
E(ercise
e"o5 is a rectan#"e s%ecifie- b$ its fo,r 8ertices A+ + C+an- D' Determine a set of in-i8i-,a" D transformationmatrices t&at transform t&e rectan#"e ACD intorectan#"e A22C2D2 as s&o5n be"o5' Note t&at t&etransformations s&o,"-+ in t&e en-+ transform 8erte( Ainto A2+ into 2+ etc'