computer graphics
play

Computer Graphics - Transformations - Hendrik Lensch Computer - PowerPoint PPT Presentation

Computer Graphics - Transformations - Hendrik Lensch Computer Graphics WS07/08 Transformations Overview Last Time Tone Mapping Today Homogeneous Coordinates Basic transformations in homogeneous coordinates


  1. Computer Graphics - Transformations - Hendrik Lensch Computer Graphics WS07/08 – Transformations

  2. Overview • Last Time – Tone Mapping • Today – Homogeneous Coordinates – Basic transformations in homogeneous coordinates – Concatenation of transformations – Projective transformations • Next Lecture – Camera transformations Computer Graphics WS07/08 – Transformations

  3. Euclidean Vector Space • Known from Mathematics: – Elements of a 3D vector space • v = (v 1 , v 2 , v 3 ) T ∈ V 3 = R 3 – Formally: Vectors written as column vectors (n x 1 matrix)! – Vectors describe directions – not positions! – 3 linear independent vectors create a basis: • {e 1 , e 2 , e 3 } – Any vector can now uniquely be represented with coordinates • v = v 1 e 1 + v 2 e 2 + v 3 e 3 = (v 1 , v 2 , v 3 ) T – Operations e 3 e • Addition, Subtraction, Scaling, … 3 e 2 e 2 • Metric – Dot/inner product: e 1 e 1 • Used for measurements of length (|v| 2 = v · v) and angles (cos(v 1 , v 2 )= v 1 · v 2 / | v 1 ||v 2 |) – Orthonormal basis e i · e j = δ ij right-/left handed: e 1 × e 2 = +/- e 3 • |e i |= 1 Computer Graphics WS07/08 – Transformations

  4. Affine Space • Known from Mathematics – Affine Space: A 3 • Elements are positions – no directions! – Defined via its associated vector space V 3 • a, b ∈ A 3 ⇔ v ∈ V 3 with v = b – a → : unique, ← : ambiguous – Addition of points and vectors (p + v ∈ A 3 ) • distance(a, b) = length(a - b) – Operations on A 3 • Subtraction yields a vector • No addition of affine elements a a v v b Computer Graphics WS07/08 – Transformations

  5. Affine Basis • Affine Basis: – {o, e1, e2, e3} • Origin: o ∈ A 3 and • Basis of vector space – Position vector of point p • (p – o) ∈ V3 e 3 e 3 e 2 e 2 o e 1 e 1 Computer Graphics WS07/08 – Transformations

  6. Affine Coordinates • Affine Combination – Linear combination of (n+1) points – Weights form a partition of unity – b 0 , … , b n ∈ A n n n n ∑ ∑ ∑ ∑ = α = + α − = + α α = b b b b b o e ( ) , mit 1 i i i i i i i 0 0 = = = i i i 0 1 1 • Affine Coordinates – Barycentric coordinates – Center of mass (R = Σ m i r i / Σ m i ) – Affine weighted sum • Weights given by the splitting ratio – p= α 1 p 1 + α 2 p 2 α 2 α 2 α 1 + α 2 = 1 p p p 1 p 1 α 1 α 1 p p 2 2 Computer Graphics WS07/08 – Transformations

  7. Affine Mappings • Properties – Affine mapping (continuous, bijective, invertible) • T: A 3 → A 3 – Defined by two non-degenerated simplicies • 2D: Triangle, 3D: Tetrahedron, ... – Affine/Barycentric coordinates are invariant under affine transformations – Other invariants • Straight lines, parallelism, splitting ratios, surface/volume ratios – Characterization via fixed points and lines • Eigenvalues and eigenvectors of the mapping • Representation α 2 α – Linear mapping A plus a translation t 2 p p p p 1 • T p = A p + t with (n x n) matrix A 1 α 1 α – Invariance of affine coordinates 1 • Tp= T( α 1 p 1 + α 2 p 2 )= A( α 1 p 1 + α 2 p 2 ) + t = α 1 A(p 1 ) + α 2 A(p 2 ) + α 1 t + α 2 t = α 1 Tp 1 + α 2 T( p 2 ) p 2 p 2 Computer Graphics WS07/08 – Transformations

  8. Homogeneous Coordinates for 3D • Embedding of R 3 into P(R 4 ) – For the time being ⎛ ⎞ ⎛ ⎞ x X ⎜ ⎟ ⎜ ⎟ ⎛ ⎞ ⎛ ⎞ x X W / ⎜ ⎟ ⎜ ⎟ y Y ⎜ ⎟ ⎜ ⎟ ∋ → ∈ → R y Y W 3 ⎜ ⎟ 4 ⎜ ⎟ P(R ), and / ⎜ ⎟ ⎜ ⎟ z Z ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ z Z W ⎝ ⎠ ⎝ ⎠ / ⎜ ⎟ ⎜ ⎟ W ⎝ ⎠ ⎝ ⎠ 1 – Representation of transformations by 4x4 matrices – Mathematical trick • Convenient representation to express rotations and translations as matrix multiplications • Easy to find line through points, point-line/line-line intersections – Also important for projections (later) Computer Graphics WS07/08 – Transformations

  9. Point Representation X = ( X,Y,W ) (x,y) w =1 X Y = = x y W W Computer Graphics WS07/08 – Transformations

  10. Line Representation l= (a,b,c) ax+by+c=0 Computer Graphics WS07/08 – Transformations

  11. Point on Line X = (X,Y,W) l = (a,b,c) ⋅ l = x 0 Computer Graphics WS07/08 – Transformations

  12. Intersection of Lines x l’ l × = l ' l x Computer Graphics WS07/08 – Transformations

  13. Line through 2 Points X = (X,Y,W) X’ = (X’,Y’,W’) l = (a,b,c) × = x ' x l Computer Graphics WS07/08 – Transformations

  14. Linear Map = Matrix • Vector Matrix Product – Action of a linear map on a vector • Multiplication of matrix with column vector ⎛ ⎞ t t t t ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ x x x ' ⎜ xx xy xz xw ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ t t t t y y ⎜ ⎟ y ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ' yx yy yz yw = = = = p T p T ' ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ t t t t z z z ' ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ zx zy zz zw ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ t t t t w w w ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ' ⎝ ⎠ wx wy wz ww • In some old text books: row vector times the transpose of this matrix – Composition (first T 1 , then T 2 ) • Matrix multiplication • T 2 T 1 p = T 2 (T 1 p) = (T 2 T 1 ) p = T p • Warning: In general, matrix multiplication does not commute !!! Computer Graphics WS07/08 – Transformations

  15. Basic Transformations • Translation ⎛ ⎞ d 1 0 0 ⎜ x ⎟ d ⎜ ⎟ 0 1 0 = y T d d d ( , , ) ⎜ ⎟ x y z d 0 0 1 ⎜ ⎟ z ⎜ ⎟ ⎝ ⎠ 0 0 0 1 + ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ d p p d 1 0 0 ⎜ x ⎟ ⎜ x ⎟ ⎜ x x ⎟ + d p p d ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ 0 1 0 = y y = y y p T ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ + d p p d 0 0 1 ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ z z z z ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ 0 0 0 1 1 1 Computer Graphics WS07/08 – Transformations

  16. Translation of Vectors • So far we looked at points (affine entities) • Vectors are defined as the difference of two points • Consequently, for vectors W is always equal to zero − ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ p q p q ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ x x x x − p q p q ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ = − = y − y = y y v p q ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ − p q p q ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ z z z z ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ 1 1 0 • This means that translations DO NOT act on vectors – Which is exactly what we expect to happen ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ d v v 1 0 0 ⎜ x ⎟ ⎜ x ⎟ ⎜ x ⎟ d v v ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ 0 1 0 = y y = y = v v T ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ d v v 0 0 1 ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ z z z ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ 0 0 0 1 0 0 Computer Graphics WS07/08 – Transformations

  17. Translations • Properties – T(0,0,0)= 1 (Identity Matrix) – T(t x , t y , t z ) T(t x ’, t y ’,t z ’) = T(t x + t x ’, t y + t y ’, t z + t z ’) – T(t x , t y , t z ) T(t x ’, t y ’,t z ’) = T(t x ’, t y ’,t z ’) T(t x , t y , t z ) – T -1 (t x , t y , t z ) = T(-t x , -t y , -t z ) Computer Graphics WS07/08 – Transformations

  18. Rotation • Rotation in 2D y = θ x r cos r sin( θ + ϕ ) = θ y r sin = θ + ϕ x r ' cos( ) r sin θ = θ + ϕ y r θ + ϕ ' sin( ) θ θ + ϕ = θ ϕ − θ ϕ cos( ) cos cos sin sin x r cos θ r cos( θ + ϕ ) θ + ϕ = θ ϕ + θ ϕ sin( ) cos sin sin cos = θ ϕ − θ ϕ = ϕ − ϕ x r r x y ' ( cos ) cos ( sin ) sin cos sin = θ ϕ + θ ϕ = ϕ + ϕ y r r x y ' ( cos ) sin ( sin ) cos sin cos Computer Graphics WS07/08 – Transformations

  19. Basic Transformations • Rotation around major axis θ θ ⎛ ⎞ ⎛ ⎞ 1 0 0 0 cos 0 sin 0 ⎜ ⎟ ⎜ ⎟ θ − θ ⎜ ⎟ ⎜ ⎟ 0 cos sin 0 0 1 0 0 θ = θ = R R ( ) ( ) ⎜ ⎟ ⎜ ⎟ x y θ θ − θ θ 0 sin cos 0 sin 0 cos 0 ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ 0 0 0 1 0 0 0 1 θ − θ ⎛ ⎞ cos sin 0 0 ⎜ ⎟ θ θ ⎜ ⎟ sin cos 0 0 θ = R ( ) ⎜ ⎟ z 0 0 1 0 ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ 0 0 0 1 – Assumes a right handed coordinate system Computer Graphics WS07/08 – Transformations

  20. Rotation • Properties – R a (0)= 1 a ( θ ) = R a (- θ ) – R -1 – R a ( θ ) R a ( ϕ ) = R a ( θ + ϕ ) – R a ( θ ) R a ( ϕ ) = R a ( ϕ ) R a ( θ ) a ( θ ) = R a (- θ ) = R T a ( θ ) – R -1 – BUT in general: R a ( θ ) R b ( ϕ ) ≠ R b ( ϕ ) R a ( θ ) • For rotations around different axes, the order matters Computer Graphics WS07/08 – Transformations

  21. Basic Transformations • Scaling ⎛ ⎞ s 0 0 0 ⎜ ⎟ x s ⎜ ⎟ 0 0 0 = y S s s s ( , , ) ⎜ ⎟ x y z s 0 0 0 ⎜ ⎟ z ⎜ ⎟ ⎝ ⎠ 0 0 0 1 – Uniform Scaling • s x = s y = s z Computer Graphics WS07/08 – Transformations

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