Professional Documents
Culture Documents
TRANSFORMATIONS
in 2-D
Representation of Points:
2 x 1 matrix:
X
Y
x' a c x
y' = b d y
x' = ax + cy
y' = bx + dy
x'
x a b
y' = y c d
x' = ax + cy
y' = bx + dy
S x
0
Sy
Example
of Scaling
Sx = 3
Sy = 2
Y
6
5
4
3
2
1
0
2
1
3
1
9
2
6
2
12 3 4 5 6 7 8 9
x= x
Non-uniform scaling
x= x + ay
0
1
Reflection about
Y=0 Axis (or X-axis)
1 0
0 1
Y = X Axis
0 1
1 0
Y = -X Axis
a c x x'
b d y = y'
x' = ax + cy
y' = bx + dy
ROTATION
cos( ) - sin( )
T=
sin( ) cos( )
= 30
1 2
(in degrees)
Matrix T
0
1
90
1 0
0 1
180
270 or -90
360 or 0
1
0
0
1
0
1
0
0
1
d
b
0
1
S=
1
0
1
x
c
x
a
S'= S
c
a a+c
b a
=
d a + c
b
b+ d
Translations
Y
tx = 5
ty = 1
6
5
4
2
2
3
7
2
3
1
0
12 3 4 5 6 7 8 9
Translations
B = A + Td , where Td = [tx ty]T
ROTATION
HOMOGENEOUS COORDINATES
Use a 3 x 3 matrix:
We have:
x' = ax + cy + tx
y' = bx + cy + ty
x' a c tx x
y' = b d t * y
y
w ' 0 0 1 w
Interpretation of
Homogeneous Coordinates
W
Ph (x, y, w)
1
P2d(x/w, y/w, 1)
x
T = c
m
b
d
n
q
s
If B = A.T, then
Translation
parameters:
(p, q)
Translation
parameters:
(m, n)
What about
S?
COMPOSITE TRANSFORMATIONS
If we want to apply a series of
transformations T1, T2, T3 to a set of points,
We can do it in two ways:
1) We can calculate p'=T1*p, p''= T2*p',
p'''=T3*p''
2) Calculate T= T1*T2*T3, then p'''= T*p.
Method 2, saves large number of additions
and multiplications (computational time)
needs approximately 1/3 of as many operations.
Therefore, we concatenate or compose the
matrices into one final transformation matrix,
and then apply that to the points.
Translations:
Translate the points
by tx1, ty1, then by tx2, ty2:
1 0 ( tx1 + tx 2 )
0 1 ( ty + ty )
1
2
0 0
Scaling:
Similar to translations
Rotations:
Rotate by 1, then by 2:
(i) stick the (1+ 2) in for , or
(ii) calculate T1 for 1, then T2 for 2 &
multiply them.
Exercise: Both gives the same result work
it out
P1
House at P1
Rotation by
P1
Translation of
P1 to Origin
Translation
back to P1
Sx
T = 0
0
0 {Px * (1 S x )}
Sy {Py * (1 S y )}
0
1
1
r
TGenRfl = Tr R Trfl R T
Commutivity of Transformations
If we scale, then translate to the origin,
and then translate back, is that equivalent to
translate to origin, scale, translate back?
When
is
the
order
multiplication unimportant?
of
matrix
T1
T2
translation
scale
rotation
scale(uniform)
translation
scale
rotation
rotation
Order:
R-G-B
Scale, translate
Rotate, differential
scale
Translate, scale
Differential scale,
rotate
COORDINATE SYSTEMS
Screen Coordinates: The coordinate system
used to address the screen (device coordinates)
World Coordinates: A user-defined application
specific coordinate system having its own
units of measure, axis, origin, etc.
Window: The rectangular region of the world
that is visible.
Viewport: The rectangular region of the screen
space that is used to display the window.
Window
Viewport2
Viewport1
X
World
Screen
WINDOW TO VIEWPORT
TRANSFORMATION
Purpose is to find the transformation matrix
that maps the window in world coordinates to
the viewport in screen coordinates.
Window:
0 0
(Xmax, Ymax)
(Xmin, Ymin)
X
Window in World
Coordinates
V
U
Window Scaled to
size to Viewport
X
Window translated
to origin
Maximum
Screen
Coordinates
(Umin, Vmin)
Viewport Translated
to final position
Y4 Y3
Y2 Y1
m=
=
X 2 X1 X 4 X 3
a b
T=
c d
b + dm
m' =
a + cm