Professional Documents
Culture Documents
TRANSFORMATIONS
in 2-D
2D TRANSFORMATIONS AND MATRICES
Representation of Points:
2 x 1 matrix: X
Y
General Problem: [B] = [T] [A]
x' a c x
T T
x' x a b
y' b d y y' y c d
x' ax cy x' ax cy
y' bx dy y' bx dy
1) T = identity matrix:
a=d=1, b=c=0 => x'=x, y'=y
Reflection
(about the Y-axis)
( )
x´= – x x
Non-uniform scaling
x
x´= x + ay
Special cases of Reflections (|T| = -1)
1 0
0 Y=0 Axis (or X-axis)
1
1 0
0 1 X=0 Axis (or Y-axis)
0 1
1 Y = X Axis
A i
0
0 1
1 0 Y = -X Axis
Off diagonal
g terms are involved
in SHEARING;
a c x x'
a = d = 1;
b d y y'
let, c = 0, b = 2
x' ax cy
x' = x
y' = 2x + y ; y' bx dy
y' depends linearly on x ; This effect is called
shear.
h
cos( ) - sin( ) 1
T 0
sin( ) cos( ) 1 2 3 4 5 X
0 1
90 1
0
1 0
180 0 1
0 1
270 or -90 1
0
1 0
360 or 0 0 1
Example - Transformation of a Unit Square
Y
Y b+d
(1, 1) d
b
x
x c a a+c
0 0 0 0
1
0
S a b a b
1 1 S' S
c d a c b d
0 1
c d
Area of the unit square after transformation
= ad - bc = |T|.
Extend this idea for any arbitrary area.
Translations
6
5
tx = 5 4 2
ty = 1 3 2
7
2
3
1
0 X
12 3 4 5 6 7 8 9
Translations
B = A + Td , where Td = [tx ty]T
xx' a c tx x
Use a 3 x 3 matrix: y' b d t * y
y
Ph (x, y, w)
1
P2d(x/w,
( / y/w,
/ 1)
Y
Two homogeneous coordinates (x1, y1, w1)
& (x2, y2, w2) may represent the same point,
iff they are multiples of one another:
say, (1,2,3) & (3,6,9).
a b p
T c d q
m n s
Parameters involved in scaling, rotation,
reflection and shear are: a, b, c, d
If B = T
T.A,
A then If B = A
A.T,
T then
Translation Translation
parameters: parameters:
What about (m, n)
(p q)
(p,
S?
COMPOSITE TRANSFORMATIONS
If we want to apply a series of
transformations T1, T2, T3 to a set of points,
points
We can do it in two ways:
0 0 1
Scaling:
S li
Similar to translations
Rotations:
Rotate by 1, then by 2:
(i) stick the (1+ 2) in for , or
(ii) calculate
l l t T1 for
f 1, then
th T2 for
f 2 &
multiply them.
• Rotate
P1
House at P1 Rotation by
P1
Translation of Translation
P1 to Origin b k to P1
back
Rotation about an arbitrary
point P in space
• Scale
S l
• Translate
T l t P back
b k
T = T1(
(Px, Py)
)* T2(
(Sx, Sy)
)*T3(
(-Px, -Py)
Sx 0 {Px * (1 S x )}
T 0 Sy {Py * (1 S y )}
0
0 1
Reflection through
g an arbitrary
y line
Steps:
• Translate line to the origin
• Reflection matrix
1
TGenRfl Tr R Trfl R T T
r
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 of matrix
multiplication unimportant?
When does T1 * T2 = T2 * T1?
Cases where T1 * T2 = T2 * T1:
T1 T2
translation translation
scale scale
rotation rotation
scale(uniform) rotation
Order:
R-G-B
Scale translate
Scale,
T
Translate,
l scale
l
Vi
Viewport1
t1
X U
World Screen
WINDOW TO VIEWPORT
TRANSFORMATION
Viewport: (u,
(u v space) denoted by:
umin, vmin, umax, vmax
The overall transformation:
(Xmin, Ymin)
(
X X
Window in World Window translated
Coordinates to origin
V
V
Maximum
Screen
Coordinates
(Umin, Vmin)
U U
Window Scaled to Viewport
e po t Translated
a s ated
size to Viewport to final position
Exercise -Transformations of Parallel Lines
Consider two parallel lines:
(i) A[X1, Y1] to B[X2, Y2] and
(ii) C[X3, Y3] to B[X4, Y4].
Slope of Y2 Y1 Y4 Y3
the lines: m
X 2 X1 X 4 X 3
Solve the problem: a b
If the lines are T
transformed by a matrix: c d
The slope of the
b dm
d
transformed lines is:
m'
a cm