1 / 172

Modeling Transformations

Modeling Transformations. CSE 409. Md. Tanvir Al Amin* Lecturer, Dept. of CSE, BUET tanviralamin@gmail.com. *Special Thanks to Tanvir Parvez , Fredo Durand, James O Brien, Tomas Lozano-Perez, Jovan Popovic. Modeling Transformation - Class 1. Transformation Background.

kassia
Download Presentation

Modeling Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Modeling Transformations CSE 409 Md. Tanvir Al Amin* Lecturer, Dept. of CSE, BUET tanviralamin@gmail.com *Special Thanks to TanvirParvez, Fredo Durand, James O Brien, Tomas Lozano-Perez, Jovan Popovic

  2. Modeling Transformation - Class 1

  3. Transformation Background What is Transformation ?

  4. What is a Transformation • Transformation: • An operation that changes one configuration into another • For images, shapes, etc. • A geometric transformation maps positions that define the object to other positions • Linear transformation means the transformation is defined by a linear function... which is what matrices are good for.

  5. What is a Transformation? • A function that maps points x to points x': Applications: animation, deformation, viewing, projection, real-time shadows, …

  6. Simple Transformations • Can be combined • Are these operations invertible? Yes, except scale = 0

  7. Rigid-Body / Euclidean Transforms • Preserves distances • Preserves angles Rigid / Euclidean Identity Translation Rotation

  8. Similitudes / Similarity Transforms • Preserves angles Similitudes Rigid / Euclidean Identity Translation Isotropic Scaling Rotation

  9. Linear Transformations Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear

  10. Linear Transformations • L(p + q) = L(p) + L(q) • L(ap) = a L(p) Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear Translation is not linear because ap+t ≠ a(p+t)

  11. Affine Transformations • preserves parallel lines Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear

  12. Projective Transformations • preserves lines Projective Affine Similitudes Linear Rigid / Euclidean Scaling Identity Translation Isotropic Scaling Reflection Rotation Shear 6.837 Fall 06 – Durand Perspective

  13. Groups • Properties of a group (element, operation): • There exists a neutral element • There exists an inverse for each member • The elements are "closed under composition" • The composition operation is associative • Example: integers under addition 0 is the neutral element -x is the inverse of x x+y is an integer (x+y)+z=x+(y+z)

  14. Groups and Transformations • Properties of a group: • There exists an identity mapping • There exists an inverse mapping for each function • The functions are "closed under composition" • The composition operation is associative • These properties might seem trivial at first glance, but they are actually very important, because when these conditions are shown for any class of functions and their two-argument composition operation, then they form an algebraic group. • One of the consequences is that any series of translations can be composed to a single translation. • Another consequence is that the inverse is unique.

  15. How are Transforms Represented? x' = ax + by + c y' = dx + ey + f x y c f x' y' a b d e + = p' = M p + t

  16. Translation in homogenous coordinates x' = ax + by + c y' = dx + ey + f Affine formulation Homogeneous formulation c f 1 x y 1 x' y‘ 1 a b d e 0 0 = x y c f x' y' a b d e + = p' = M p + t p' = M p

  17. Homogeneous Co-ordinates • Translation, scaling and rotation are expressed (non-homogeneously) as: • translation: P = P + T • Scale: P = S · P • Rotate: P = R · P • Composition is difficult to express, since translation not expressed as a matrix multiplication • Homogeneous coordinates allow all three to be expressed homogeneously, using multiplication by 3 ´ 3 matrices • W is 1 for affine transformations in graphics

  18. Homogeneous Coordinates • Add an extra dimension • in 2D, we use 3 x 3 matrices • In 3D, we use 4 x 4 matrices • Each point has an extra value, w a e i m b f j n c g k o d h l p x y z w x' y' z' w' = p' = M p

  19. Homogeneous Coordinates • Most of the time w = 1, and we can ignore it • If we multiply a homogeneous coordinate by an affine matrix, w is unchanged a e i 0 b f j 0 c g k 0 d h l 1 x y z 1 x' y' z' 1 =

  20. w Ph(x,y,w) w=1 P2d(x,y,1) y x Homogeneous Co-ordinates • P2d is a projection of Ph onto the w = 1 plane • So an infinite number of points correspond to : they constitute the whole line (tx, ty, tw)

  21. Homogeneous Visualization

  22. Mechanics of Rigid Transformations Translate Rotate Scale

  23. x’ = x + dx y’ = y + dy Translation – 2D

  24. Translation – 3D

  25. Scaling – 2D • Types of Scaling: • Differential ( sx != sy ) • Uniform ( sx = sy )

  26. Original scale Y axis scale all axes Scaling – 3D

  27. rotated original Rotation – 2D

  28. Rotation – 2D

  29. Modeling Transformation - Class 2

  30. Rotation – 3D For 3D-Rotation 2 parameters are needed • Angle of rotation • Axis of rotation Rotation about z-axis:

  31. Rotation about Y-axis & X-axis About y-axis About x-axis

  32. Rotation about Z axis ZRotate(θ) y p' • About z axis θ p x z cos θ sin θ 0 0 -sin θ cos θ 0 0 0 0 1 0 0 0 0 1 x y z 1 x' y' z' 1 =

  33. Rotation • How to rotate around (kx, ky, kz), a unit vector on an arbitrary axis … • Example : Rotate 30 degree around vector 2i+1j+3k • For now, solution is Rodrigues Formula • Can it be found from some rotation around x axis, then some rotation around y axis, then z axis ? • We will munch it later ….

  34. Rotation Rotate(k, θ) y θ • About (kx, ky, kz), a unit vector on an arbitrary axis(Rodrigues Formula) k x z kxkx(1-c)+c kykx(1-c)+kzs kzkx(1-c)-kys 0 kykx(1-c)-kzs kyky(1-c)+c kzky(1-c)+kxs 0 kxkz(1-c)+kys kykz(1-c)-kxs kzkz(1-c)+c 0 0 0 0 1 x y z 1 x' y' z' 1 = where c = cos θ & s = sin θ We will return to this case of arbitrary rotation later …

  35. Non Rigid Transforms

  36. Non Rigid Transforms • We just studied Translation, Scale, Rotate • All these are Rigid Transformations • Is Shear rigid ? • No • Shear is Linear Transform • However, Translate, Scale, Rotate, Shear, Reflect all are member of general class “Affine Transformation”

  37. Mirror Reflection

  38. Shearing Transformation

  39. y x z Shear along Z-axis

  40. Inverse Transforms

  41. Inverse Transformations

  42. Composing Transformations

  43. 0 0 0 0 0 0 1 1 1 How are transforms combined? Scale then Translate (5,3) (2,2) Scale(2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Use matrix multiplication: p' = T ( S p ) = TS p 0 1 0 2 0 2 1 0 3 1 2 0 0 0 2 0 3 1 TS = = Caution: matrix multiplication is NOT commutative!

  44. Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (5,3) (2,2) Scale(2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Translate then Scale: p' = S ( T p ) = ST p (8,4) (4,2) Translate(3,1) Scale(2,2) (6,2) (1,1) (3,1) (0,0)

  45. 0 0 0 0 0 0 1 1 1 Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p 0 1 0 0 2 0 0 2 0 1 0 0 3 1 1 2 0 0 0 0 1 2 0 0 3 1 1 TS = = Translate then Scale: p' = S ( T p ) = ST p 0 2 0 1 0 2 2 0 0 0 1 0 3 1 2 0 6 2 ST = =

  46. Combining Translations, Rotations • Order matters!! TR is not the same as RT (demo) • General form for rigid body transforms • We show rotation first, then translation (commonly used to position objects) on next slide. Slide after that works it out the other way

  47. Rotate then Translate

  48. Translate then Rotate

  49. Classification of Transformations Again • Rigid-body Transformation • Preserves parallelism of lines • Preserves angle and length • e.g. any sequence of R() and T(dx,dy) • Affine Transformation • Preserves parallelism of lines • Doesn’t preserve angle and length • e.g. any sequence of R(), S(sx,sy) and T(dx,dy)

  50. Example Affine Transforms

More Related