Trang 4 Transformation Definition■ What is a transformation?□ P′=TP□Transform the coordinates / normal vectors of objects■ Uses□Moving the objects to the desired location in the environm
Trang 1Lesson 5
Modeling Transformation
Trinh Thanh Trung School of ICT, HUST
Trang 3Transformation
Trang 4□ Virtual camera: parallel and perspective projections
Trang 5Types of transformation
■ Object Transformation alters the coordinates of
each point according to some rule, leaving the
underlying coordinate system unchanged
■ Coordinate Transformation produces a
different coordinate system, and then represents all original points in this new system
Trang 6Display
Coordinate System
MODELING
TRANSFORMS
Projection Coordinate System
PROJECTION
TRANSFORMS
Trang 7Modeling
Transformation
Trang 8Transformation
Trang 9Transformation
Trang 10Affine transformation
■ Whole collections of points may be transformed
by the same transformation T, e.g lines or circles
■ The image of a line, L, under T, is the set of all images of the individual points of L
■ For most mappings of interest, this image is still
a connected curve of some shape
■ For some mappings, the result of transforming a line may no longer be a line
lines, and are the most commonly-used
transformations in computer graphics
Trang 11Affine transformation properties
endpoints of the original line and then draw a
straight line between them
Trang 12Affine transformation properties
■ Preservation of proportional distances
Trang 142D transformations
Trang 15Matrix representation
■ All affine transformations in 2D can be
generically described in terms of a generic equation
P d
c
b a
Q Q
Trang 16■ A translation moves an object into a different position in a scene
Note: House shifts position relative to origin
y
x
0 1
Trang 17x y
x
t
t P
P Q
t T
y
x P
Transformation matrix
Trang 18■ Scaling multiplies all coordinates
□ Alters the size of an object
Note: House shifts position relative to origin
y
x
0 1
Trang 19x P
x x
y
x
S P
S P
Q Q
Trang 20x = r cos , y = r sin x’ = r cos ( + ), y’ = r sin ( + ) x’ = r ( cos cos - sin sin )
Trang 21Rotates all coordinates by a specified angle
x new = x old × cosθ – y old × sinθ
y new = x old × sinθ + y old × cosθ
Trang 22■ Using the trigonometric relations, a point
rotated by an angle q about the origin is given by the following equations:
y
x P
sincos
y x
y x
y
x
P P
P P
Q Q
Trang 23■ A shearing affects an object in a particular
direction (in 2D, it’s either in the x or in the y
Trang 24■ A shear in the x direction would be as follows:
■ More generally: a simultaneous shear in both the
x and y directions would be
y
x
P
hP P
Q Q
y x
y
x
gP P
hP P
Q Q
Trang 25x y
x
t
t P
P Q
Q
10
01
sin
sincos
y
x y
x
P
P θ θ
θ θ
1
y
x y
x
P
P g
h Q
Trang 26Homogenous representation
Trang 27■ An affine transformation is composed of a linear
combination followed by a translation
■ Unfortunately, the translation portion is not a
matrix multiplication but must instead be added as
an extra term, or vector – this is inconvenient
□ E.g pivotal point rotation
Trang 28R ( ) ( − , − ) T ( dx , dy ) R ( ) T ( − dx , − dy ) H
Trang 29Homogeneous Coordinates
■ A point (x, y) can be re-written in homogeneous
coordinates as (xh, yh, h)
■ The homogeneous parameter h is a
non-zero value such that:
■ We can then write any point (x, y) as (h.x, h.y, h)
■ We can conveniently choose h = 1 so that
y = h
Trang 30Why use homogeneous coordinates
■ Allow scaling factors to be removed from
equations
■ All of the transformations we discussed
previously can be represented as 3*3 matrices
■ Allows us use matrix multiplication to calculate transformations
Trang 31Homogeneous Coordinates
1 to both P and Q, and also a third row and column to M, consisting of zeros and a 1
y
x y
x y
x
P
P t
d c
t b a Q
1 0
0 1
y
x
t
t M
0 0
0 0
y
x
S
S M
0
0 cos sin
sin cos
0 1
0 1
g
h M
Translation by {tx, ty}
Scale by Sx, Sy Shear by g, h:
Rotate by :
Trang 32Homogeneous Translation
■ The translation of a point by (dx, dy) can be
written in matrix form as:
0
1 0
0 1
dy dx
+ +
* 1
* 0
* 0
1
*
* 1
* 0
1
*
* 0
* 1
1 1
0 0
1 0
0 1
dy y
dx x
y x
dy y
x
dx y
x y
x dy
dx
Trang 33Homogenous Coordinates
■ To make operations easier, 2-D points are
written as homogenous coordinate column vectors
100
00
00
y s
x s y
x s
s
y
x y
sin cos
1 1
0 0
0 cos
sin
0 sin
cos
y x
y x
Trang 35R ( ) ( − , − ) T ( dx , dy ) R ( ) T ( − dx , − dy ) H
Trang 360 0
1 0
0 1
1 0
0
0 cos
sin
0 sin
cos
1 0
dx dy
REMEMBER: Matrix multiplication is NOT
commutative so order matters
v dy dx
T R
dy dx
T
Trang 37Scale → Translate
Translate → Scale
Trang 383D transformations
Trang 39Homogenous coordinates
■ Point representation in 3D
■ Homogenous transformation matrix
■ We are still able to use P’ = R.P
0 0
z y x
d j
h g
d f
e d
d c
b a
P P P
Trang 400 0
1 0 0
0 1 0
0 0 1
z y x
d d d
1 0
0 0
1 0 0
0 1 0
0 0 1
z y x
z y x
d z
d y
d x
z y x
d d d
Trang 410 0
0 0
0
0 0
0
0 0
0
z y
x
S S
1 0
0 0
0 0
0
0 0
0
0 0
0
z S
y S
x S
z y x
S S
S
z y x
z y
x
Trang 42down to the coordinate center
x y
z
x y
z
x y
z
Trang 43Every rotation around the origin can be decomposed into a rotation around the x- axis followed by a rotation around the y-axis followed by
a rotation around the z-axis.
Euler’s Theorem
Trang 440 0
0 cos
sin 0
0 sin
cos 0
0 0
0 1
0
0 1 0
0
0 0 cos
sin
0 0 sin
Trang 450 0
0 cos
0 sin
0 0
1 0
0 sin
0 cos
Trang 47Any questions?
Trang 48Lecture notes provided by School of Information and
Communication Technology, Hanoi University of Science and
Technology.
Composed by Huynh Quyet Thang, Le Tan Hung, Trinh Thanh
Trung and others
Edited by Trinh Thanh Trung
Special thanks to all the people who made and released these awesome resources for free:
■ Presentation template by SlidesCarnival
■ Photographs by Death to the Stock Photo ( license )
■ Diverse device hand photos by Facebook Design Resources