0% found this document useful (0 votes)
19 views18 pages

Lect 2

The document discusses different types of 2D transformations including translation, scaling, and rotation. It provides the mathematical definitions and matrix representations for translating, scaling, and rotating 2D points. It also covers combining multiple transformations using matrix multiplication and properties of different transformation types.

Uploaded by

abebaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views18 pages

Lect 2

The document discusses different types of 2D transformations including translation, scaling, and rotation. It provides the mathematical definitions and matrix representations for translating, scaling, and rotating 2D points. It also covers combining multiple transformations using matrix multiplication and properties of different transformation types.

Uploaded by

abebaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

COMPUTER GRAPHICS

Lecture 2
Transformations

Lecture 2 1
TRANSFORMATIONS.
What is a transformation?
 P=T(P)

What does it do?


Transform the coordinates / normal vectors of objects
Why use them?
 Modelling

-Moving the objects to the desired location in the environment


-Multiple instances of a prototype shape
-Kinematics of linkages/skeletons – character animation
• Viewing
– Virtual camera: parallel and perspective projections
2
TYPES OF TRANSFORMATIONS

– Geometric Transformations
• Translation
• Rotation
• scaling
• Linear (preserves parallel lines)
• Non-uniform scales, shears or skews
– Projection (preserves lines)
• Perspective projection
• Parallel projection
– Non-linear (lines become curves)
• Twists, bends, warps, morphs,

3
GEOMETRIC TRANSFORMATION
– Once the models are prepared, we need to place them in
the environment
– Objects are defined in their own local coordinate
system
– We need to translate, rotate and scale them to put them
into the world coordinate system

15/04/16 Lecture 1
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 vectors
 x  x  d x 
P    , P    , T   
 y  y  dy  P’
Now P

P  P  T

5
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
 x   s x 0  x 
P  S  P or  y   0 . 
   s y   y
6
2D ROTATION ABOUT THE ORIGIN.


P’(x’,y’)

P(x,y)
r

r
x
7
2D ROTATION ABOUT THE ORIGIN.
y

P’(x’,y’)

r
P(x,y) x  r. cos 
y  r. sin 
 y
r

x
x 8
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 9
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
10
2D ROTATION ABOUT THE ORIGIN.

x  x. cos  y. sin 
y  x. sin   y. cos
Rewriting in matrix form gives us :

 x  cos  sin    x 
 y   sin  . 
cos   y 
  

cos  sin  
Define the matrix R    , P  R  P
 sin  cos  11
TRANSFORMATIONS.
 Translation.
 P=T +P
 Scale
 P=S P
 Rotation  x cos  sin    x 
 y   sin  cos . y 
 P=R P     
 We would like all transformations to be multiplications so
we can concatenate them
  express points in homogenous coordinates.

12
CONCATENATION.

 When we perform 2 translations on the same point


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 )  P

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 )
13
CONCATENATION.

The matrix product T (d x1 , d y1 )  T (d x 2 , d y 2 ) is :


1 0 d x1  1 0 d x 2 
0 1 d .0 1 d   ?
 y1   y2 

0 0 1  0 0 1 
Matrix product is variously referred to as compounding,
concatenation, or composition
14
CONCATENATION.

The matrix product T (d x1 , d y1 )  T (d x 2 , d y 2 ) is :


1 0 d x1  1 0 d x 2  1 0 d x1  d x 2 
0 1 d .0 1 d   0 1 d  d 
 y1   y2   y1 y2 

0 0 1  0 0 1  0 0 1 

Matrix product is variously referred to as compounding, concatenation, or


composition.
15
PROPERTIES OF TRANSLATIONS.

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 )

Note : 3. translation matrices are commutative.


16
CONCATENATION OF SCALES.

The matrix product S ( s x1 , s y1 )  S ( s x 2 , s y 2 ) is :


s x1 0 0  s x2 0 0  s x1  s x2 0 0
0 s 0  . 0 s 0    0 s  s 0 
 y1  y2   y1 y2 
 0 0 1   0 0 1   0 0 1
Only diagonal elements in the matrix - easy to multiply !

17
PROPERTIES OF ROTATION.
R ( 0)  I
R ( )  R ( )  R (   )

and
R ( )  R ( )  R ( )  R ( )
But this is only because the axis of rotation
is the same
For 3D rotations, need to be more careful
18

You might also like