Computer Graphics
Computer Graphics
1
WHERE ARE TRANSFORMATIONS USED?
Translation
Scaling
Rotation
2
TRANSLATION
It is process of changing the position of an object
in a straight line path from one coordinate
location another.
We can translate a 2D point by adding
translation distances dx and dy to the original
coordinate position (x,y) to move the point to a
new position (x’,y’).
3
2D TRANSLATIONS
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
4
Note : Column Vector representation for a point for standard Mathematical
Notation.
Example : Translate a polygon with coordinates
A(2,5) , B(7,10) and C(10,2) by 3 units in x
direction and 4 units in y direction.
5
SCALING
A scaling transformation changes the size of an
object.
This operation can be carried out for polygon by
multiplying the coordinate values (x,y) of each
vertex by scaling factors sx and sy to produce the
transformed coordinates (x’, y’).
6
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’
P
sx 0
S
0 s y
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’
P
sx 0
S
0 s y
9
ROTATION
A 2D rotation is applied to an object by
repositioning it along a circular path in the xy
plane. To generate a rotation, we specify a
rotation angle ө and the position of the rotation
point about which the object is to be rotated.
10
2D ROTATION ABOUT THE ORIGIN.
P’(x’,y’)
P(x,y)
r
r
x
11
2D ROTATION ABOUT THE ORIGIN.
y
P’(x’,y’)
r
P(x,y) x r. cos
y r. sin
y
r
x
x 12
2D ROTATION ABOUT THE ORIGIN.
P’(x’,y’)
P(x,y)
r x r. cos
y r. sin
y
r
x
x 13
2D ROTATION ABOUT THE ORIGIN.
x r. cos
y r. sin
Gives us :
x x. cos y. sin
y x. sin y. cos
14
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 15
2D ROTATION ABOUT THE ORIGIN.
x x. cos y. sin
y x. sin y. cos
cos sin
[ x’ y’ ] = [x y] .
sin cos
cos sin
Define the matrix R , P P R
sin cos 16
Example :
A point (4,3) is rotated counterclockwise by an
angle of 45 degree. Find the rotation matrix
and the resultant point.
17
TRANSFORMATIONS
Simple transformation
Translation
Rotation
Scaling
18
TRANSFORMATIONS
Deformable transformations
Shearing
Tapering
Twisting
Etc..
Issues
Can be combined
Are these operations invertible?
19
TRANSFORMATIONS
Why use transformations?
Position objects in a scene (modeling)
Change the shape of objects
Create multiple copies of objects
Projection for virtual cameras
Animations
20
CLASSES OF TRANSFORMATION
Rigid-Body/ Euclidean transformation
Similarity Transforms
Linear Transforms
Affine Transforms
Projective Transforms
21
TRANSFORMATIONS
Simple transformation
Translation
Rotation
Scaling
22