welcome
play

Welcome 1 Note for todays lecture Will be closely following book - PowerPoint PPT Presentation

Graphics (INFOGR), 2018-19, Block IV, lecture 12 Deb Panja Today: Matrix reloaded 2 (or Viewing Transformations) Welcome 1 Note for todays lecture Will be closely following book chapter 7 (read it thoroughly to grab the concepts)


  1. Graphics (INFOGR), 2018-19, Block IV, lecture 12 Deb Panja Today: Matrix reloaded 2 (or Viewing Transformations) Welcome 1

  2. Note for today’s lecture • Will be closely following book chapter 7 (read it thoroughly to grab the concepts) • Most of the lecture will be in symbols 2

  3. Today • Redo part of last lecture • Rotation co-ordinate transformation revisited • Viewing transformation (getting world space → screen space) − viewport transfomation − orthographic tranformation − camera transformation − projection transformation − “graphics pipeline”: putting everything together • Summary maths lectures 3

  4. Redo part of last lecture 4

  5. From last lecture • Point, or active transformations  − translation    redo − projection   − reflection  − scaling − shearing − rotation − linear transformation properties − combining transformations (and transformation back!) • Co-ordinate, or passive transformations 5

  6. Translation: a matrix operation • We translate a point P ( x, y, z ) by ( a x , a y , a z ) i.e., x ′ = x + a x , y ′ = y + a y , z ′ = z + a z       x ′ 1 0 0 a x x   a x y ′ 0 1 0 a y y       = ; � a = a y         z ′ 0 0 1 a z z       a z 1 0 0 0 1 1 � �� � � �� � � �� � w t � M t ( � a ) � v 6

  7. How to think about an extended vector for 2D v · ˆ • Note: A “real” vector � v , by construction, satisfies � f = 0   v x e.g., the (2+1)D representation of a real vector in 2D is v y   0 7

  8. Projecting and reflecting vectors 8

  9. Projecting and reflecting vectors original vector projected vector reflected vector These rules always hold! 9

  10. Projecting a vector: a matrix operation in (3+1)D     w p · ˆ � x � v · ˆ x − ( � v · ˆ n )(ˆ n · ˆ x ) w p · ˆ � y � v · ˆ y − ( � v · ˆ n )(ˆ n · ˆ y )     w p = � � v − ( � v · ˆ n ) ˆ n ; for d = 3, � w p =  =     w p · ˆ � z � v · ˆ z − ( � v · ˆ n )(ˆ n · ˆ z )    w p · ˆ v · ˆ � f � f   1 − n 2 − n x n y − n x n z 0 x 1 − n 2 − n x n y − n y n z 0   y w p = M p � � v ; M p =   1 − n 2 − n x n z − n y n z 0   z 0 0 0 1 10

  11. Reflecting a vector: a matrix operation in (3+1)D   � v · ˆ x − 2( � v · ˆ n )(ˆ n · ˆ x ) v · ˆ � y − 2( � v · ˆ n )(ˆ n · ˆ y )   w r = � � v − 2( � v · ˆ n )ˆ n ; for d = 3, � w r =   � v · ˆ z − 2( � v · ˆ n )(ˆ n · ˆ z )   v · ˆ � f   1 − 2 n 2 − 2 n x n y − 2 n x n z 0 x 1 − 2 n 2 − 2 n x n y − 2 n y n z 0   y w r = M r � � v ; M r =   1 − 2 n 2 − 2 n x n z − 2 n y n z 0   z 0 0 0 1 11

  12. Projecting and reflecting points 12

  13. Projecting and reflecting points (on an object) • Can we use vector projection/reflection formulae for points as well? yes, provided care is taken 13

  14. Projecting and reflecting points (on an object) • Can we use vector projection/reflection formulae for points as well? yes, provided care is taken • Why? because specifying a vector (arrow) does not specify its starting point;   x  from the origin, although point P ( x, y, z ) is reached by vector y  z the origin may “move” upon projection/reflection 14

  15. Projecting points (on an object) • Specifying a vector (arrow) does not specify its starting point;   x  from the origin, although point P ( x, y, z ) is reached by vector y  z the origin may “move” upon projection/reflection ← − − − → contrast 15

  16. Projecting and reflecting points (on an object) • Specifying a vector (arrow) does not specify its starting point;   x  from the origin, although point P ( x, y, z ) is reached by vector y  z the origin may “move” upon projection/reflection ← − − − → contrast • The case for reflection is similar (not shown further) 16

  17. Rotation co-ordinate transformation revisited 17

  18. Active rotation in (2+1)D revisited       x ′ cos θ − sin θ 0 x  = • Active: y ′ sin θ cos θ 0 y      1 0 0 1 1 • Now consider the passive (co-ordinate) rotation 18

  19. Active rotation in (2+1)D revisited       x ′ cos θ − sin θ 0 x  = • Active: y ′ sin θ cos θ 0 y      1 0 0 1 1 • Now consider the passive (co-ordinate) rotation     x ′ x  = M ro Q. y ′ y  ; M ro =?   1 1 19

  20. Active rotation in (2+1)D revisited       x ′ cos θ − sin θ 0 x  = • Active: y ′ sin θ cos θ 0 y      1 0 0 1 1 • Now consider the passive (co-ordinate) rotation     x ′ x  = M ro Q. y ′ y  ; M ro =?   1 1       x ′ cos θ sin θ 0 x  = A. y ′ − sin θ cos θ 0 y      1 0 0 1 1 20

  21. Passive rotation in (2+1)D       x ′ cos θ sin θ 0 x  = • y ′ − sin θ cos θ 0 y      1 0 0 1 1 x ′ = ˆ x ′ = − ˆ cos θ = ˆ x · ˆ y · ˆ y ′ , sin θ = ˆ y · ˆ x · ˆ y ′    x ′ · ˆ x ′ · ˆ        x ′ ˆ x ˆ y 0 x x x ′ y x ′ 0 x y ′ · ˆ y ′ · ˆ  =  = then y ′ ˆ x ˆ y 0 y x y ′ y y ′ 0 y         1 0 0 1 1 0 0 1 1 21

  22. Passive rotation in (3+1)D           u u · ˆ ˆ x u · ˆ ˆ y u · ˆ ˆ z 0 x x u y u z u 0 x v v · ˆ ˆ x v · ˆ ˆ y v · ˆ ˆ z 0 y x v y v z v 0 y           •  =  =           w w · ˆ ˆ x w · ˆ ˆ y w · ˆ ˆ z 0 z x w y w z w 0 z         1 0 0 0 1 1 0 0 0 1 1 22

  23. Viewing transformation 23

  24. What is viewing transformation? 24

  25. What is viewing transformation? • Will achieve these (passive!) transformations by concatenating matrices 25

  26. What is viewing transformation? • Will achieve these (passive!) transformations by concatenating matrices (and we need to do that in the reverse order of transformations) 26

  27. Viewport transformation 27

  28. Viewport transformation − − − − → M vp 28

  29. Viewport transformation − − − − → M vp • Canonical view space: ( x, y, z ) ∈ [ − 1 , 1] 3 • Screen space: n x × n y pixels • M vp : transform [ − 1 , 1] 2 → [ − 0 . 5 , n x − 0 . 5] × [ − 0 . 5 , n y − 0 . 5] (only for x and y , don’t care about z ) 29

  30. Viewport transformation: M vp • M vp : transform [ − 1 , 1] 2 → [ − 0 . 5 , n x − 0 . 5] × [ − 0 . 5 , n y − 0 . 5] (only for x and y , don’t care about z ) • Concatenate translation after scaling (diagonal matrix): ↓ ↓     n x − 1 n x 1 0 0 0 0 0 2 2 n y n y − 1 0 0 0 0 1 0     2 2     0 0 1 0 0 0 1 0     0 0 0 1 0 0 0 1 30

  31. Viewport transformation: M vp • M vp : transform [ − 1 , 1] 2 → [ − 0 . 5 , n x − 0 . 5] × [ − 0 . 5 , n y − 0 . 5] (only for x and y , don’t care about z ) • Concatenate translation after scaling (diagonal matrix): ↓ ↓     n x − 1 n x 1 0 0 0 0 0 2 2 n y n y − 1 0 0 0 0 1 0     2 2     0 0 1 0 0 0 1 0     0 0 0 1 0 0 0 1 31

  32. Viewport transformation: M vp • M vp : transform [ − 1 , 1] 2 → [ − 0 . 5 , n x − 0 . 5] × [ − 0 . 5 , n y − 0 . 5] (only for x and y , don’t care about z ) • Concatenate translation after scaling (diagonal matrix): ↓ ↓     n x − 1 n x 1 0 0 0 0 0 2 2 n y n y − 1 0 0 0 0 1 0     2 2     0 0 1 0 0 0 1 0     0 0 0 1 0 0 0 1   n x n x − 1 0 0 2 2 n y n y − 1 0 0   • After concatenation, we obtain M vp = 2 2   0 0 1 0   0 0 0 1 32

  33. Orthographic projection transformation 33

  34. Orthographic transformation − − − − → M ortho (canonical view volume) • M ortho : transform [ l, r ] × [ b, t ] × [ n, f ] → [ − 1 , 1] 3 34

  35. Orthographic transformation: M ortho • M ortho : transform [ l, r ] × [ b, t ] × [ n, f ] → [ − 1 , 1] 3 • Concatenate scaling (diagonal matrix) after translation: ↓ ↓     2 − r + l 0 0 0 1 0 0 r − l 2 2 − t + b   0 0 0 0 1 0     t − b 2   2   − n + f 0 0 0 0 0 1     n − f 2 0 0 0 1 0 0 0 1   2 − r + l 0 0 r − l r − l 2 − t + b   0 0   t − b t − b • After concatenation we obtain M ortho =  − n + f  2 0 0   n − f n − f 0 0 0 1 35

Recommend


More recommend