transformations projections 02
play

Transformations, Projections (02) RNDr. Martin Madaras, PhD. - PowerPoint PPT Presentation

Fundamentals of Computer Graphics and Image Processing Transformations, Projections (02) RNDr. Martin Madaras, PhD. madaras@skeletex.xyz Overview 2D Transformations Basic 2D transformations Matrix representation Matrix


  1. Fundamentals of Computer Graphics and Image Processing Transformations, Projections (02) RNDr. Martin Madaras, PhD. madaras@skeletex.xyz

  2. Overview  2D Transformations  Basic 2D transformations  Matrix representation  Matrix composition  3D Transformations  Basic 3D transformations  Same as 2D 2

  3. How the lectures should look like #1 Ask questions, please!!! - Be communicative - www.slido.com #ZPGSO02 - More active you are, the better for you! - We will go into depth as far, as there are no questions - 3

  4. Geometry space  Scene  Virtual representation of world  Objects  Visible objects (“real world”)  Invisible objects (e.g. lights, cameras, etc.) 4

  5. Full scene definition  Objects  What objects, where, how transformed  To be discussed early during course  How they look – color, material, texture...  To be discussed later during course  Camera  Position, target, camera parameters 5

  6. Coordinate system  Cartesian coordinates in 2D  Origin  x axis  y axis (5,3) 6

  7. Coordinate systems  Global  One for whole scene  Local  Individual for every model  Pivot point  Camera coordinates  Window coordinates  Units may differ  Conversion between coordinate spaces 7

  8. Global/local/camera coords. 8

  9. Essential basic algebra 9

  10. Point  Position in space  Cartesian coordinates ( , ) x y ( , , ) x y z  Homogeneous coordinates ( , , 1 ) x y  Subtraction of points  Translation ( , , , 1 ) x y z  Notation: P , A , … 10

  11. Vector  Direction in space  Has no position ( , ) x y  Subtraction of 2 points ( , , ) x y z  Cartesian coordinates ( , , 0 ) x y  Homogeneous coordinates ( , , , 0 ) x y z     Notation: , , u v n 11

  12. Vector  Addition Point + vector = point Vector + vector = vector  Subtraction Point – point = vector Point – vector = point + (-vector) = point Vector – vector = vector + (-vector) = vector  Multiplication Multiplier * vector = vector 12

  13. Ask questions Ask questions, please!!! - Be communicative - www.slido.com #PPGSO02 - More active you are, the better for you! - 13

  14. Transformations 14

  15. 2D Modeling Transformations  Modeling space and World space 15

  16. 2D Modeling Transformations  Transformed instances 16

  17. 2D Modeling Transformations  Transformation identity 17

  18. 2D Modeling Transformations  Scaling applied… 18

  19. 2D Modeling Transformations  Scaling and rotation applied… 19

  20. 2D Modeling Transformations  Scaling, rotation and translation applied… 20

  21. 2D Modeling Transformations  Translation:  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale:  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation:  x’ = x* cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 21

  22. 2D Modeling Transformations  Translation:  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale:  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation:  x’ = x* cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 22

  23. 2D Modeling Transformations  Translation:  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale :  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation:  x’ = x* cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 23

  24. 2D Modeling Transformations  Translation:  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale:  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation :  x’ = x *cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 24

  25. 2D Modeling Transformations  Translation :  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale:  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation:  x’ = x* cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 25

  26. 2D Modeling Transformations  Translation:  x’ = x + 𝑢 𝑦  y’ = y + 𝑢 𝑧  Scale:  x’ = x * 𝑡 𝑦  y’ = y * 𝑡 𝑧  Rotation:  x’ = x* cos Θ - y*sin Θ  y’ = x* sin Θ + y*cos Θ 26

  27. Overview  2D Transformations  Basic 2D transformations  Matrix representation  Matrix composition  3D Transformations  Basic 3D transformations  Same as 2D 27

  28. Matrix Representation  Represent 2D transformation by a matrix 𝑏 𝑐 𝑑 𝑒  Multiply matrix by column vector ⇔ transformation of a point 𝑦 𝑦′ 𝑧′ = 𝑏 𝑐 𝑦 ′ = 𝑏𝑦 + 𝑐𝑧 𝑧 𝑑 𝑒 𝑧 ′ = 𝑑𝑦 + 𝑒𝑧 28

  29. Matrix Representation  Transformations combined by multiplication 𝑦 𝑓 𝑔 𝑦′ 𝑗 𝑘 𝑧′ = 𝑏 𝑐 𝑧 𝑕 ℎ 𝑑 𝑒 𝑙 𝑚 Matrices are a convenient and efficient way to represent a sequence of transformations! 29

  30. 2x2 Matrices  What transformations can be represented by a 2x2 matrix?  2D Identity? 𝑦 𝑦′ 𝑧′ = 1 0 𝑦 ′ = 𝑦 𝑧 = 𝑧 𝑧 0 1  2D Scale around origin (0,0)? 𝑧′ = 𝑡 𝑦 0 𝑦 𝑦′ 𝑦 ′ = 𝑡 𝑦 ∗ 𝑦 𝑧 = 𝑡 𝑧 ∗ 𝑧 𝑧 0 𝑡 𝑧 30

  31. 2x2 Matrices  What transformations can be represented by a 2x2 matrix?  2D Rotate around origin (0,0)? 𝑦 ′ = x ∗ cos 𝜄 − y ∗ sin 𝜄 𝑦 𝑦′ 𝑧′ = cos 𝜄 − sin 𝜄 𝑧 ′ = x ∗ 𝑡𝑗𝑜 𝜄 + y ∗ 𝑑𝑝𝑡 𝜄 𝑧 𝑡𝑗𝑜 𝜄 𝑑𝑝𝑡 𝜄  2D Shear? 𝑦 ′ = 𝑦 + 𝑡ℎ 𝑦 ∗ 𝑧 𝑦 1 𝑡ℎ 𝑦 𝑦′ 𝑧 ′ = 𝑡ℎ 𝑧 ∗ 𝑦 + 𝑧 𝑧′ = 𝑧 𝑡ℎ 𝑧 1 31

  32. 2x2 Matrices  What transformations can be represented by a 2x2 matrix?  2D Mirror over Y axis? 𝑦 ′ = −𝑦 𝑦 𝑦′ 𝑧′ = −1 0 𝑧 ′ = 𝑧 𝑧 0 1  2D Mirror over (0,0)? 𝑦 ′ = −𝑦 𝑦 𝑦′ 𝑧′ = −1 0 𝑧 ′ = −𝑧 𝑧 0 −1 32

  33. 2x2 Matrices  What transformations can be represented by a 2x2 matrix?  2D Translation? 𝑦 ′ = 𝑦 + 𝑢 𝑦 𝑦 𝑦′ 𝑧′ = ? ? 𝑧 ′ = 𝑧 + 𝑢 𝑧 𝑧 ? ? Only a linear 2D transformations can be represented by a 2x2 matrix 33

  34. Linear Transformations  Linear transformations are combinations of ..  Scale  Rotation  Shear  Mirror  Properties of linear transformations:  Satisfies: 𝑈 𝑡 1 𝑞 1 + 𝑡 2 𝑞 2 = 𝑡 1 𝑈 𝑞 1 + 𝑡 2 𝑈(𝑞 1 )  Origin maps to origin  Lines map to lines  Parallel lines remain parallel  Ratios are preserved  Closed under composition 34

  35. 2D Translation  2D translation represented by a 3x3 matrix  Point represented in homogenous coordinates 𝑦 ′ = 𝑦 + 𝑢 𝑦 𝑦 ′ 1 0 𝑢 𝑦 𝑦 𝑧 ′ = 𝑧 + 𝑢 𝑧 = 𝑧 ′ 𝑧 0 1 𝑢 𝑧 1 1 0 0 1 35

  36. Homogenous 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 36

  37. Basic 2D Transformations  Basic 2D transformations as 3x3 matrices 𝑦 ′ 𝑦 ′ 1 0 𝑢 𝑦 𝑦 𝑡 𝑦 0 0 𝑦 = = 𝑧 ′ 𝑧 ′ 𝑧 𝑧 0 1 𝑢 𝑧 0 𝑡 𝑧 0 1 1 1 1 0 0 1 0 0 1 Translate Scale 𝑦 ′ 𝑦 ′ 𝑦 1 𝑡ℎ 𝑦 0 𝑦 cos 𝜄 −sin 𝜄 0 = = 𝑧 ′ 𝑧 ′ 𝑧 𝑧 𝑡ℎ 𝑧 1 0 sin 𝜄 cos 𝜄 0 1 1 0 0 1 1 1 0 0 1 Rotate Shear 37

  38. Affine Transformations  Affine transformations are combinations of...  Linear transformations, and  Translations 𝑦 ′ 𝑦 𝑏 𝑐 𝑑 = 𝑧 ′ 𝑧 𝑒 𝑓 𝑔 𝑥 0 0 1 𝑥′  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 38

  39. Projective Transformations  Projective transformations: 𝑦 ′ 𝑏 𝑐 𝑑 𝑦 𝑧 ′ = 𝑒 𝑓 𝑔 𝑧 𝑥 𝑕 ℎ 𝑗 𝑥′  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 39

  40. Overview  2D Transformations  Basic 2D transformations  Matrix representation  Matrix composition  3D Transformations  Basic 3D transformations  Same as 2D 40

  41. Matrix Composition  Transformations can be combined by matrix multiplication 𝑦 ′ 1 0 𝑢 𝑦 𝑡 𝑦 0 0 𝑦 cos 𝜄 −sin 𝜄 0 𝑧 ′ = 𝑧 0 1 𝑢 𝑧 0 𝑡 𝑧 0 sin 𝜄 cos 𝜄 0 𝑥 0 0 1 𝑥′ 0 0 1 0 0 1 P’ = T( 𝑢 𝑦 , 𝑢 𝑧 ) R( 𝜄 ) S( 𝑡 𝑦 , 𝑡 𝑧 ) P 41

  42. Matrix Composition  Matrices are a convenient and efficient way to represent a sequence of transformations  General purpose representation  Hardware matrix multiply  Efficiency with premultiplication  Matrix multiplication is associative P’ = (T * (S * (R * p))) P’ = (T * S * R) * p 42

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend