Lecture 6 Geometric transformations
Lecture 6 Geometric transformations
TRANSFORMATIONS
CCS 2208 COMPUTER GRAPHICS
2D Geometric Transformations
• What are geometric transformations?
• Operations that are applied to the geometric description of an
object to change its position, orientation, or size.
• Why the transformation is needed?
• To manipulate the initially created object and to display the
modified object without having to redraw it.
• 2 ways
• Object Transformation
• Alter the coordinates descriptions of an object
• Translation, rotation, scaling etc.
• Coordinate system unchanged
• Coordinate transformation
• Produce a different coordinate system
2D Geometric Transformations
• Basic Transformations
• Translation
• Rotation
• Scaling
• Other transformations
• Reflection
• Shear
Translation
• A translation moves all points in
an object along the same
straight-line path to new
positions.
• The path is represented by a ?
vector, called the translation or
shift vector.
ty=4
• We can write the components:
p'x = px + tx tx = 6
(2, 2)
p'y = py + ty
• or in matrix form:
P' = P + T Adding or subtracting a value to or
x’ x tx from a coordinate translates it in
y’ = y + ty space.
Translation (55,60)
x x tx
y y t y
(20,35)
(45,30)
(65,30)
x’ 10 35 45
y’ = 5 + 25 = 30
(10,5) (30,5)
y
=>sin (+ ) = y’/r
y’ = r. sin (+ ) x
• y’ = r.cossin + r.sincos x’ -Phi
• y’ = x.sin + y.cos -Theta
Rotation
• We can write the components:
p'x = px cos – py sin
p'y = px sin + py cos
• or in matrix form:
P' = R • P
• A positive value for the angle θ defines a counterclockwise
rotation about the pivot point, as in our example, and a
negative value rotates objects in the clockwise direction
• Rotation matrix
cos sin
R
sin cos
Rotation
• Example
• Find the transformed point, P’, caused by rotating
P= (5, 1) about the origin through an angle of 90.
cos sin x x cos y sin
sin
cos y x sin y cos
coordinates respectively.
• Scales are about the origin.
• We can write the components:
p'x = sx • px P
p'y = sy • py
x 1 0 t x x
y 0 1 t y , P T t , t P
2D Translation
y x y
1 0 0 1 1
x S x 0 0 x
2D Scaling y 0 S y 0 y , P S Sx , S y P
1 0 0 1 1
Homogeneous Transform Advantages
• Unified view of transformation as matrix multiplication
• Easier in hardware and software
y = y
Reflection
• Reflection about the y axis
• A reflection about the line x = 0 (the y axis)
• It flips x coordinates while keeping y coordinates the same
x = x
Reflection
• Reflection relative to the coordinate origin
• We flip both the x and y coordinates of a point by reflecting
relative to an axis that is perpendicular to the xy plane and
that passes through the coordinate origin
x = x
y = y
Reflection
• Reflection of an object relative to an axis
perpendicular to the xy plane through Preflect
Reflection
• Reflection about the line y = x
Reflections
x x hx y
y y
Scaling Yes No No No
x a1 x b1 y c1
y a 2 x b2 y c2
(a1b2 a 2 b1 0)
Transformation Matrix:
a1 b1 c1
a b2 c 2
2
0 0 1
Affine Transformation: Properties
• Product of affine transformations is affine.
Pmax
Pmin
P0
Translation:
Move block of pixels of frame buffer into new destination.
90° counterclockwise rotation
1 2 3 12 11 10
4 5 6 3 6 9 12 9 8 7
2 5 8 11
7 8 9 6 5 4
1 4 7 10
10 11 12 3 2 1
180° rotation