computer graphics course
play

COMPUTER GRAPHICS COURSE Transformations Georgios Papaioannou 2016 - PowerPoint PPT Presentation

COMPUTER GRAPHICS COURSE Transformations Georgios Papaioannou 2016 ABOUT TRANSFORMATIONS Transformations They are operators on vectors and points of a corresponding vector or affine space They alter the coordinates of shape vertices


  1. COMPUTER GRAPHICS COURSE Transformations Georgios Papaioannou – 2016

  2. ABOUT TRANSFORMATIONS

  3. Transformations • They are operators on vectors and points of a corresponding vector or affine space • They alter the coordinates of shape vertices • They are basic building blocks of geometric design: – Help us manipulate shapes to produce new ones – Help us express relations between coordinate systems in a virtual world

  4. Affine Transformations • An affine transformation Φ on an affine space is a transformation that preserve affine combinations 𝑜 𝑜 𝐪 = ෍ 𝑏 𝑗 𝐪 𝑗 ⟹ Φ 𝐪 = ෍ 𝑏 𝑗 Φ(𝐪 𝑗 ) 𝑗=0 𝑗=0 • For shapes in 𝔽 2 and 𝔽 3 this is an important property: • To transform a shape we only need to transform its defining vertices

  5. Affine Transformations on Vertices • Example: Φ Φ(𝐪 1 ) 𝐪 1 𝐪 0 Φ Φ(𝐪 0 ) • The midpoint of the transformed endpoints is the transformed midpoint – Similarly, all transformed points on the line segment can be linearly interpolated form the transformed endpoints

  6. Affine Transformations in 2D and 3D • Mappings of the form Φ 𝐪 = 𝐁 ∙ 𝐪 + 𝐮 are affine transformations in 𝔽 2 and 𝔽 3 • 2D: – 𝐁 is a 2X2 matrix and 𝑈 – 𝐮 is an offset vector in matric column form: 𝐮 = 𝑢 𝑦 𝑢 𝑧 • 3D: – 𝐁 is a 3X3 matrix and 𝑈 – 𝐮 is an offset vector in matric column form: 𝐮 = 𝑢 𝑦 𝑢 𝑧 𝑢 𝑨

  7. Linear Transformations • Linear transformations are affine transformations with the following properties: – Preserve additivity: Φ 𝐪 + 𝐫 = Φ 𝐪 + Φ 𝐫 – Preserve scalar multiplication: Φ 𝑑𝐪 = cΦ 𝐪 • Important: – The affine transformation Φ 𝐪 = 𝐁 ∙ 𝐪 + 𝐮 is not linear (why?) – But the transformation Φ 𝐪 = 𝐁 ∙ 𝐪 is!

  8. 2D TRANSFORMATIONS

  9. Geometric Transformations in 2D • The 4 common transformations that are used in computer graphics are:   – Translation T( ) p Ip t  – Rotation R( ) p R p  – Scaling  p S p S( ) sx sy , – Shearing  Sh( ) p Sh p sx sy , • All of the above transformations are invertible, i.e. given Φ 𝐪 , there always exists the inverse transformation Φ −1 𝐪 : 𝐪 ′ = Φ 𝐪 ⟺ 𝐪 = Φ −1 𝐪 ′

  10. 2D Translation • Moves a point on the plane 𝐪 ′ = 𝐉𝐪 + Ԧ 𝐮 = 𝐪 + Ԧ 𝐮 Y (𝑞 𝑦 + 𝑢 𝑦 , 𝑞 𝑧 + 𝑢 𝑧 ) 𝑢 𝑧 (𝑞 𝑦 , 𝑞 𝑧 ) X 𝑢 𝑦

  11. 2D Scaling 𝐓 𝑡 𝑦 ,𝑡 𝑧 = 𝑡 𝑦 0 𝐪 ′ = 𝐓 𝑡 𝑦 ,𝑡 𝑧 𝐪 0 𝑡 𝑧 • When 𝑡 𝑦 = 𝑡 𝑧 , then the scaling is isotropic (preserves angles) Y Y (3, 7) (2, 5) (4, 5) (6, 3.5) (8, 2.5) (4, 2.5) (2, 2) (4, 1) (4, 2) (8, 1) X X

  12. 2D Rotation • Rotates a point around the origin by angle θ                    x l cos l cos cos sin sin x cos y sin                    y l sin l cos sin sin cos x sin y cos       p x y , Y 𝐪 ′ = 𝐒 𝜄 𝐪    p x y , l 𝐒 𝜄 = cos 𝜄 − sin 𝜄 sin 𝜄 cos 𝜄 l θ φ X

  13. 2D Rotation - Examples Rotations are always relative to the coordinate system origin!

  14. 2D Shearing • Skews the shape by translating a point in one axis proportionally to its coordinate on the other axis 𝐪 ′ = 𝐓𝐢 𝑧,𝑐 𝐪 𝐪 ′ = 𝐓𝐢 𝑦,𝑏 𝐪 𝐓𝐢 𝑧,𝑐 = 1 0 𝐓𝐢 𝑦,𝑏 = 1 𝑏 𝑐 1 0 1 Y Y Y (4, 12) b =2 α =2 (4, 10) (2, 8) (2, 4) (4, 4) (10, 4) (12, 4) (2, 6) (6, 2) (8, 2) (2, 2) (4, 2) X X X

  15. Composite Transformations • Useful transformations in computer graphics and visualization rarely consist of a single basic affine transformation • Transformation composition is the stacking of operators (function composition): Φ ∘ Γ 𝐪 = Φ ( Γ 𝐪 ) • We can efficiently compute composite linear transformations

  16. Composite Linear Transformations (1) • A useful property of linear transformations is that a composite transformation can be expressed as matrix multiplication: Φ ∘ Γ 𝐪 = 𝚾 ∙ 𝚫 ∙ 𝐪 • In graphics, it allows the efficient computation of multiple composite transformations

  17. Composite Linear Transformations (2) • Example: 𝑆 45 o 𝑇 1,2 𝐪 = 𝐒 45 o 𝐓 1,2 𝐪

  18. Composite Linear Transformations (3) • Transformations are not commutative in general! 𝐒 45 o 𝐓 1,2 𝐪 ≠ 𝐒 45 o 𝐓 1,2 𝐪

  19. Composite Linear Transformations (4) • Unfortunately, translation cannot be expressed as a linear transformation and is therefore impossible to express it as a matrix multiplication • We must convert the transformation to a linear one

  20. Homogeneous Coordinates (1) • With homogeneous coordinates, we augment the dimensionality of the space by one • So 𝑦, 𝑧 𝑈 coordinates become 𝑦, 𝑧, 𝑥 𝑈 • Similarly, all transformations are now expressed as 3X3 matrices – For w=1 we get the basic representation of a point: 𝑦, 𝑧, 1 𝑈 – All points which are multiples of each other are equivalent – Typically, we work with the basic representation of points

  21. Homogeneous Coordinates (2) • Therefore the 2D space becomes a plane (slice) embedded in 3D space at w=1

  22. Homogeneous Coordinates (3) • Points on the homogeneous 2D plane define an affine space and not a vector space – Adding two vectors results in a vector outside the plane (remember we also add the w coordinates!) • The origin of our homogeneous coordinate system is typically (0,0,1) (or (0,0,w) in general) • Since addition is not defined in our space, how is translation expressed?

  23. Homogeneous Transformations (1) • Translation in our augmented, homogeneous space can be expressed as a linear transformation: – (it is actually a skew (shearing) transformation of x,y w.r.t. w in 3D) 𝑦 ′ 1 0 𝑢 𝑦 𝑦 𝑥=1 𝑦 ′ , 𝑧 ′ = 𝑦, 𝑧 + (𝑢 𝑦 , 𝑢 𝑧 ) 𝑧 ′ 𝑧 0 1 𝑢 𝑧 = 𝑥 𝑥 0 0 1 𝑦, 𝑧 (𝑢 𝑦 , 𝑢 𝑧 ) 𝑥 = 1

  24. Homogeneous Transformations (2) • Now all geometric transformations can be performed by matrix multiplication alone! • We can arbitrarily combine transformations in a unified manner 𝑆 𝜄 1 𝛶 𝑆 𝜄 2 𝛶 𝐰 2 𝑇 𝑡 1 ,𝑡 2 … 𝐪 … = 𝐒 𝜄 1 𝚼 𝐰 1 𝐒 𝜄 2 𝚼 𝐰 2 𝐓 𝑡 1 ,𝑡 2 𝐰 1 … 𝐪

  25. Homogeneous 2D Transformations • In matrix form (3X3) the homogeneous 2D transformations become: 1 0 𝑢 𝑦 1 𝑏 0 𝐓𝐢 𝑦,𝑏 = 𝐔 𝑢 𝑦 ,𝑢 𝑧 = 0 1 𝑢 𝑧 0 1 0 0 0 1 0 0 1 𝑡 𝑦 0 0 1 0 0 0 𝑡 𝑧 0 𝐓 𝑡 𝑦 ,𝑡 𝑧 = 𝐓𝐢 𝑧,𝑐 = 𝑐 1 0 0 0 1 0 0 1 cos 𝜄 − sin 𝜄 0 𝐒 𝜄 = sin 𝜄 cos 𝜄 0 0 0 1

  26. Representing Shape Transformations • In the following, we will apply transformations to entire shapes • This is equivalent to applying the transformations on each defining vertex of the shape • Notation: 𝑦 1 𝑦 2 𝑦 3 𝑦 4 𝑧 1 𝑧 2 𝑧 3 𝑧 4 𝐍 1 ∙ 𝐍 2 ∙ 𝑆𝑓𝑑𝑢 = 𝐍 1 ∙ 𝐍 2 ∙ 𝐰 1 𝐰 2 𝐰 3 𝐰 4 = 𝐍 1 ∙ 𝐍 2 ∙ 1 1 1 1 shape shape vertices

  27. Categorizing the Transformations • Affine: preserve linear combinations • Linear: can be expressed by a concatenation of matrices, preserve parallel lines • Similitudes: preserve ratios of distances and angles • Rigid: preserve distances

  28. Inverse Transformations • The inverse of geometric transformation is the inverse matrix 𝐍 −1 of the original transformation 𝐍 • The inverse of a concatenated transformation is the concatenation of the inverse matrices in reverse order: 𝐍 1 𝐍 2 𝐍 3 … 𝐍 𝑜 −1 = 𝐍 𝑜 −1 … 𝐍 3 −1 𝐍 2 −1 𝐍 1 −1 • Inverse of standard transformations: −1 = 𝐒 −𝜄 −1 −1 𝐔 𝑢 𝑦 ,𝑢 𝑧 = 𝐔 −𝑢 𝑦 ,−𝑢 𝑧 𝐒 𝜄 𝐓 𝑡 𝑦 ,𝑡 𝑧 = 𝐓 1 𝑡 𝑦 , 1 𝑡 𝑧

  29. Shape Composition • We can use geometric transformations to create complex shapes from simple primitive ones – We use the transformations to modify instances of the original shapes and arrange them in their pose in the composite object Original primitives (object space coords) Composite object Colored object

  30. 2D Transformation Example (1) • Given the following primitives y y 1 A B 1 1 x x 2 • Build this: y 1 1 3 1 1 0.5 x 4

  31. 2D Transformation Example (2) • First, let us try to decompose the target shape into primitives: Three shape groups: - Chassis ? - Wheels - Windshield • Observe that in 2D we can order primitives in different layers to hide parts of the geometry • Second, locate the origin of the resulting shape and compare it to the one of the primitives

  32. 2D Transformation Example (3) y • Chassis (3XB parts) C1 C2 C3 x • Looks like no scaling is required, just translations and rotations • Now observe where the pivot point should end in each one: y C1 C2 C3 B x

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