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.
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
More Related Content
Presentation Transcript
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
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.
What is a Transformation? • A function that maps points x to points x': Applications: animation, deformation, viewing, projection, real-time shadows, …
Simple Transformations • Can be combined • Are these operations invertible? Yes, except scale = 0
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)
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.
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
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
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
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 =
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)
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 =
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 ….
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 …
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”
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!
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)
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 = =
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
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)