SlideShare une entreprise Scribd logo
1  sur  25
2D transformations and
homogeneous coordinates
        TARUN GEHLOTS
Map of the lecture
• Transformations in 2D:
  – vector/matrix notation
  – example: translation, scaling, rotation
• Homogeneous coordinates:
  – consistent notation
  – several other good points (later)
• Composition of transformations
• Transformations for the window system
Transformations in 2D
• In the application model:
  – a 2D description of an object (vertices)
  – a transformation to apply
• Each vertex is modified:
  • x’ = f(x,y)
  • y’ = g(x,y)
• Express the modification
Translations
• Each vertex is modified:
  • x’ = x+tx
  • y’ = y+ty




       Before                  After
Translations: vector notation
• Use vector for the notation:
  – makes things simpler
• A point is a vector: x
                           y
• A translation is merely a vector sum:
          P’ = P + T
Scaling in 2D
• Coordinates multiplied by the scaling
  factor:
  • x’ = sx x
  • y’ = sy y




       Before                   After
Scaling in 2D, matrix notation
• Scaling is a matrix multiplication:
          P’ = SP

          x      sx    0   x
          y       0   sy   y
Rotating in 2D
• New coordinates depend on both x and y
  • x’ = cos x - sin y
  • y’ = sin x + cos y




     Before                 After
Rotating in 2D, matrix notation
• A rotation is a matrix multiplication:
          P’=RP

   x        cos           sin       x
   y         sin        cos         y
2D transformations, summary
• Vector-matrix notation simplifies writing:
  – translation is a vector sum
  – rotation and scaling are matrix-vector
    multiplication
• I would like a consistent notation:
  – that expresses all three identically
  – that expresses combination of these also
    identically
• How to do this?
Homogeneous coordinates
• Introduced in mathematics:
  – for projections and drawings
  – used in artillery, architecture
  – used to be classified material (in the 1850s)
• Add a third coordinate, w                     x
• A 2D point is a 3 coordinates vector:         y
                                               w
Homogeneous coordinates (2)
• Two points are equal if and only if:
  x’/w’ = x/w and y’/w’= y/w
• w=0: points at infinity
  – useful for projections and curve drawing
• Homogenize = divide by w.
• Homogenized points:    x
                         y
                         1
Translations with homogeneous
x   1 0 tx   x            x   x
                          w   w   tx
y   0 1 ty   y
                          y   y
w   0 0 1 w
                          w   w   ty
             x   x wt x
             y   y wt y
             w     w
Scaling with homogeneous
x   sx   0    0   x              x         x
y   0    sy   0   y              w   s   x w
                                 y         y
w   0    0    1 w
                                 w   s   y w
                      x   sx x
                      y   sy y
                      w   w
Rotation with homogeneous
x    cos    sin    0   x
y    sin   cos     0   y       x         x         y
                               w   cos   w   sin   w
w     0     0      1 w
                               y         x         y
                               w   sin   w   cos   w


             x    cos x sin y
             y    sin x cos y
            w              w
Composition of transformations
• To compose transformations, multiply
  the matrices:
  – composition of a rotation and a translation:
                M = RT
• all transformations can be expressed as
  matrices
  – even transformations that are not
    translations, rotations and scaling
Rotation around a point Q
• Rotation about a point Q:
  – translate Q to origin (TQ),
  – rotate about origin (R )
  – translate back to Q (- TQ).


              P’=(-TQ)R TQ P
Beware!
• Matrix multiplication is not commutative
• The order of the transformations is vital
  – Rotation followed by translation is very different
    from translation followed by rotation
  – careful with the order of the matrices!
• Small commutativity:
  – rotation commute with rotation, translation with
    translation…
From World to Window
• Inside the application:
  – application model
  – coordinates related to the model
  – possibly floating point
• On the screen:
  – pixel coordinates
  – integer
  – restricted viewport: umin/umax, vmin/vmax
From Model to Viewport
ymax



ymin

       xmin    xmax
From Model to Viewport
• Model is (xmin,ymin)-(xmax,ymax)
• Viewport is (umin,vmin)-(umax,vmax)
• Translate by (-xmin,-ymin)
• Scale by ( umax-umin , vmax-vmin )
             xmax-xmin   ymax-ymin
• Translate by (umin,vmin)

         M = T’ST
From Model to Viewport


Pixel Coordinates             Model Coordinates
                    u     x
                    v   M y
                    w     w
Mouse position: inverse problem
• Mouse click: coordinates in pixels
• We want the equivalent in World Coord
  – because the user has selected an object
  – to draw something
  – for interaction
• How can we convert from window
  coordinates to model coordinates?
Mouse click: inverse problem
    • Simply inverse the matrix:
                        1               1
                    M       (T ST)
Model Coordinates
                                            Pixels coordinates
                    x               u
                                1
                    y       M       v
                    w               w
2D transformations: conclusion
• Simple, consistent matrix notation
  – using homogeneous coordinates
  – all transformations expressed as matrices
• Used by the window system:
  – for conversion from model to window
  – for conversion from window to model
• Used by the application:
  – for modeling transformations

Contenu connexe

Tendances

Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)RohitK71
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphicsSHIVANI SONI
 
Composite transformation
Composite transformationComposite transformation
Composite transformationPooja Dixit
 
3D Transformation
3D Transformation3D Transformation
3D TransformationSwatiHans10
 
3d transformation computer graphics
3d transformation computer graphics 3d transformation computer graphics
3d transformation computer graphics University of Potsdam
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithmMani Kanth
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
Overview of 2D and 3D Transformation
Overview of 2D and 3D TransformationOverview of 2D and 3D Transformation
Overview of 2D and 3D TransformationDheeraj Sadawarte
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation9784
 
2d-transformation
2d-transformation2d-transformation
2d-transformationPooja Dixit
 
Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4PrathimaBaliga
 
Transformations(scaling rotation translation)
Transformations(scaling rotation translation)Transformations(scaling rotation translation)
Transformations(scaling rotation translation)Arjun Betageri
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformationsMohammad Sadiq
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 

Tendances (20)

Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 
Video display devices
Video display devicesVideo display devices
Video display devices
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Composite transformation
Composite transformationComposite transformation
Composite transformation
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
3d transformation computer graphics
3d transformation computer graphics 3d transformation computer graphics
3d transformation computer graphics
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
Overview of 2D and 3D Transformation
Overview of 2D and 3D TransformationOverview of 2D and 3D Transformation
Overview of 2D and 3D Transformation
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation
 
2d-transformation
2d-transformation2d-transformation
2d-transformation
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Unit 3
Unit 3Unit 3
Unit 3
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4
 
Transformations(scaling rotation translation)
Transformations(scaling rotation translation)Transformations(scaling rotation translation)
Transformations(scaling rotation translation)
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 

En vedette

Homogeneous coordinate
Homogeneous coordinateHomogeneous coordinate
Homogeneous coordinateBed Dhakal
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingMark Kilgard
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL TransformationSandip Jadhav
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologyTiago Sousa
 
Display devices CRT and LCD screen
Display devices CRT and LCD screenDisplay devices CRT and LCD screen
Display devices CRT and LCD screenManoj Harsule
 
Computer Graphics Notes
Computer Graphics NotesComputer Graphics Notes
Computer Graphics NotesGurpreet singh
 
3 d projections
3 d projections3 d projections
3 d projectionsMohd Arif
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformationsMohd Arif
 
Introduction to Computer graphics
Introduction to Computer graphics Introduction to Computer graphics
Introduction to Computer graphics PrathimaBaliga
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devicesvinay arora
 
3D Geometric Transformations
3D Geometric Transformations3D Geometric Transformations
3D Geometric TransformationsIshan Parekh
 
Video display device
Video display deviceVideo display device
Video display devicemissagrata
 
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
 
Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)Rajesh Kamboj
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphicsAaina Katyal
 

En vedette (20)

2d/3D transformations in computer graphics(Computer graphics Tutorials)
2d/3D transformations in computer graphics(Computer graphics Tutorials)2d/3D transformations in computer graphics(Computer graphics Tutorials)
2d/3D transformations in computer graphics(Computer graphics Tutorials)
 
Homogeneous coordinate
Homogeneous coordinateHomogeneous coordinate
Homogeneous coordinate
 
Projection Matrices
Projection MatricesProjection Matrices
Projection Matrices
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
3D transformation
3D transformation3D transformation
3D transformation
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
Display devices CRT and LCD screen
Display devices CRT and LCD screenDisplay devices CRT and LCD screen
Display devices CRT and LCD screen
 
lecture1 introduction to computer graphics(Computer graphics tutorials)
lecture1 introduction to computer graphics(Computer graphics tutorials)lecture1 introduction to computer graphics(Computer graphics tutorials)
lecture1 introduction to computer graphics(Computer graphics tutorials)
 
Computer Graphics Notes
Computer Graphics NotesComputer Graphics Notes
Computer Graphics Notes
 
3 d projections
3 d projections3 d projections
3 d projections
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformations
 
Introduction to Computer graphics
Introduction to Computer graphics Introduction to Computer graphics
Introduction to Computer graphics
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
 
3D Geometric Transformations
3D Geometric Transformations3D Geometric Transformations
3D Geometric Transformations
 
Video display device
Video display deviceVideo display device
Video display device
 
transformation 3d
transformation 3dtransformation 3d
transformation 3d
 
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)
 
Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)Computer Graphics Notes (B.Tech, KUK, MDU)
Computer Graphics Notes (B.Tech, KUK, MDU)
 
applications of computer graphics
applications of computer graphicsapplications of computer graphics
applications of computer graphics
 

Similaire à 2D Transformations and Homogeneous Coordinates

Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer GraphicsJatenderKhatri
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptxAneesAbbasi14
 
Geometric transformation cg
Geometric transformation cgGeometric transformation cg
Geometric transformation cgharinipriya1994
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformationsNareek
 
GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.pptDebjit Doira
 
Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformationsWael Badawy
 
2D Transformation.pptx
2D Transformation.pptx2D Transformation.pptx
2D Transformation.pptxMuhammadNaqi7
 
Lecture 9-online
Lecture 9-onlineLecture 9-online
Lecture 9-onlinelifebreath
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsBala Murali
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
Matrix of linear transformation 1.9-dfs
Matrix of linear transformation 1.9-dfsMatrix of linear transformation 1.9-dfs
Matrix of linear transformation 1.9-dfsFarhana Shaheen
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphicsDrSUGANYADEVIK
 
04transformation2d
04transformation2d04transformation2d
04transformation2dKetan Jani
 

Similaire à 2D Transformations and Homogeneous Coordinates (20)

2d Transformation.pdf
2d Transformation.pdf2d Transformation.pdf
2d Transformation.pdf
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer Graphics
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptx
 
Geometric transformation cg
Geometric transformation cgGeometric transformation cg
Geometric transformation cg
 
Two dimensionaltransformations
Two dimensionaltransformationsTwo dimensionaltransformations
Two dimensionaltransformations
 
GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.ppt
 
Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformations
 
september4.ppt
september4.pptseptember4.ppt
september4.ppt
 
2D Transformation.pptx
2D Transformation.pptx2D Transformation.pptx
2D Transformation.pptx
 
Lecture 9-online
Lecture 9-onlineLecture 9-online
Lecture 9-online
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
CO3303-1 Lecture 2.ppt
CO3303-1 Lecture 2.pptCO3303-1 Lecture 2.ppt
CO3303-1 Lecture 2.ppt
 
transformations.pdf
transformations.pdftransformations.pdf
transformations.pdf
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 
Matrix of linear transformation 1.9-dfs
Matrix of linear transformation 1.9-dfsMatrix of linear transformation 1.9-dfs
Matrix of linear transformation 1.9-dfs
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphics
 
Lec08112004.pdf
Lec08112004.pdfLec08112004.pdf
Lec08112004.pdf
 
04transformation2d
04transformation2d04transformation2d
04transformation2d
 

Plus de Tarun Gehlot

Materials 11-01228
Materials 11-01228Materials 11-01228
Materials 11-01228Tarun Gehlot
 
Continuity and end_behavior
Continuity and  end_behaviorContinuity and  end_behavior
Continuity and end_behaviorTarun Gehlot
 
Continuity of functions by graph (exercises with detailed solutions)
Continuity of functions by graph   (exercises with detailed solutions)Continuity of functions by graph   (exercises with detailed solutions)
Continuity of functions by graph (exercises with detailed solutions)Tarun Gehlot
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error methodTarun Gehlot
 
Introduction to finite element analysis
Introduction to finite element analysisIntroduction to finite element analysis
Introduction to finite element analysisTarun Gehlot
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functionsTarun Gehlot
 
Finite elements for 2‐d problems
Finite elements  for 2‐d problemsFinite elements  for 2‐d problems
Finite elements for 2‐d problemsTarun Gehlot
 
Error analysis statistics
Error analysis   statisticsError analysis   statistics
Error analysis statisticsTarun Gehlot
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Linear approximations and_differentials
Linear approximations and_differentialsLinear approximations and_differentials
Linear approximations and_differentialsTarun Gehlot
 
Local linear approximation
Local linear approximationLocal linear approximation
Local linear approximationTarun Gehlot
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functionsTarun Gehlot
 
Propeties of-triangles
Propeties of-trianglesPropeties of-triangles
Propeties of-trianglesTarun Gehlot
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadraturesTarun Gehlot
 
Basics of set theory
Basics of set theoryBasics of set theory
Basics of set theoryTarun Gehlot
 
Numerical integration
Numerical integrationNumerical integration
Numerical integrationTarun Gehlot
 
Applications of set theory
Applications of  set theoryApplications of  set theory
Applications of set theoryTarun Gehlot
 
Miscellneous functions
Miscellneous  functionsMiscellneous  functions
Miscellneous functionsTarun Gehlot
 

Plus de Tarun Gehlot (20)

Materials 11-01228
Materials 11-01228Materials 11-01228
Materials 11-01228
 
Binary relations
Binary relationsBinary relations
Binary relations
 
Continuity and end_behavior
Continuity and  end_behaviorContinuity and  end_behavior
Continuity and end_behavior
 
Continuity of functions by graph (exercises with detailed solutions)
Continuity of functions by graph   (exercises with detailed solutions)Continuity of functions by graph   (exercises with detailed solutions)
Continuity of functions by graph (exercises with detailed solutions)
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error method
 
Introduction to finite element analysis
Introduction to finite element analysisIntroduction to finite element analysis
Introduction to finite element analysis
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 
Finite elements for 2‐d problems
Finite elements  for 2‐d problemsFinite elements  for 2‐d problems
Finite elements for 2‐d problems
 
Error analysis statistics
Error analysis   statisticsError analysis   statistics
Error analysis statistics
 
Matlab commands
Matlab commandsMatlab commands
Matlab commands
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Linear approximations and_differentials
Linear approximations and_differentialsLinear approximations and_differentials
Linear approximations and_differentials
 
Local linear approximation
Local linear approximationLocal linear approximation
Local linear approximation
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
 
Propeties of-triangles
Propeties of-trianglesPropeties of-triangles
Propeties of-triangles
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadratures
 
Basics of set theory
Basics of set theoryBasics of set theory
Basics of set theory
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
Applications of set theory
Applications of  set theoryApplications of  set theory
Applications of set theory
 
Miscellneous functions
Miscellneous  functionsMiscellneous  functions
Miscellneous functions
 

2D Transformations and Homogeneous Coordinates

  • 1. 2D transformations and homogeneous coordinates TARUN GEHLOTS
  • 2. Map of the lecture • Transformations in 2D: – vector/matrix notation – example: translation, scaling, rotation • Homogeneous coordinates: – consistent notation – several other good points (later) • Composition of transformations • Transformations for the window system
  • 3. Transformations in 2D • In the application model: – a 2D description of an object (vertices) – a transformation to apply • Each vertex is modified: • x’ = f(x,y) • y’ = g(x,y) • Express the modification
  • 4. Translations • Each vertex is modified: • x’ = x+tx • y’ = y+ty Before After
  • 5. Translations: vector notation • Use vector for the notation: – makes things simpler • A point is a vector: x y • A translation is merely a vector sum: P’ = P + T
  • 6. Scaling in 2D • Coordinates multiplied by the scaling factor: • x’ = sx x • y’ = sy y Before After
  • 7. Scaling in 2D, matrix notation • Scaling is a matrix multiplication: P’ = SP x sx 0 x y 0 sy y
  • 8. Rotating in 2D • New coordinates depend on both x and y • x’ = cos x - sin y • y’ = sin x + cos y Before After
  • 9. Rotating in 2D, matrix notation • A rotation is a matrix multiplication: P’=RP x cos sin x y sin cos y
  • 10. 2D transformations, summary • Vector-matrix notation simplifies writing: – translation is a vector sum – rotation and scaling are matrix-vector multiplication • I would like a consistent notation: – that expresses all three identically – that expresses combination of these also identically • How to do this?
  • 11. Homogeneous coordinates • Introduced in mathematics: – for projections and drawings – used in artillery, architecture – used to be classified material (in the 1850s) • Add a third coordinate, w x • A 2D point is a 3 coordinates vector: y w
  • 12. Homogeneous coordinates (2) • Two points are equal if and only if: x’/w’ = x/w and y’/w’= y/w • w=0: points at infinity – useful for projections and curve drawing • Homogenize = divide by w. • Homogenized points: x y 1
  • 13. Translations with homogeneous x 1 0 tx x x x w w tx y 0 1 ty y y y w 0 0 1 w w w ty x x wt x y y wt y w w
  • 14. Scaling with homogeneous x sx 0 0 x x x y 0 sy 0 y w s x w y y w 0 0 1 w w s y w x sx x y sy y w w
  • 15. Rotation with homogeneous x cos sin 0 x y sin cos 0 y x x y w cos w sin w w 0 0 1 w y x y w sin w cos w x cos x sin y y sin x cos y w w
  • 16. Composition of transformations • To compose transformations, multiply the matrices: – composition of a rotation and a translation: M = RT • all transformations can be expressed as matrices – even transformations that are not translations, rotations and scaling
  • 17. Rotation around a point Q • Rotation about a point Q: – translate Q to origin (TQ), – rotate about origin (R ) – translate back to Q (- TQ). P’=(-TQ)R TQ P
  • 18. Beware! • Matrix multiplication is not commutative • The order of the transformations is vital – Rotation followed by translation is very different from translation followed by rotation – careful with the order of the matrices! • Small commutativity: – rotation commute with rotation, translation with translation…
  • 19. From World to Window • Inside the application: – application model – coordinates related to the model – possibly floating point • On the screen: – pixel coordinates – integer – restricted viewport: umin/umax, vmin/vmax
  • 20. From Model to Viewport ymax ymin xmin xmax
  • 21. From Model to Viewport • Model is (xmin,ymin)-(xmax,ymax) • Viewport is (umin,vmin)-(umax,vmax) • Translate by (-xmin,-ymin) • Scale by ( umax-umin , vmax-vmin ) xmax-xmin ymax-ymin • Translate by (umin,vmin) M = T’ST
  • 22. From Model to Viewport Pixel Coordinates Model Coordinates u x v M y w w
  • 23. Mouse position: inverse problem • Mouse click: coordinates in pixels • We want the equivalent in World Coord – because the user has selected an object – to draw something – for interaction • How can we convert from window coordinates to model coordinates?
  • 24. Mouse click: inverse problem • Simply inverse the matrix: 1 1 M (T ST) Model Coordinates Pixels coordinates x u 1 y M v w w
  • 25. 2D transformations: conclusion • Simple, consistent matrix notation – using homogeneous coordinates – all transformations expressed as matrices • Used by the window system: – for conversion from model to window – for conversion from window to model • Used by the application: – for modeling transformations