SlideShare a Scribd company logo
April 2010 1
Geometric Transformations for
Computer Graphics
Shmuel Wimer
Bar Ilan Univ., School of Engineering
April 2010 2
2D Translation
P

P
T
x
y
,
, ,
x y
x
y
x x t y y t
t
x x
t
y y
 
   
  
   

   
   

     
 
P P T
P P T
April 2010 3
2D Rotation
x
y
r
x
r
y

 
Rotation in angle about a
pivot (rotation) point , .
r r
x y

x
y

 
,
r r
x y
 
,
x y
 
 
,
x y
   
   
 
cos sin
sin cos
cos sin
sin cos
r r r
r r r
r r
x x x x y y
y y x x y y
 
 
 
 
    
    
   

 
 
 
P P R P P
R
April 2010 4
2D Scaling
x
S
y
S
,
0
0
x y
x
y
x x s y y s
s
x x
s
y y
 
   
  
   
 
   

   
 
 
P S P
x
y
 
,
f f
x y
 
 
 
1
1
x f x
y f y
f
x x s x s
y y s y s
   
   
   
P P S P 1-S
 
Scaling about a fixed point ,
f f
x y
April 2010 5
Homogeneous Coordinates
1 2
1 2
Rotate and then displace a point :
: 2 2 rotation matrix. : 2 1 displacement vector.
 
 
P P = M P + M
M M
Displacement is unfortunately a non linear operation.
   
Make displacement linear with .
, , ,1 . Transformations turn into 3 3 matrices.
x y x y
 
Homoheneous Coordinates
Very big advantage. All transformations are concatenated by
matrix multiplication.
April 2010 6
 
1 0
0 1 , ,
1 0 0 1 1
x
y x y
x t x
y t y t t

     
     
 
   
     
     
     
P T P
2D Translation
 
cos sin 0
sin cos 0 ,
1 0 0 1 1
x x
y y
 
  
 
     
     
 
   
     
     
     
P R P
2D Rotation
 
0 0
0 0 , ,
1 0 0 1 1
x
y x y
x S x
y S y S S

     
     
 
   
     
     
     
P S P
2D Scaling
April 2010 7
1 1 1
1 0 cos sin 0 1 0 0
0 1 , sin cos 0 , 0 1 0
0 0 1 0 0 1 0 0 1
x x
y y
t S
t S
 
 
  

     
     
    
     
     
     
T R S
Inverse transformations:
   
2 1 2 1
      
P M M P M M P M P
Composite transformations:
   
     
 
     
2 2 1 1 2 2 1 1
2 1 1 2
2 1 1 2
2 2 1 1 1 2 1 2
, , , ,
1 0 1 0 1 0
0 1 0 1 0 1
0 0 1 0 0 1 0 0 1
, , ,
x y x y x y x y
x x x x
y y y y
x y x y x x y y
t t t t t t t t
t t t t
t t t t
t t t t t t t t
    

     
     
  
     
     
     
   
P T T P T T P
T T T
Composite translations:
April 2010 8
   
     
 
     
 
2 1 2 1
2 1 1 2
1 2
   
   
 
    
  
  
P R R P R R P
R R R
P R P
Composite Rotations:
     
2 1 1 2
2 1 1 2
2 2 1 1 1 2 1 2
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 0 0 1 0 0 1
, , ,
x x x x
y y y y
x y x y x x y y
S S S S
S S S S
S S S S S S S S

     
     
  
     
     
     
   
S S S
Composite Scaling:
April 2010 9
General 2D Rotation
Move to origin Rotate Move back
 
 
1 0 cos sin 0 1 0
0 1 sin cos 0 0 1
0 0 1 0 0 1 0 0 1
cos sin 1 cos sin
sin cos 1 cos sin
0 0 1
r r
r r
r r
r r
x x
y y
x y
y x
 
 
   
   
 
     
     
   
     
     
     
  
 
 
 
 
 
 
 
,
r r
x y
April 2010 10
General 2D Scaling
Move to origin Scale Move back
 
 
0 1
1 0 0 0 1 0
0 1 0 0 0 1 0 1
0 0 1 0 0 1 0 0 1 0 0 1
x f x
f x f
f y f y f y
S x S
x S x
y S y S y S

 

     
 
     
    
 
     
 
     
       
 
,
f f
x y
April 2010 11
2D Directional Scaling
y
x
2
S
1
S

     
 
 
1
1 2
2 2
1 2 2 1
2 2
2 1 1 2
,
cos sin cos sin 0
cos sin sin cos 0
0 0 1
S S
S S S S
S S S S
 
   
   

  
 
 
 
 
 
 
 
R S R
y
x
y
x
1
2
O
1
2
45
S
S




April 2010 12
2D Reflections
x
y
x
y
x
y
1 0 0
0 1 0
0 0 1
 
 

 
 
 
1 0 0
0 1 0
0 0 1

 
 
 
 
 
1 0 0
0 1 0
0 0 1

 
 

 
 
 
April 2010 13
0 1 0
1 0 0
0 0 1
 
 
 
 
 
3
1
2
1
2
3
y x
 y x

1
2
3
1
2
3
0 1 0
1 0 0
0 0 1

 
 

 
 
 
April 2010 14
Geometric Transformations by Rasterization
• The transformed shape needs to be filled.
– A whole scan-line filling is usually in order.
• However, simple transformations can save new filling by
manipulating blocks in the frame buffer.
min
P
max
P
0
P
Translation:
Move block of pixels of frame buffer into new destination.
April 2010 15
1 2 3
4 5 6
7 8 9
10 11 12
 
 
 
 
 
 
3 6 9 12
2 5 8 11
1 4 7 10
 
 
 
 
 
90° counterclockwise rotation
12 11 10
9 8 7
6 5 4
3 2 1
 
 
 
 
 
 
180° rotation
Rotated pixel block
Destination pixel array
RGB of destination pixel can
be determined by averaging
rotated ones (as antialiasing)
April 2010 16
Translation
 
, ,
x y z
 
, ,
x y z
  
x
y
z
x
y
z
x x t
y y t
z z t
 
 
 
3D Transformations
1 0 0
0 1 0
0 0 1
1 0 0 0 1 1
x
y
z
x t x
y t y
z t z

     
     

     
 

     
     
     
Very similar to 2D. Using 4x4 matrices rather than 3x3.
April 2010 17
General 3D Rotation
1. Translate the object such that rotation axis passes
through the origin.
2. Rotate the object such that rotation axis coincides with
one of Cartesian axes.
3. Perform specified rotation about the Cartesian axis.
4. Apply inverse rotation to return rotation axis to original
direction.
5. Apply inverse translation to return rotation axis to
original position.
April 2010 18
x
z
y
2
P
1
P
x
z
y
2
P
1
P
x
z
y
1
P
2
P

x
z
y
1
P
2
P
 
x
z
y
2
P
1
P
x
z
y
2
P
1
P
April 2010 19
 
1 2
2 1 2 1 2 1 2 1
The vector from to is:
, ,
x x y y z z
     
P P
V P P
 
 
 
 
2 1
2 1
2 1
2 2 2
Unit rotation vector: | | , ,
| |
| |
| |
1
a b c
a x x
b y y
c z z
a b c
 
 
 
 
  
u V V
V
V
V
1
1
1
1 0 0
0 1 0
0 0 1
0 0 0 1
x
y
z

 
 

 

 

 
 
T
 
, ,
a b c

u
x
y
z
April 2010 20
Rotating to coincide with axis
z
u
 
2 2
2 2
First rotate around axis to lay in plane.
Equivqlent to rotation 's projection on plane around axis.
cos , sin .
We obtained a unit vector ,0, in plane.
x x z
y z x
c b c c d b d
a b c d x z
 


   
   
u
u
w
 
1 0 0 0
0 0
0 0
0 0 0 1
x
c d b d
b d c d

 
 

 

 
 
 
R
 
, ,
a b c

u
x
y
z


u

April 2010 21
 
, ,
a b c

u
x
y
z

 
,0,
a d

w
2 2
Rotate counterclockwise around axis.
is a unit vector whose component is , component is 0,
hence component is .
y
x a y
z b c d
 
  
w
w
cos , sin
d a
 
 
 
0 0
0 1 0 0
0 0
0 0 0 1
y
d a
a d

 
 
 

 

 
 
R
           
1 1 1
x y z y x
     
  
      
R T R R R R R T
April 2010 22
 
cos sin 0 0
sin cos 0 0
0 0 1 0
0 0 0 1
z
 
 


 
 
 

 
 
 
R
           
1 1 1
x y z y x
     
  
      
R T R R R R R T
 
     
     
     
2
2
2
1 cos cos 1 cos sin 1 cos sin
1 cos sin 1 cos cos 1 cos sin
1 cos sin 1 cos sin 1 cos cos
R
a ab c ac b
ba c b bc a
ca b cb a c

     
     
     

 
     
 
     
 
 
     
 
M
April 2010 23
Efficient 3D Rotations by Quaternions
   
Quaternions are extensions of complex numbers to 4-dimension.
, : real , , : imaginary
q s ia jb kc s s a b c
     
v v
2 2 2
1, , ,
i j k ij ji k jk kj i ki ik j
        
 
 
1 2 1 2
1 2 1 2 1 2 2 1
Addition: ,
Multiplication: ,
q q s s
q q s s s s
   
    
1 2
1 2 1 2
v v
v v v + v v v
   
2 2 1 1 1
2
1
, , , 1,0
q s q s qq q q
q
  
      
v v v
April 2010 24
x
z
y

u
 
Rotate a point position , , about the unit vector .
x y z

p u
   
Quarternion representation:
Rotation: cos , sin
2 2
Position: 0, , , ,
q
x y z
 
 
 
 
 
u
P p p
     
 
1 2
Rotation of is carried out with the quarternion operation:
0, 2
This can be calculated by efficient HW for fast 3D rotations
when many rotation operations are involved.
q q s s

        
P
P P p v p v v p v v p
April 2010 25
3D Scaling
x
y
z x
y
z
x
y
z
x x S
y y S
z x S
 
 
 
Enlarging object also moves it from origin
0 0 0
0 0 0
0 0 0
1 0 0 0 1 1
x
y
z
x S x
y S y
z S z

     
     

     
    

     
     
     
P S P
April 2010 26
 
, ,
f f f
x y z
x
y
z
Scaling with respect to a fixed point (not necessarily of object)
 
, ,
f f f
x y z
x
y
z
 
, ,
f f f
x y z
x
y
z
 
, ,
f f f
x y z
x
y
z
 
 
 
1
0 0 1
0 0 1
0 0 1
0 0 0 1
x x f
y y f
z z f
S S x
S S y
S S z


 
 

 
   

 
 
 
T S T

More Related Content

PDF
2D Translation.pdf
PPTX
Transformations computer graphics
PPT
Modeling Transformations
PPT
2D_transformatiomcomputer graphics 2d translation, rotation and scaling trans...
PPT
2 d transformations by amit kumar (maimt)
PPT
Two dimensional_Transformations Notes.ppt
PPT
06.Transformation.ppt
PPTX
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2D Translation.pdf
Transformations computer graphics
Modeling Transformations
2D_transformatiomcomputer graphics 2d translation, rotation and scaling trans...
2 d transformations by amit kumar (maimt)
Two dimensional_Transformations Notes.ppt
06.Transformation.ppt
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx

Similar to 2D Geometric_Transformations in graphics.ppt (20)

PPT
2 d transformation
PPT
09transformation3d
PPT
transformation 3d
PDF
3-D Transformation in Computer Graphics
PPTX
Part 2- Transformation.pptx
PPTX
Part 3- Manipulation and Representation of Curves.pptx
PPTX
Part 2- Geometric Transformation.pptx
PPT
GeometricTransformations.ppt
PPT
Transformations
PPTX
moule 3 ppt1 basic 2D transformations.pptx
PPTX
Three dimensional transformations
PPT
“Transformations are the operations applied to geometrical description of an ...
PPTX
Two dimensionaltransformations
PPTX
Three dimensional geometric transformations
PPTX
2D Transformation
PPT
Transforms UNIt 2
PDF
3D transformation and viewing
PPT
2d transformation
PPT
Cs8092 computer graphics and multimedia unit 2
PPTX
Computer Graphic - Transformations in 2D
2 d transformation
09transformation3d
transformation 3d
3-D Transformation in Computer Graphics
Part 2- Transformation.pptx
Part 3- Manipulation and Representation of Curves.pptx
Part 2- Geometric Transformation.pptx
GeometricTransformations.ppt
Transformations
moule 3 ppt1 basic 2D transformations.pptx
Three dimensional transformations
“Transformations are the operations applied to geometrical description of an ...
Two dimensionaltransformations
Three dimensional geometric transformations
2D Transformation
Transforms UNIt 2
3D transformation and viewing
2d transformation
Cs8092 computer graphics and multimedia unit 2
Computer Graphic - Transformations in 2D
Ad

Recently uploaded (20)

DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
master seminar digital applications in india
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Types and Its function , kingdom of life
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
Lesson notes of climatology university.
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Module 4: Burden of Disease Tutorial Slides S2 2025
Paper A Mock Exam 9_ Attempt review.pdf.
Cell Structure & Organelles in detailed.
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
A systematic review of self-coping strategies used by university students to ...
Microbial diseases, their pathogenesis and prophylaxis
master seminar digital applications in india
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
Yogi Goddess Pres Conference Studio Updates
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
History, Philosophy and sociology of education (1).pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
Lesson notes of climatology university.
Ad

2D Geometric_Transformations in graphics.ppt

  • 1. April 2010 1 Geometric Transformations for Computer Graphics Shmuel Wimer Bar Ilan Univ., School of Engineering
  • 2. April 2010 2 2D Translation P  P T x y , , , x y x y x x t y y t t x x t y y                                P P T P P T
  • 3. April 2010 3 2D Rotation x y r x r y    Rotation in angle about a pivot (rotation) point , . r r x y  x y    , r r x y   , x y     , x y           cos sin sin cos cos sin sin cos r r r r r r r r x x x x y y y y x x y y                              P P R P P R
  • 4. April 2010 4 2D Scaling x S y S , 0 0 x y x y x x s y y s s x x s y y                             P S P x y   , f f x y       1 1 x f x y f y f x x s x s y y s y s             P P S P 1-S   Scaling about a fixed point , f f x y
  • 5. April 2010 5 Homogeneous Coordinates 1 2 1 2 Rotate and then displace a point : : 2 2 rotation matrix. : 2 1 displacement vector.     P P = M P + M M M Displacement is unfortunately a non linear operation.     Make displacement linear with . , , ,1 . Transformations turn into 3 3 matrices. x y x y   Homoheneous Coordinates Very big advantage. All transformations are concatenated by matrix multiplication.
  • 6. April 2010 6   1 0 0 1 , , 1 0 0 1 1 x y x y x t x y t y t t                                      P T P 2D Translation   cos sin 0 sin cos 0 , 1 0 0 1 1 x x y y                                            P R P 2D Rotation   0 0 0 0 , , 1 0 0 1 1 x y x y x S x y S y S S                                      P S P 2D Scaling
  • 7. April 2010 7 1 1 1 1 0 cos sin 0 1 0 0 0 1 , sin cos 0 , 0 1 0 0 0 1 0 0 1 0 0 1 x x y y t S t S                                            T R S Inverse transformations:     2 1 2 1        P M M P M M P M P Composite transformations:                   2 2 1 1 2 2 1 1 2 1 1 2 2 1 1 2 2 2 1 1 1 2 1 2 , , , , 1 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 , , , x y x y x y x y x x x x y y y y x y x y x x y y t t t t t t t t t t t t t t t t t t t t t t t t                                            P T T P T T P T T T Composite translations:
  • 8. April 2010 8                     2 1 2 1 2 1 1 2 1 2                      P R R P R R P R R R P R P Composite Rotations:       2 1 1 2 2 1 1 2 2 2 1 1 1 2 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 , , , x x x x y y y y x y x y x x y y S S S S S S S S S S S S S S S S                                       S S S Composite Scaling:
  • 9. April 2010 9 General 2D Rotation Move to origin Rotate Move back     1 0 cos sin 0 1 0 0 1 sin cos 0 0 1 0 0 1 0 0 1 0 0 1 cos sin 1 cos sin sin cos 1 cos sin 0 0 1 r r r r r r r r x x y y x y y x                                                                  , r r x y
  • 10. April 2010 10 General 2D Scaling Move to origin Scale Move back     0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 x f x f x f f y f y f y S x S x S x y S y S y S                                                  , f f x y
  • 11. April 2010 11 2D Directional Scaling y x 2 S 1 S            1 1 2 2 2 1 2 2 1 2 2 2 1 1 2 , cos sin cos sin 0 cos sin sin cos 0 0 0 1 S S S S S S S S S S                             R S R y x y x 1 2 O 1 2 45 S S    
  • 12. April 2010 12 2D Reflections x y x y x y 1 0 0 0 1 0 0 0 1            1 0 0 0 1 0 0 0 1            1 0 0 0 1 0 0 0 1            
  • 13. April 2010 13 0 1 0 1 0 0 0 0 1           3 1 2 1 2 3 y x  y x  1 2 3 1 2 3 0 1 0 1 0 0 0 0 1            
  • 14. April 2010 14 Geometric Transformations by Rasterization • The transformed shape needs to be filled. – A whole scan-line filling is usually in order. • However, simple transformations can save new filling by manipulating blocks in the frame buffer. min P max P 0 P Translation: Move block of pixels of frame buffer into new destination.
  • 15. April 2010 15 1 2 3 4 5 6 7 8 9 10 11 12             3 6 9 12 2 5 8 11 1 4 7 10           90° counterclockwise rotation 12 11 10 9 8 7 6 5 4 3 2 1             180° rotation Rotated pixel block Destination pixel array RGB of destination pixel can be determined by averaging rotated ones (as antialiasing)
  • 16. April 2010 16 Translation   , , x y z   , , x y z    x y z x y z x x t y y t z z t       3D Transformations 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 x y z x t x y t y z t z                                          Very similar to 2D. Using 4x4 matrices rather than 3x3.
  • 17. April 2010 17 General 3D Rotation 1. Translate the object such that rotation axis passes through the origin. 2. Rotate the object such that rotation axis coincides with one of Cartesian axes. 3. Perform specified rotation about the Cartesian axis. 4. Apply inverse rotation to return rotation axis to original direction. 5. Apply inverse translation to return rotation axis to original position.
  • 19. April 2010 19   1 2 2 1 2 1 2 1 2 1 The vector from to is: , , x x y y z z       P P V P P         2 1 2 1 2 1 2 2 2 Unit rotation vector: | | , , | | | | | | 1 a b c a x x b y y c z z a b c            u V V V V V 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 x y z                 T   , , a b c  u x y z
  • 20. April 2010 20 Rotating to coincide with axis z u   2 2 2 2 First rotate around axis to lay in plane. Equivqlent to rotation 's projection on plane around axis. cos , sin . We obtained a unit vector ,0, in plane. x x z y z x c b c c d b d a b c d x z             u u w   1 0 0 0 0 0 0 0 0 0 0 1 x c d b d b d c d                R   , , a b c  u x y z   u 
  • 21. April 2010 21   , , a b c  u x y z    ,0, a d  w 2 2 Rotate counterclockwise around axis. is a unit vector whose component is , component is 0, hence component is . y x a y z b c d      w w cos , sin d a       0 0 0 1 0 0 0 0 0 0 0 1 y d a a d                R             1 1 1 x y z y x                 R T R R R R R T
  • 22. April 2010 22   cos sin 0 0 sin cos 0 0 0 0 1 0 0 0 0 1 z                    R             1 1 1 x y z y x                 R T R R R R R T                     2 2 2 1 cos cos 1 cos sin 1 cos sin 1 cos sin 1 cos cos 1 cos sin 1 cos sin 1 cos sin 1 cos cos R a ab c ac b ba c b bc a ca b cb a c                                                 M
  • 23. April 2010 23 Efficient 3D Rotations by Quaternions     Quaternions are extensions of complex numbers to 4-dimension. , : real , , : imaginary q s ia jb kc s s a b c       v v 2 2 2 1, , , i j k ij ji k jk kj i ki ik j              1 2 1 2 1 2 1 2 1 2 2 1 Addition: , Multiplication: , q q s s q q s s s s          1 2 1 2 1 2 v v v v v + v v v     2 2 1 1 1 2 1 , , , 1,0 q s q s qq q q q           v v v
  • 24. April 2010 24 x z y  u   Rotate a point position , , about the unit vector . x y z  p u     Quarternion representation: Rotation: cos , sin 2 2 Position: 0, , , , q x y z           u P p p         1 2 Rotation of is carried out with the quarternion operation: 0, 2 This can be calculated by efficient HW for fast 3D rotations when many rotation operations are involved. q q s s           P P P p v p v v p v v p
  • 25. April 2010 25 3D Scaling x y z x y z x y z x x S y y S z x S       Enlarging object also moves it from origin 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 x y z x S x y S y z S z                                             P S P
  • 26. April 2010 26   , , f f f x y z x y z Scaling with respect to a fixed point (not necessarily of object)   , , f f f x y z x y z   , , f f f x y z x y z   , , f f f x y z x y z       1 0 0 1 0 0 1 0 0 1 0 0 0 1 x x f y y f z z f S S x S S y S S z                     T S T