You are on page 1of 18

Geometric

Transformations
Geometric Transformations
 Basic transformations:
 Translation
 Scaling
 Rotation
 Purposes:
 To move the position of objects
 To alter the shape / size of objects
 To change the orientation of objects
Homogeneous Coordinates
 A point (x,y) can be re-written in homogeneous
coordinates as (xh, yh, h)
 The homogeneous parameter h is a non-zero value
such that:
xh yh
x y
h h

 We can then write any point (x,


y) as (hx, hy, h)
 We can conveniently choose h = 1 so that
(x, y) becomes (x, y, 1)
Why Homogeneous Coordinates?

 Mathematicians commonly use homogeneous


coordinates as they allow scaling factors to be
removed from equations
 All the transformations previously defined can be
represented as 3*3 matrices
 Using homogeneous coordinates allows us use
matrix multiplication to calculate transformations
– extremely efficient!
Homogenous Coordinates

 Combine the geometric transformation into a single matrix with 3by3 matrices
 Expand each 2D coordinate to 3D coordinate with homogenous parameter
 Two-Dimensional translation matrix

 x'   1 0 t x   x 
     
y '
    0 1 t y   y
 1  0 0 1  1
 Two-Dimensional rotation matrix
x' cos   cos  0 x 
     
y'   sin cos  0  y 
 1   0 0 1 1

 Two-Dimensional scaling matrix


x' s x 0 0  x 
     
 y'    0 sy 0   y 
 1   0 0 1  1
Inverse transformations

 Inverse translation matrix


1 0  t x 
 
T 1  0 1  t y 
0 0 1 

 Two-Dimensional Rotation matrix


 cos  sin 0
 
R 1   sin cos  0
 0 0 1

 Two-Dimensional Scaling matrix


 1 
s 0 0
 x 
0 0
1
S 1
 sx 
0 0 1
 
 
Basic 2D Transformations

 Basic 2D transformations as 3x3 Matrices


 x  1 0 tx  x   x   sx 0 0  x 
 y  0 1 ty  y   y  0 sy 0  y 
         
1  0 0 1  1  1  0 0 1  1 
Translate Scale

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

Rotate
Matrix Concatenation Properties

 Associative properties
A  B  C  A  (B  C )  ( A  B )  C

 Transformation product is not commutative .


(i.e) A.B is not equal to B.A
Two-dimensional composite transformation

 Composite transformation
 A sequence of transformations
 Calculate composite transformation matrix rather
than applying individual transformations
P'  M2  M1  P
P'  M  P
 Composite two-dimensional translations
 Apply two successive translations, T1 and T2
T1  T (t1x , t1 y )
T2  T (t 2 x , t2 y )
P'  T2  (T1  P)  (T2  T1 )  P
 Composite transformation matrix in coordinate form
T( t 2 x , t 2 y )  T( t 1x , t 1y )  T( t 1x  t 2 x , t 1y  t 2 y )
Two-dimensional composite transformation (2)

 Composite two-dimensional rotations


 Two successive rotations, R1 and R2 into a point P
P'  R(1 )  {R( 2 )  P}
P'  {R(1 )  R( 2 )}  P

 Multiply two rotation matrices to get composite transformation


matrix
R(1 )  R( 2 )  R(1   2 )
P'  R(1   2 )  P
 Composite two-dimensional scaling

S(s1x , s1y )  S(s 2 x , s 2 y )  S(s1x  s 2 x , s1y  s 2 y )


P'  S(s1x  s 2 x , s1y  s 2 y )  P
Two-dimensional composite transformation

 General two-dimensional Pivot-point rotation


 Graphics package provide only origin rotation
 Perform a translate-rotate-translate sequence
 Translate the object to move pivot-point position to origin
 Rotate the object
 Translate the object back to the original position

 Composite matrix in coordinates form

T( x r , y r )  R( )  T(x r ,y r )  R( x r , y r , )


Two-dimensional composite transformation (4)

 Example of pivot-point rotation


Pivot-Point Rotation

(xr,y (xr,y (xr,y (xr,y


r) r) r) r)

Translate Rotate Translate

T xr , yr  R  T  xr , yr   Rxr , yr , 


1 0 x r  cos   sin  0 1 0  x r  cos   sin  x r (1  cos  )  y r sin  
0 1 y    sin  cos  0  0 1  y    sin  cos  y (1  cos  )  x sin  
 r    r  r r 
0 0 1   0 0 1 0 0 1   0 0 1 
Two-dimensional composite transformation (5)

 General two-dimensional Fixed-point scaling


 Perform a translate-scaling-translate sequence
 Translate the object to move fixed-point position to origin
 Scale the object wrt. the coordinate origin
 Use inverse of translation in step 1 to return the object
back to the original position
 Composite matrix in coordinates form
T( x f , y f )  S(s x , s y )  T(  x f , y f )  S( x f , y f , s x , s y )
Two-dimensional composite transformation (6)

 Example of fixed-point scaling


General Fixed-Point Scaling

(xr,y (xr,y (xr,y (xr,y


r) r) r) r)

Translate Scale Translate

T x f , y f  S s x , s y  T  x f , y f   S x f , y f , s x , s y 
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 
Two-dimensional composite transformation (7)

 General two-dimensional scaling directions


 Perform a rotate-scaling-rotate sequence
 Composite matrix in coordinates form

R 1( )  S(s1, s 2 )  R( )


s1 cos 2   s 2 sin2  (s 2  s1 ) cos  sin 0
 
  (s 2  s1 ) cos  sin s1 sin2   s 2 cos 2  0
 0 0 1

s1


s2
General Scaling Directions

 Converted to a parallelogram
y y
(1/2,3/2) (2,2)
(0,1) (1,1)

(3/2,1/2)
(0,0) (1,0) x (0,0) x

Scale
 s1 cos 2   s2 sin 2  ( s2  s1 ) cos sin  0 y s2
 
R 1 ( )  S ( s1 , s2 )  R( )   ( s2  s1 ) cos sin  s1 sin 2   s2 cos 2  0
 0 0 1  xs
 1

You might also like