SlideShare uma empresa Scribd logo
1 de 52
Introduction to
                                           Computer Graphics
                                           CS 445 / 645

                                               Lecture 5
                                            Transformations
M.C. Escher – Smaller and Smaller (1956)
Modeling Transformations
Specify transformations for objects
  • Allows definitions of objects in own coordinate systems
  • Allows use of object definition multiple times in a scene
    – Remember how OpenGL provides a transformation stack
      because they are so frequently reused


Chapter 5 from Hearn and Baker

                                                     H&B Figure 109
Overview
2D Transformations
  • Basic 2D transformations
  • Matrix representation
  • Matrix composition

3D Transformations
  • Basic 3D transformations
  • Same as 2D
2D Modeling Transformations
      Modeling
     Coordinates
                         Scale
 y                     Translate

                   x



       Scale
      Rotate
     Translate


                                   World Coordinates
2D Modeling Transformations
      Modeling
     Coordinates
 y

                   x




        Let’s look
        at this in
        detail…

                       World Coordinates
2D Modeling Transformations
      Modeling
     Coordinates
 y

                   x



     Initial location
     at (0, 0) with
     x- and y-axes
     aligned
2D Modeling Transformations
      Modeling
     Coordinates
 y

                   x



  Scale .3, .3
  Rotate -90
 Translate 5, 3
2D Modeling Transformations
      Modeling
     Coordinates
 y

                   x



  Scale .3, .3
  Rotate -90
 Translate 5, 3
2D Modeling Transformations
      Modeling
     Coordinates
 y

                   x



  Scale .3, .3
  Rotate -90
 Translate 5, 3


                       World Coordinates
Scaling
Scaling a coordinate means multiplying each of its
  components by a scalar
Uniform scaling means this scalar is the same for all
  components:




                          ×2
Scaling
Non-uniform scaling: different scalars per component:




                       X × 2,
                       Y × 0.5

How can we represent this in matrix form?
Scaling


 Scaling operation:       x' ax 
                          y ' = by 
                            


 Or, in matrix form:    x ' a     0  x 
                        y ' = 0      y 
                                     b  
                         
                             scaling matrix
2-D Rotation
          (x’, y’)

                     (x, y)

                       x’ = x cos(θ) - y sin(θ)
     θ                 y’ = x sin(θ) + y cos(θ)
2-D Rotation
                      x = r cos (φ)
                      y = r sin (φ)
                      x’ = r cos (φ + θ)
                      y’ = r sin (φ + θ)
      (x’, y’)
                      Trig Identity…
             (x, y)   x’ = r cos(φ) cos(θ) – r sin(φ) sin(θ)
                      y’ = r sin(φ) sin(θ) + r cos(φ) cos(θ)


  θ   φ
                      Substitute…
                      x’ = x cos(θ) - y sin(θ)
                      y’ = x sin(θ) + y cos(θ)
2-D Rotation
This is easy to capture in matrix form:

              x ' cos(θ )      − sin (θ )  x 
              y ' = sin (θ )   cos(θ )  y 
                                           
Even though sin(θ) and cos(θ) are nonlinear functions
 of θ,
  • x’ is a linear combination of x and y
  • y’ is a linear combination of x and y
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:
   • x’ = x * sx
   • y’ = y * sy

Shear:                        Transformations
   • x’ = x + hx*y            can be combined
   • y’ = y + hy*x
                            (with simple algebra)
Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:
   • x’ = x * sx
   • y’ = y * sy

Shear:
   • x’ = x + hx*y
   • y’ = y + hy*x

Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:                                  (x,y)
   • x’ = x * sx            (x’,y’)
   • y’ = y * sy

Shear:
   • x’ = x + hx*y
                            x’ = x*sx
   • y’ = y + hy*x
                            y’ = y*sy

Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:
   • x’ = x * sx
   • y’ = y * sy

Shear:                         (x’,y’)
   • x’ = x + hx*y          x’ = (x*sx)*cosΘ - (y*sy)*sinΘ
   • y’ = y + hy*x          y’ = (x*sx)*sinΘ + (y*sy)*cosΘ
Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:                         (x’,y’)
   • x’ = x * sx
   • y’ = y * sy

Shear:
   • x’ = x + hx*y
                            x’ = ((x*sx)*cosΘ - (y*sy)*sinΘ) + tx
                            y’ = ((x*sx)*sinΘ + (y*sy)*cosΘ) + ty
   • y’ = y + hy*x

Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Basic 2D Transformations
Translation:
   • x’ = x + tx
   • y’ = y + ty

Scale:
   • x’ = x * sx
   • y’ = y * sy

Shear:
   • x’ = x + hx*y
                            x’ = ((x*sx)*cosΘ - (y*sy)*sinΘ) + tx
                            y’ = ((x*sx)*sinΘ + (y*sy)*cosΘ) + ty
   • y’ = y + hy*x

Rotation:
   • x’ = x*cosΘ - y*sinΘ
   • y’ = x*sinΘ + y*cosΘ
Overview
2D Transformations
  • Basic 2D transformations
  • Matrix representation
  • Matrix composition

3D Transformations
  • Basic 3D transformations
  • Same as 2D
Matrix Representation
Represent 2D transformation by a matrix

                   a      b
                   c
                          d
                            

Multiply matrix by column vector
     ⇔ apply transformation to point
    x' = a   b  x         x' = ax + by
    y ' c
             d  y 
                             y ' = cx + dy
Matrix Representation
Transformations combined by multiplication

          x' = a   b  e   f  i   j  x 
          y ' c
                   d g
                             h k
                                      l  y 
                                           


       Matrices are a convenient and efficient way
       to represent a sequence of transformations!
2x2 Matrices
What types of transformations can be
 represented with a 2x2 matrix?
   2D Identity?
     x' = x             x' = 1     0  x 
     y' = y             y ' 0
                                   1 y 
                                        
   2D Scale around (0,0)?
     x' = s x * x       x ' s x     0  x 
     y' = s y * y       y ' =  0    s y  y 
                                         
2x2 Matrices
What types of transformations can be
 represented with a 2x2 matrix?
   2D Rotate around (0,0)?
    x ' = cos Θ* x − sin Θ* y    x ' cos Θ − sin Θ x 
    y ' = sin Θ* x + cos Θ* y    y ' = sin Θ cos Θ  y 
                                                    

   2D Shear?
    x ' = x + shx * y            x '  1      shx  x 
    y ' = shy * x + y            y ' = sh     1  y 
                                   y              
2x2 Matrices
What types of transformations can be
 represented with a 2x2 matrix?
   2D Mirror about Y axis?
     x ' = −x                 x' = −1 0 x 
     y' = y                   y '  0 1 y 
                                        

   2D Mirror over (0,0)?
      x ' = −x                x' = −1 0  x 
      y' = −y                 y '  0 −1 y 
                                         
2x2 Matrices
What types of transformations can be
 represented with a 2x2 matrix?
   2D Translation?
      x' = x + t x
                     NO!
      y' = y + t y

            Only linear 2D transformations
          can be represented with a 2x2 matrix
Linear Transformations
Linear transformations are combinations of …
   • Scale,
                                x' a      b  x 
                                y ' = c
   • Rotation,
   • Shear, and                           d  y 
                                                
   • Mirror
Properties of linear transformations:
   • Satisfies:   T ( s1p1 + s2p 2 ) = s1T (p1 ) + s2T (p 2 )
   • Origin maps to origin
   • Lines map to lines
   • Parallel lines remain parallel
   • Ratios are preserved
   • Closed under composition
Homogeneous Coordinates
Q: How can we represent translation as a 3x3 matrix?
        x' = x + t x
        y' = y + t y
Homogeneous Coordinates
Homogeneous coordinates
                                                          x
 • represent coordinates in 2    x  homogeneous coords  
   dimensions with a 3-vector    y     → y 
                                                       1 
                                                          

Homogeneous coordinates seem unintuitive, but they
 make graphics operations much easier
Homogeneous Coordinates
Q: How can we represent translation as a 3x3 matrix?
        x' = x + t x
        y' = y + t y

A: Using the rightmost column:

                                1   0   tx 
                                           
                  Translation = 0   1   ty
                                0   0   1
                                           
Translation
                              Homogeneous Coordinates
Example of translation
α                                x ' 1 0 t x   x   x + t x 
                                 y ' = 0 1 t   y  =  y + t 
                                            y             y

                                 1  0 0 1   1   1 
                                                           




                     tx = 2
                     ty = 1
Homogeneous Coordinates
Add a 3rd coordinate to every 2D point
   • (x, y, w) represents a point at location (x/w, y/w)
   • (x, y, 0) represents a point at infinity
   • (0, 0, 0) is not allowed         y
                                     2
                                                    (2,1,1) or (4,2,2) or (6,3,3)
                                     1

Convenient coordinate                       1   2       x
system to
represent many useful
transformations
Basic 2D Transformations
Basic 2D transformations as 3x3 matrices
                                                   x ' s x    0        0  x 
         x ' 1     0   t x  x                y ' =  0   sy       0  y 
         y ' = 0                                                      
                   1   t y  y 
                                               1   0
                                                              0        11 
                                                                            
         1  0
                   0   1 1 
                               
              Translate                                     Scale


     x' cos Θ      − sin Θ          0  x     x '  1      shx        0  x 
     y ' = sin Θ                    0  y     y ' = sh
                   cos Θ                       y             1      0  y 
                                                                               
    1   0
                       0            11 
                                               1   0
                                                                   0      11 
                                                                               
               Rotate                                       Shear
Affine Transformations
Affine transformations are combinations of …
  • Linear transformations, and            x '  a    b   c  x 
                                           y ' = d   e   f  y 
  • Translations                          w  0
                                                     0   1 w
                                                               
Properties of affine transformations:
  • Origin does not necessarily map to origin
  • Lines map to lines
  • Parallel lines remain parallel
  • Ratios are preserved
  • Closed under composition
Projective Transformations
Projective transformations …
                                          x'  a      b   c  x 
  • Affine transformations, and           y '  = d   e   f  y 
                                         w' g
                                                     h   i w
                                                               
  • Projective warps

Properties of projective transformations:
  • Origin does not necessarily map to origin
  • Lines map to lines
  • Parallel lines do not necessarily remain parallel
  • Ratios are not preserved
  • Closed under composition
Overview
2D Transformations
  • Basic 2D transformations
  • Matrix representation
  • Matrix composition

3D Transformations
  • Basic 3D transformations
  • Same as 2D
Matrix Composition
Transformations can be combined by
  matrix multiplication
   x '   1     0      tx cos Θ − sin Θ 0sx   0     0  x 
   y '  =  0   1      ty sin Θ cos Θ 0 0     sy       y 
                                                           0 
  w'  0
    
                  0      1  0
                                      0    1 0
                                                   0     1 w
                                                              
    p’ =       T(tx,ty)           R(Θ)          S(sx,sy)       p
Matrix Composition
Matrices are a convenient and efficient way to
 represent a sequence of transformations
  • General purpose representation
  • Hardware matrix multiply


  p’ = (T * (R * (S*p) ) )
  p’ = (T*R*S) * p
Matrix Composition
Be aware: order of transformations matters
    – Matrix multiplication is not commutative


           p’ = T * R * S * p

          “Global”       “Local”
Matrix Composition
What if we want to rotate and translate?
• Ex: Rotate line segment by 45 degrees about endpoint a
      and lengthen




           a                a
Multiplication Order – Wrong Way
Our line is defined by two endpoints
  • Applying a rotation of 45 degrees, R(45), affects both points
  • We could try to translate both endpoints to return endpoint a to its
    original position, but by how much?




                               a
         a                                             a
                                Wrong                   Correct
                                R(45)               T(-3) R(45) T(3)
Multiplication Order - Correct
Isolate endpoint a from rotation effects               a


• First translate line so a is at origin: T (-3)
                                                   a

• Then rotate line 45 degrees: R(45)
                                                   a

• Then translate back so a is where it was: T(3)
                                                           a
Matrix Composition
Will this sequence of operations work?
       1 0 − 3 cos(45) − sin( 45) 0 1 0 3  a x   a ' x 
       0 1 0   sin( 45) cos(45) 0 0 1 0 a  = a' 
                                            y   y 
       0 0 1   0
                           0      1  0 0 1   1   1 
                                                 
Matrix Composition
After correctly ordering the matrices
Multiply matrices together
What results is one matrix – store it (on stack)!
Multiply this matrix by the vector of each vertex
All vertices easily transformed with one matrix
multiply
Overview
2D Transformations
  • Basic 2D transformations
  • Matrix representation
  • Matrix composition

3D Transformations
  • Basic 3D transformations
  • Same as 2D
3D Transformations
Same idea as 2D transformations
  • Homogeneous coordinates: (x,y,z,w)
  • 4x4 transformation matrices

              x'   a     b   c   d  x 
              y'  e      f   g   h  y 
              z'  =  i   j   k   l  z 
             w' m
                         n   o   p w
                                       
Basic 3D Transformations
                                        x ' s x    0    0    0  x 
    x' 1       0   0   0  x       y '  0
    y ' 0      1   0   0  y       =          sy   0    0  y 
                                                                  
    z '  = 0   0   1   0  z       z'   0     0    sz   0  z 
   w  0
               0   0   1w
                                                            
                                       w   0       0    0    1w 
             Identity                                 Scale


    x ' 1      0   0   t x  x 
    y ' 0                             x' −1      0   0    0 x 
    =          1   0   t y  y 
                                      y '  0     1   0    0 y 
    z '  0     0   1   t z  z      z' =  0    0   1    0 z 
                                  w   0
                                                    0   0    1 w
                                                                   
   w  0        0   0    1 w 
             Translation                 Mirror about Y/Z plane
Basic 3D Transformations
                            x' cos Θ − sin Θ      0    0 x 
   Rotate around Z axis:    y ' sin Θ cos Θ       0    0 y 
                            z ' =  0    0         1    0 z 
                           w   0
                                        0         0    1w
                                                            

                          x '  cos Θ       0   sin Θ 0 x 
                          y '  0           1     0   0 y 
   Rotate around Y axis:   =                           
                          z '  − sin Θ     0   cos Θ 0 z 
                                                       
                         w   0             0     0   1w 


                            x' 1         0      0      0 x 
   Rotate around X axis:    y ' 0      cos Θ − sin Θ   0 y 
                            z '  = 0   sin Θ cos Θ     0 z 
                           w  0
                                         0      0      1w
                                                            
Reverse Rotations
Q: How do you undo a rotation of θ, R(θ )?
A: Apply the inverse of the rotation…            R-1(θ ) = R(-θ )


How to construct R-1(θ ) = R(-θ )
• Inside the rotation matrix: cos(θ) = cos(-θ)
   – The cosine elements of the inverse rotation matrix are unchanged
• The sign of the sine elements will flip

Therefore… R-1(θ ) = R(-θ ) = RT(θ )
Summary
Coordinate systems
• World vs. modeling coordinates

2-D and 3-D transformations
• Trigonometry and geometry
• Matrix representations
• Linear vs. affine transformations

Matrix operations
• Matrix composition

Mais conteúdo relacionado

Mais procurados

Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationSaumya Tiwari
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation9784
 
2d transformations
2d transformations2d transformations
2d transformationskmrvivek2
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D2013901097
 
Scaling and shearing
Scaling and shearingScaling and shearing
Scaling and shearingMani Kanth
 
2D Transformation
2D Transformation2D Transformation
2D TransformationShahDhruv21
 
CG 2D Transformation
CG 2D TransformationCG 2D Transformation
CG 2D TransformationMohitModyani
 
Transformations computer graphics
Transformations computer graphics Transformations computer graphics
Transformations computer graphics Vikram Halder
 
2 d transformations
2 d transformations2 d transformations
2 d transformationsSardar Alam
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformationsNareek
 
3 d transformation
3 d transformation3 d transformation
3 d transformationPooja Dixit
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinatesTarun Gehlot
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinatesKRIPA SHNAKAR TIWARI
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)Amit Kapoor
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 dxyz120
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 

Mais procurados (19)

Reflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and RotationReflection, Scaling, Shear, Translation, and Rotation
Reflection, Scaling, Shear, Translation, and Rotation
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation
 
2d transformations
2d transformations2d transformations
2d transformations
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 
Scaling and shearing
Scaling and shearingScaling and shearing
Scaling and shearing
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
CG 2D Transformation
CG 2D TransformationCG 2D Transformation
CG 2D Transformation
 
Transformations computer graphics
Transformations computer graphics Transformations computer graphics
Transformations computer graphics
 
2 d transformations
2 d transformations2 d transformations
2 d transformations
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformations
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
2d transformations
2d transformations2d transformations
2d transformations
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 

Destaque

Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsPartnered Health
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsMichael Heron
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transformPatel Punit
 
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithmsavelraj
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5geethawilliam
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Lesson 1 different types of animation
Lesson 1   different types of animationLesson 1   different types of animation
Lesson 1 different types of animationMrsNunn
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformationsMohammad Sadiq
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNANDINI SHARMA
 
COMP 4010 - Lecture 1: Introduction to Virtual Reality
COMP 4010 - Lecture 1: Introduction to Virtual RealityCOMP 4010 - Lecture 1: Introduction to Virtual Reality
COMP 4010 - Lecture 1: Introduction to Virtual RealityMark Billinghurst
 
Multimedia presentation
  Multimedia presentation   Multimedia presentation
Multimedia presentation kamalesh2015
 
Introduction To Multimedia
Introduction To MultimediaIntroduction To Multimedia
Introduction To MultimediaJomel Penalba
 
Text-Elements of multimedia
Text-Elements of multimediaText-Elements of multimedia
Text-Elements of multimediaVanitha Chandru
 
Chapter 1 : INTRODUCTION TO MULTIMEDIA
Chapter 1 : INTRODUCTION TO MULTIMEDIAChapter 1 : INTRODUCTION TO MULTIMEDIA
Chapter 1 : INTRODUCTION TO MULTIMEDIAazira96
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphicsAaina Katyal
 
Cost effective construction techniques
Cost effective construction techniquesCost effective construction techniques
Cost effective construction techniquesSayali Darakh
 

Destaque (20)

Planning
PlanningPlanning
Planning
 
Cgmodule
CgmoduleCgmodule
Cgmodule
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D Graphics
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
 
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Geometric transformation 2d chapter 5
Geometric transformation 2d   chapter 5Geometric transformation 2d   chapter 5
Geometric transformation 2d chapter 5
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Lesson 1 different types of animation
Lesson 1   different types of animationLesson 1   different types of animation
Lesson 1 different types of animation
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphics
 
COMP 4010 - Lecture 1: Introduction to Virtual Reality
COMP 4010 - Lecture 1: Introduction to Virtual RealityCOMP 4010 - Lecture 1: Introduction to Virtual Reality
COMP 4010 - Lecture 1: Introduction to Virtual Reality
 
Multimedia presentation
  Multimedia presentation   Multimedia presentation
Multimedia presentation
 
Introduction To Multimedia
Introduction To MultimediaIntroduction To Multimedia
Introduction To Multimedia
 
Text-Elements of multimedia
Text-Elements of multimediaText-Elements of multimedia
Text-Elements of multimedia
 
Chapter 1 : INTRODUCTION TO MULTIMEDIA
Chapter 1 : INTRODUCTION TO MULTIMEDIAChapter 1 : INTRODUCTION TO MULTIMEDIA
Chapter 1 : INTRODUCTION TO MULTIMEDIA
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphics
 
Cost effective construction techniques
Cost effective construction techniquesCost effective construction techniques
Cost effective construction techniques
 

Semelhante a Geometric transformation cg

Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformationsWael Badawy
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer GraphicsJatenderKhatri
 
07 cie552 image_mosaicing
07 cie552 image_mosaicing07 cie552 image_mosaicing
07 cie552 image_mosaicingElsayed Hemayed
 
04transformation2d
04transformation2d04transformation2d
04transformation2dKetan Jani
 
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
7.curves   Further Mathematics Zimbabwe Zimsec Cambridge7.curves   Further Mathematics Zimbabwe Zimsec Cambridge
7.curves Further Mathematics Zimbabwe Zimsec Cambridgealproelearning
 
3 d transformation
3 d transformation3 d transformation
3 d transformationMani Kanth
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptxAneesAbbasi14
 
2 d transformation
2 d transformation2 d transformation
2 d transformationAnkit Garg
 
Calculus Review for semester 1 at University
Calculus Review for semester 1 at UniversityCalculus Review for semester 1 at University
Calculus Review for semester 1 at Universitynetaf56543
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2SIMONTHOMAS S
 
VHDL and Cordic Algorithim
VHDL and Cordic AlgorithimVHDL and Cordic Algorithim
VHDL and Cordic AlgorithimSubeer Rangra
 
Image Processing 3
Image Processing 3Image Processing 3
Image Processing 3jainatin
 

Semelhante a Geometric transformation cg (20)

Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformations
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer Graphics
 
07 cie552 image_mosaicing
07 cie552 image_mosaicing07 cie552 image_mosaicing
07 cie552 image_mosaicing
 
04transformation2d
04transformation2d04transformation2d
04transformation2d
 
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
7.curves   Further Mathematics Zimbabwe Zimsec Cambridge7.curves   Further Mathematics Zimbabwe Zimsec Cambridge
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
Alg2 lesson 6-6
Alg2 lesson 6-6Alg2 lesson 6-6
Alg2 lesson 6-6
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptx
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 
1533 game mathematics
1533 game mathematics1533 game mathematics
1533 game mathematics
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
 
0205 ch 2 day 5
0205 ch 2 day 50205 ch 2 day 5
0205 ch 2 day 5
 
Lecture 2.1 2.2a bt
Lecture 2.1 2.2a btLecture 2.1 2.2a bt
Lecture 2.1 2.2a bt
 
Calculus Review for semester 1 at University
Calculus Review for semester 1 at UniversityCalculus Review for semester 1 at University
Calculus Review for semester 1 at University
 
transformation IT.ppt
transformation IT.ppttransformation IT.ppt
transformation IT.ppt
 
Virtual reality
Virtual realityVirtual reality
Virtual reality
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2
 
VHDL and Cordic Algorithim
VHDL and Cordic AlgorithimVHDL and Cordic Algorithim
VHDL and Cordic Algorithim
 
Image Processing 3
Image Processing 3Image Processing 3
Image Processing 3
 

Último

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Último (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

Geometric transformation cg

  • 1. Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations M.C. Escher – Smaller and Smaller (1956)
  • 2. Modeling Transformations Specify transformations for objects • Allows definitions of objects in own coordinate systems • Allows use of object definition multiple times in a scene – Remember how OpenGL provides a transformation stack because they are so frequently reused Chapter 5 from Hearn and Baker H&B Figure 109
  • 3. Overview 2D Transformations • Basic 2D transformations • Matrix representation • Matrix composition 3D Transformations • Basic 3D transformations • Same as 2D
  • 4. 2D Modeling Transformations Modeling Coordinates Scale y Translate x Scale Rotate Translate World Coordinates
  • 5. 2D Modeling Transformations Modeling Coordinates y x Let’s look at this in detail… World Coordinates
  • 6. 2D Modeling Transformations Modeling Coordinates y x Initial location at (0, 0) with x- and y-axes aligned
  • 7. 2D Modeling Transformations Modeling Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3
  • 8. 2D Modeling Transformations Modeling Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3
  • 9. 2D Modeling Transformations Modeling Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3 World Coordinates
  • 10. Scaling Scaling a coordinate means multiplying each of its components by a scalar Uniform scaling means this scalar is the same for all components: ×2
  • 11. Scaling Non-uniform scaling: different scalars per component: X × 2, Y × 0.5 How can we represent this in matrix form?
  • 12. Scaling Scaling operation:  x' ax   y ' = by      Or, in matrix form:  x ' a 0  x   y ' = 0  y  b      scaling matrix
  • 13. 2-D Rotation (x’, y’) (x, y) x’ = x cos(θ) - y sin(θ) θ y’ = x sin(θ) + y cos(θ)
  • 14. 2-D Rotation x = r cos (φ) y = r sin (φ) x’ = r cos (φ + θ) y’ = r sin (φ + θ) (x’, y’) Trig Identity… (x, y) x’ = r cos(φ) cos(θ) – r sin(φ) sin(θ) y’ = r sin(φ) sin(θ) + r cos(φ) cos(θ) θ φ Substitute… x’ = x cos(θ) - y sin(θ) y’ = x sin(θ) + y cos(θ)
  • 15. 2-D Rotation This is easy to capture in matrix form:  x ' cos(θ ) − sin (θ )  x   y ' = sin (θ ) cos(θ )  y       Even though sin(θ) and cos(θ) are nonlinear functions of θ, • x’ is a linear combination of x and y • y’ is a linear combination of x and y
  • 16. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: • x’ = x * sx • y’ = y * sy Shear: Transformations • x’ = x + hx*y can be combined • y’ = y + hy*x (with simple algebra) Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 17. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: • x’ = x * sx • y’ = y * sy Shear: • x’ = x + hx*y • y’ = y + hy*x Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 18. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: (x,y) • x’ = x * sx (x’,y’) • y’ = y * sy Shear: • x’ = x + hx*y x’ = x*sx • y’ = y + hy*x y’ = y*sy Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 19. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: • x’ = x * sx • y’ = y * sy Shear: (x’,y’) • x’ = x + hx*y x’ = (x*sx)*cosΘ - (y*sy)*sinΘ • y’ = y + hy*x y’ = (x*sx)*sinΘ + (y*sy)*cosΘ Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 20. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: (x’,y’) • x’ = x * sx • y’ = y * sy Shear: • x’ = x + hx*y x’ = ((x*sx)*cosΘ - (y*sy)*sinΘ) + tx y’ = ((x*sx)*sinΘ + (y*sy)*cosΘ) + ty • y’ = y + hy*x Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 21. Basic 2D Transformations Translation: • x’ = x + tx • y’ = y + ty Scale: • x’ = x * sx • y’ = y * sy Shear: • x’ = x + hx*y x’ = ((x*sx)*cosΘ - (y*sy)*sinΘ) + tx y’ = ((x*sx)*sinΘ + (y*sy)*cosΘ) + ty • y’ = y + hy*x Rotation: • x’ = x*cosΘ - y*sinΘ • y’ = x*sinΘ + y*cosΘ
  • 22. Overview 2D Transformations • Basic 2D transformations • Matrix representation • Matrix composition 3D Transformations • Basic 3D transformations • Same as 2D
  • 23. Matrix Representation Represent 2D transformation by a matrix a b c  d  Multiply matrix by column vector ⇔ apply transformation to point  x' = a b  x  x' = ax + by  y ' c    d  y    y ' = cx + dy
  • 24. Matrix Representation Transformations combined by multiplication  x' = a b  e f  i j  x   y ' c    d g  h k  l  y    Matrices are a convenient and efficient way to represent a sequence of transformations!
  • 25. 2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Identity? x' = x  x' = 1 0  x  y' = y  y ' 0    1 y    2D Scale around (0,0)? x' = s x * x  x ' s x 0  x  y' = s y * y  y ' =  0 s y  y      
  • 26. 2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Rotate around (0,0)? x ' = cos Θ* x − sin Θ* y  x ' cos Θ − sin Θ x  y ' = sin Θ* x + cos Θ* y  y ' = sin Θ cos Θ  y       2D Shear? x ' = x + shx * y  x '  1 shx  x  y ' = shy * x + y  y ' = sh 1  y     y  
  • 27. 2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Mirror about Y axis? x ' = −x  x' = −1 0 x  y' = y  y '  0 1 y       2D Mirror over (0,0)? x ' = −x  x' = −1 0  x  y' = −y  y '  0 −1 y      
  • 28. 2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Translation? x' = x + t x NO! y' = y + t y Only linear 2D transformations can be represented with a 2x2 matrix
  • 29. Linear Transformations Linear transformations are combinations of … • Scale,  x' a b  x   y ' = c • Rotation, • Shear, and    d  y    • Mirror Properties of linear transformations: • Satisfies: T ( s1p1 + s2p 2 ) = s1T (p1 ) + s2T (p 2 ) • Origin maps to origin • Lines map to lines • Parallel lines remain parallel • Ratios are preserved • Closed under composition
  • 30. Homogeneous Coordinates Q: How can we represent translation as a 3x3 matrix? x' = x + t x y' = y + t y
  • 31. Homogeneous Coordinates Homogeneous coordinates  x • represent coordinates in 2  x  homogeneous coords   dimensions with a 3-vector  y     → y    1    Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
  • 32. Homogeneous Coordinates Q: How can we represent translation as a 3x3 matrix? x' = x + t x y' = y + t y A: Using the rightmost column: 1 0 tx    Translation = 0 1 ty 0 0 1  
  • 33. Translation Homogeneous Coordinates Example of translation α  x ' 1 0 t x   x   x + t x   y ' = 0 1 t   y  =  y + t     y    y  1  0 0 1   1   1         tx = 2 ty = 1
  • 34. Homogeneous Coordinates Add a 3rd coordinate to every 2D point • (x, y, w) represents a point at location (x/w, y/w) • (x, y, 0) represents a point at infinity • (0, 0, 0) is not allowed y 2 (2,1,1) or (4,2,2) or (6,3,3) 1 Convenient coordinate 1 2 x system to represent many useful transformations
  • 35. Basic 2D Transformations Basic 2D transformations as 3x3 matrices  x ' s x 0 0  x   x ' 1 0 t x  x   y ' =  0 sy 0  y   y ' = 0         1 t y  y    1   0    0 11     1  0    0 1 1    Translate Scale  x' cos Θ − sin Θ 0  x   x '  1 shx 0  x   y ' = sin Θ 0  y   y ' = sh    cos Θ      y 1 0  y    1   0    0 11    1   0    0 11    Rotate Shear
  • 36. Affine Transformations Affine transformations are combinations of … • Linear transformations, and  x '  a b c  x   y ' = d e f  y  • Translations w  0    0 1 w   Properties of affine transformations: • Origin does not necessarily map to origin • Lines map to lines • Parallel lines remain parallel • Ratios are preserved • Closed under composition
  • 37. Projective Transformations Projective transformations …  x'  a b c  x  • Affine transformations, and  y '  = d e f  y  w' g    h i w   • Projective warps Properties of projective transformations: • Origin does not necessarily map to origin • Lines map to lines • Parallel lines do not necessarily remain parallel • Ratios are not preserved • Closed under composition
  • 38. Overview 2D Transformations • Basic 2D transformations • Matrix representation • Matrix composition 3D Transformations • Basic 3D transformations • Same as 2D
  • 39. Matrix Composition Transformations can be combined by matrix multiplication  x '   1 0 tx cos Θ − sin Θ 0sx 0 0  x   y '  =  0 1 ty sin Θ cos Θ 0 0 sy   y  0  w'  0     0 1  0   0 1 0  0 1 w    p’ = T(tx,ty) R(Θ) S(sx,sy) p
  • 40. Matrix Composition Matrices are a convenient and efficient way to represent a sequence of transformations • General purpose representation • Hardware matrix multiply p’ = (T * (R * (S*p) ) ) p’ = (T*R*S) * p
  • 41. Matrix Composition Be aware: order of transformations matters – Matrix multiplication is not commutative p’ = T * R * S * p “Global” “Local”
  • 42. Matrix Composition What if we want to rotate and translate? • Ex: Rotate line segment by 45 degrees about endpoint a and lengthen a a
  • 43. Multiplication Order – Wrong Way Our line is defined by two endpoints • Applying a rotation of 45 degrees, R(45), affects both points • We could try to translate both endpoints to return endpoint a to its original position, but by how much? a a a Wrong Correct R(45) T(-3) R(45) T(3)
  • 44. Multiplication Order - Correct Isolate endpoint a from rotation effects a • First translate line so a is at origin: T (-3) a • Then rotate line 45 degrees: R(45) a • Then translate back so a is where it was: T(3) a
  • 45. Matrix Composition Will this sequence of operations work? 1 0 − 3 cos(45) − sin( 45) 0 1 0 3  a x   a ' x  0 1 0   sin( 45) cos(45) 0 0 1 0 a  = a'      y   y  0 0 1   0   0 1  0 0 1   1   1      
  • 46. Matrix Composition After correctly ordering the matrices Multiply matrices together What results is one matrix – store it (on stack)! Multiply this matrix by the vector of each vertex All vertices easily transformed with one matrix multiply
  • 47. Overview 2D Transformations • Basic 2D transformations • Matrix representation • Matrix composition 3D Transformations • Basic 3D transformations • Same as 2D
  • 48. 3D Transformations Same idea as 2D transformations • Homogeneous coordinates: (x,y,z,w) • 4x4 transformation matrices  x'   a b c d  x   y'  e f g h  y   z'  =  i j k l  z  w' m    n o p w  
  • 49. Basic 3D Transformations  x ' s x 0 0 0  x   x' 1 0 0 0  x   y '  0  y ' 0 1 0 0  y   = sy 0 0  y     z '  = 0 0 1 0  z   z'   0 0 sz 0  z  w  0    0 0 1w        w   0 0 0 1w  Identity Scale  x ' 1 0 0 t x  x   y ' 0  x' −1 0 0 0 x   = 1 0 t y  y     y '  0 1 0 0 y   z '  0 0 1 t z  z   z' =  0 0 1 0 z       w   0    0 0 1 w   w  0 0 0 1 w  Translation Mirror about Y/Z plane
  • 50. Basic 3D Transformations  x' cos Θ − sin Θ 0 0 x  Rotate around Z axis:  y ' sin Θ cos Θ 0 0 y   z ' =  0 0 1 0 z  w   0    0 0 1w    x '  cos Θ 0 sin Θ 0 x   y '  0 1 0 0 y  Rotate around Y axis:   =     z '  − sin Θ 0 cos Θ 0 z       w   0 0 0 1w   x' 1 0 0 0 x  Rotate around X axis:  y ' 0 cos Θ − sin Θ 0 y   z '  = 0 sin Θ cos Θ 0 z  w  0    0 0 1w  
  • 51. Reverse Rotations Q: How do you undo a rotation of θ, R(θ )? A: Apply the inverse of the rotation… R-1(θ ) = R(-θ ) How to construct R-1(θ ) = R(-θ ) • Inside the rotation matrix: cos(θ) = cos(-θ) – The cosine elements of the inverse rotation matrix are unchanged • The sign of the sine elements will flip Therefore… R-1(θ ) = R(-θ ) = RT(θ )
  • 52. Summary Coordinate systems • World vs. modeling coordinates 2-D and 3-D transformations • Trigonometry and geometry • Matrix representations • Linear vs. affine transformations Matrix operations • Matrix composition