Computer Graphics

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 22

TRANSFORMATIONS

Transformations are central in computer


graphics. They are used to map from one space to
another along the graphics pipeline;

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

Now column vec tor


 x   s x 0  x 
P  S  P or  y   0 s y   y 
.
  
7
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

Now row vector


sx 0
P  P.S or [ x' y' ]  [ x y] .
0 s y 
8
Example : Scale the polygon with coordinates
A(2,5), B(7,10) and C(10,2) by 2 units in x
direction and 2 units in y direction.

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.

x  r. cos(   )  r. cos  . cos  r. sin  . sin 


y y  r. sin(    )  r. cos  . sin   r. sin  . cos

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(   )  r. cos  . cos  r. sin  . sin 


y  r. sin(    )  r. cos  . sin   r. sin  . cos
Substituting for r :

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

Rewriting in matrix form gives us (Column Vector) :

 x cos  sin    x 


 y   sin  . 
cos   y 
  

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

Rewriting in matrix form gives us : (ROW VECTOR)

 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.

Find the matrix that represents rotation of an


object by 30 degree about the origin.

What are the new coordinates of the point P(2,-4)


after the rotation.

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

You might also like