Professional Documents
Culture Documents
Final 2D Transformations Heran Baker New
Final 2D Transformations Heran Baker New
OVERVIEW
1. Geometric Transformation
2. Co-ordinate Transformation
Transformation
• Translation
• Rotation
• Scaling
• Reflection
• Shearing
Point P defined as P( x, y ),
translate to Point P( x, y) a distance d x parallel to x axis, d y parallel to y axis.
x x d x y y d y
Define the column vec tors
x x d x
P , P , T
y y dy P’
P
Now
P P T
2D Scaling from the origin.
Point P defined as P( x, y ),
Perform a scale (stretch) to Point P( x, y) by a factor s x along the x axis,
and s y along the y axis.
x s x . x, y s y . y
Define the matrix P’
sx 0 P
S
0 s y
Now
x s x 0 x
P S P or y 0 .
s y y
2D Rotation about the origin.
P’(x’,y’)
P(x,y)
r
r
x
2D Rotation about the origin.
P’(x’,y’)
r
P(x,y) x r. cos
y r. sin
y
r
x
x
2D Rotation about the origin.
P’(x’,y’)
P(x,y)
r x r. cos
y r. sin
y
r
x
x
2D Rotation about the origin.
x r. cos
y r. sin
Gives us :
x x. cos y. sin
y x. sin y. cos
2D Rotation about the origin.
x x. cos y. sin
y x. sin y. cos
cos sin
Define the matrix R , P R P
sin cos
2D Basic Transformations
Translation. Scale Rotation
P=T + P P=S P P=R P
W P
W=1 plane
Y
Translation in homogenised
coordinates
x 1 0 d x x x x d x
y 0 1 d . y
y y y d y
1 0 0 1 1 11
Scaling in homogenised
coordinates
x S x 0 0 x x S x . x
y 0 0. y
Sy y S y . y
1 0 0 1 1 11
Rotation in homogenised
coordinates
P P T (d x1 , d y1 )
P P T ( d x 2 , d y 2 )
P P T (d x1 , d y1 ) T (d x 2 , d y 2 ) P T (d x1 d x 2 , d y1 d y 2 )
So we expect :
T (d x1 , d y1 ) T (d x 2 , d y 2 ) T (d x1 d x 2 , d y1 d y 2 )
Concatenation.
0 0 1 0 0 1
Matrix product is variously referred to as compounding,
concatenation, or composition
Concatenation.
1. T (0,0) I
2. T ( s x , s y ) T (t x , t y ) T ( s x t x , s y t y )
3. T ( s x , s y ) T (t x , t y ) T (t x , t y ) T ( s x , s y )
4. T -1 ( s x , s y ) T ( s x , s y )
In homogeneous coordinates :
sx 0 0
S ( s x , s y ) 0 sy 0
0 0 1
Concatenation of scales
sx = -1 sy = 1 original
Along y-axis
sx = 1 sy = -1
sx = -1 sy = -1
Along x-axis
Along xy-plane
Homogeneous form of rotation.
1 0 x
y T ( x, y )
0.4 1 y
(0,1) x
(1,1)
0.4 x y
S
(0,0) (1,0) x
Example 1
y T ( x, y )
x
(0,1) 0 .4 x y
(1,1)
S
(0,0) (1,0) x
Example 1
y (1, 1.4) T ( x, y )
x
(0,1) 0 .4 x y
T(S)
(1, 0.4)
(0,0)
x
Example 2
1 0.6 x
T ( x, y )
y 0 1 y
x 0.6 y
(0,1) (1,1)
y
S
(0,0) (1,0) x
Example 2
x 0.6 y
y
T ( x, y )
y
(0,1) (1,1)
S
(0,0) (1,0) x
Example 2
x 0.6 y
y T ( x, y ) y
(0,1) (0.6, 1) (1.6, 1)
T(S)
(0,0) (1, 0) x
Summary
Shear in x:
1 shx x x shx y
Shx
Shear in y:
0 1 y y
1 0 x x
Shy
sh
y 1 y shy .x y
Double Shear: not commutative!
1 a 1 0 (1 ab) a
0 1 b 1 b
1
1 0 1 a 1 a
b 1 0 1 b (1 ab)
Questions on 2D Composite
Transformations
Q1 Find the transformation that scales by
(a) A units in X direction
(b) B unit in Y direction
(c) Simultaneously a unit in X direction and b unit in Y
direction.
Q2 Write the general form of scaling matrix with respect
to a fixed point p(h, k).
Q3 Magnify the triangle with vertices A(0, 0), B(1, 1) and
C(5, 2) to twice its size while keeping C(5, 2) fixed.
Q4 Describe the transformation ML which reflects an
object about a line L.
Q5 Find the form of the matrix for reflection about a line
L with slope m and y intercept (0,b).
Viewing Transformations
Much like, what we see in real life through a small
window on the wall or the viewfinder of a camera, a
computer generated image often depicts a partial view
of a large scene.
World Coordinate System: Objects are placed into the
scene by modelling transformations to a master
coordinate system known as world coordinate system.
Window: A rectangular window with its edges parallel
to the axes of the WCS is used to select the portion of
the scene for which an image is to be generated.
Viewing Transformations
Q1. Find the complete viewing transformation that maps a window in WCS
with x extent 1 to 10 and y extent 1 to 10 onto a viewport with x extent ¼ to ¾
ant y extent 0 to ½ and y extent 0 to ½ in normalized device space and then
maps a workstation window with x extent ¼ to ½ and y extent ¼ to ½ in the
normalized device space into a workstation viewport with x extent 1 to 10 and y
extent 1 to 10.
Q2. Find a normalization transformation from the window whose lower left
corner is at (0, 0) and upper right corner is at (4, 3) onto normalized device
screen so that aspect ratio are preserved.
Where
Q. Find the normalization transformation N which uses the rectangle A(1, 1),
B(5,3), C(4,5) and D(0,3) as a window and the normalized device screen as a
viewport.
Q. Illustrate the effect of shearing transformation on the square A(0, 0), B(1, 0),
C(1, 1) and D(0,1) when a=2 and b=3.
Where