2D Geometric Transformations: CS-1206 Course Coordinator Dr. Badal Soni
2D Geometric Transformations: CS-1206 Course Coordinator Dr. Badal Soni
CS-1206
Course Coordinator
Dr. Badal Soni
Contents
• Definition & Motivation
• 2D Geometric Transformation
– Translation
– Rotation
– Scaling
• Matrix Representation
• Homogeneous Coordinates
• Matrix Composition
• Composite Transformations
– Pivot-Point Rotation
– General Fixed-Point Scaling
– Reflection and Shearing
– Transformations Between Coordinate Systems
Geometric Transformation
• Definition
World Coordinates
Example: 2D Scaling
Modeling
Coordinates
Scale(0.3, 0.3)
World Coordinates
Example: 2D Rotation
Modeling
Coordinates
Scale(0.3, 0.3)
Rotate(-90)
World Coordinates
Example: 2D Translation
Modeling
Coordinates
Scale(0.3, 0.3)
Rotate(-90)
Translate(5, 3)
World Coordinates
Example: 2D Geometric
Transformation
Modeling
Coordinates
Again?
World Coordinates
Example: 2D Geometric
Transformation
Modeling
Coordinates
Scale
Translate
Scale
Rotate
Translate
World Coordinates
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
–
x x cosθ - y sinθ
–
y y sinθ y cosθ
• Shear
–
– x x hx y
y y hy x
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
– Transformations
x x cosθ - y sinθ
– can be combined
y y sinθ y cosθ
• Shear (with simple algebra)
–
– x x hx y
y y hy x
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
–
x x cosθ - y sinθ
–
y y sinθ y cosθ
• Shear
x x sx
–
– x x hx y
y y sy
y y hy x
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
–
x x cosθ - y sinθ
–
y y sinθ y cosθ
• Shear
x ((x sx) cos (y sy) sin )
–
– x x hx y
y ((x sx) sin (y sy) cos )
y y hy x
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
–
x x cosθ - y sinθ
–
y y sinθ y cosθ
• Shear
x ((x sx) cos (y sy) sin ) tx
–
– x x hx y
y ((x sx) sin (y sy) cos ) ty
y y hy x
Basic 2D Transformations
• Translation
– x x tx
– y y ty
• Scale
– x x sx
– y y sy
• Rotation
–
x x cosθ - y sinθ
–
y y sinθ y cosθ
• Shear
x ((x sx) cos (y sy) sin ) tx
–
– x x hx y
y ((x sx) sin (y sy) cos ) ty
y y hy x
Matrix Representation
• Represent a 2D Transformation by a Matrix
a b
c d
Rotate Shear
Homogeneous Coordinates
• Add a 3rd coordinate to every 2D point
– (x, y, w) represents a point at location (x/w, y/w)
– (x, y, 0) represents a point at infinity
– (0, 0, 0) Is not yallowed
2 (2, 1, 1) or (4, 2, 2) or (6, 3, 3)
1
x
1 2
T x f , y f S sx , sy T x f , y f S x f , y f , sx , sy
1 0 xf s x 0 0 1 0 x f s x 0 x f (1 s x )
0 1 yf 0 sy 0 0 1 y f 0 sy y f (1 s y )
0 0 1 0 0 1 0 0 1 0 0 1
cgvr.korea.ac.kr
Reflection
• Reflection with respect to the axis
• x • y • xy
1 0 0 1 0 0
1 0 0 0 1
0 1 0 0 0 1 0
0 0 1 0 0 1
0 0 1
y 1 y y
1 1’ 1’
2 3 2 3 3’ 2 3’ 2
x x 3 x
2’ 3’ 1
1’ 2
Reflection
Reflection with respect to a Line
y
0 1 0
1 0 0
x
0 0 1
y=x
Clockwise rotation of 45 Reflection about the x
axis Counterclockwise rotation of 45
y y 1
y
2 3
x x
2’ 3’ x
1’
Shear
• Converted to a parallelogram y y
(0,1) (1,1)
1 sh x 0 (2,1) (3,1)
0 1 0
(0,0) (1,0) x
(0,0) (1,0)
x
0 0 1
x’ = x + shx · y, y’ = y
x (Shx=2)
• Transformed to a shifted parallelogram
(Y = Yref)
y y
(1,1) (1,1) (2,1)
1 shx shx y ref (0,1)
0 1 0 (1/2,0)
(0,0) (1,0)
x (3/2,0) x
0 0 1
(0,-1)
x’ = x + shx · (y-yref), y’ = y
(Shx=1/2, yref=-1)
Shear
• Transformed to a shifted parallelogram
(X = Xref)
(1,2)
1 0 0 y
(0,3/2)
y
sh 1 sh y x ref (1,1)
y (0,1)
(0,1/2) (1,1)
0 0 1
x x
(0,0) (1,0) (-1,0)
x’ = x, y’ = shy · (x-xref) + y
(Shy=1/2, xref=-1)