Transformations

MIT EECS 6.837, Durand and Cutler

Outline
• • • • • • Assignment 0 Recap Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Change of Orthonormal Basis

MIT EECS 6.837, Durand and Cutler

Cool Results from Assignment 0
(Image removed due to copyright considerations.)

emmav
(Courtesy of Emily Vincent. Used with permission.)

psoto
(Courtesy of Paul Soto. Used with permission.)

(Image removed due to copyright considerations.)

scyudits
MIT EECS 6.837, Durand and Cutler
(Courtesy of Sophia Yuditskaya. Used with permission.)

Notes on Assignments
• Make sure you turn in a linux or windows executable (so we can test your program) • Collaboration Policy
– Share ideas, not code

• Tell us how much time you spent on each assignment

MIT EECS 6.837, Durand and Cutler

Quick Review of Last Week • Ray representation • Generating rays from eyepoint / camera – orthographic camera – perspective camera • Find intersection point & surface normal • Primitives: – spheres. triangles. planes.837. Durand and Cutler . boxes MIT EECS 6. polygons.

Durand and Cutler .837.Outline • • • • • • Assignment 0 Recap Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Change of Orthonormal Basis MIT EECS 6.

What is a Transformation? • Maps points (x. IFS: MIT EECS 6. y') in another coordinate system x' = ax + by + c y' = dx + ey + f • For example. y) in one coordinate system to points (x'.837. Durand and Cutler .

Used with permission. Durand and Cutler z o .Common Coordinate Systems • Object space – local to each object FAR NEAR • World space – common to all objects z o y x EYE • Eye space / Camera space – derived from view frustum x z NDC y • Screen space – indexed according to hardware attributes ((Courtesy x y of Seth Teller.) MIT EECS 6.837.

Durand and Cutler . except scale = 0 MIT EECS 6.Simple Transformations • Can be combined • Are these operations invertible? Yes.837.

Transformations are used: • • • • • Position objects in a scene (modeling) Change the shape of objects Create multiple copies of objects Projection for virtual cameras Animations MIT EECS 6. Durand and Cutler .837.

837. Durand and Cutler .Outline • Assignment 0 Recap • Intro to Transformations • Classes of Transformations • • • • • Rigid Body / Euclidean Transforms Similitudes / Similarity Transforms Linear Affine Projective • Representing Transformations • Combining Transformations • Change of Orthonormal Basis MIT EECS 6.

Rigid-Body / Euclidean Transforms • Preserves distances • Preserves angles Rigid / Euclidean Translation Identity Rotation MIT EECS 6.837. Durand and Cutler .

Durand and Cutler .837.Similitudes / Similarity Transforms • Preserves angles Similitudes Rigid / Euclidean Translation Identity Rotation Isotropic Scaling MIT EECS 6.

Linear Transformations Similitudes Linear Rigid / Euclidean Translation Identity Rotation Scaling Isotropic Scaling Reflection Shear MIT EECS 6.837. Durand and Cutler .

Durand and Cutler .Linear Transformations • L(p + q) = L(p) + L(q) • L(ap) = a L(p) Similitudes Linear Rigid / Euclidean Translation Identity Rotation Scaling Isotropic Scaling Reflection Shear MIT EECS 6.837.

Affine Transformations • preserves parallel lines Affine Similitudes Linear Rigid / Euclidean Translation Identity Rotation Scaling Isotropic Scaling Reflection Shear MIT EECS 6. Durand and Cutler .837.

Projective Transformations • preserves lines Projective Affine Similitudes Linear Rigid / Euclidean Translation Identity Rotation Scaling Isotropic Scaling Reflection Shear MIT EECS 6.837. Durand and Cutler Perspective .

Perspective Projection MIT EECS 6. Durand and Cutler .837.

Durand and Cutler .Outline • • • • • • Assignment 0 Recap Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Change of Orthonormal Basis MIT EECS 6.837.

Durand and Cutler .How are Transforms Represented? x' = ax + by + c y' = dx + ey + f x' = y' a d b e c x + f y p' = Mp + t MIT EECS 6.837.

we use 3 x 3 matrices • In 3D. Durand and Cutler . w a b x' e f y' = i j z' m n w' c g k o d h l p x y z w p' = Mp MIT EECS 6. we use 4 x 4 matrices • Each point has an extra value.Homogeneous Coordinates • Add an extra dimension • in 2D.837.

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

837.Homogeneous Visualization • Divide by w to normalize (homogenize) • W = 0? Point at infinity (direction) (0. 1) = (14. 1. 0. 1) = (0. 2) = … w = 1 (7. 1) = (8. 2) = … (4. 2) = … w=2 MIT EECS 6. 10. 5. Durand and Cutler . 2. 0.

0.0) • Why bother with the extra dimension? Because now translations can be encoded in the matrix! p p' x c x' y' z' 0 1 = 1 0 0 0 0 1 0 0 0 0 1 0 tx ty tz 1 x y z 1 MIT EECS 6. Durand and Cutler . tz) y Translate(c.Translate (tx.837. ty.

Durand and Cutler .s. sz) y Scale(s.Scale (sx.s) p' p q' q x • Isotropic (uniform) scaling: sx = sy = sz x' y' z' 1 sx 0 = 0 0 0 sy 0 0 0 0 sz 0 0 0 0 1 x y z 1 MIT EECS 6. sy.837.

Durand and Cutler .Rotation y ZRotate(θ) p' • About z axis θ z p x x' y' z' 1 = cos θ -sin θ sin θ cos θ 0 0 0 0 0 0 1 0 0 0 0 1 x y z 1 MIT EECS 6.837.

Rotation • About x axis: x' y' z' 1 x' y' z' 1 = 0 0 1 0 cos θ -sin θ 0 sin θ cos θ 0 0 0 cos θ 0 -sin θ 0 0 1 1 0 sin θ 0 cos θ 0 0 0 0 1 0 0 0 1 x y z 1 x y z 1 • About y axis: = MIT EECS 6.837. Durand and Cutler .

θ) θ k x kxkx(1-c)+c kzkx(1-c)-kzs kxkz(1-c)+kys x' kykx(1-c)+kzs kzkx(1-c)+c kykz(1-c)-kxs y' = kzkx(1-c)-kys kzkx(1-c)-kxs kzkz(1-c)+c z' 0 0 0 1 where c = cos θ & s = sin θ MIT EECS 6. a unit vector on an arbitrary axis (Rodrigues Formula) z y Rotate(k. kz). ky.837.Rotation • About (kx. Durand and Cutler 0 0 0 1 x y z 1 .

Outline • • • • • • Assignment 0 Recap Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Change of Orthonormal Basis MIT EECS 6.837. Durand and Cutler .

1) (5.3) (3.How are transforms combined? Scale then Translate (1.837.0) (2. Durand and Cutler .1) (0.2) (0.2) Translate(3.0) Scale(2.1) Use matrix multiplication: p' = T ( S p ) = TS p TS = 1 0 3 0 1 1 0 0 1 2 0 0 0 2 0 0 0 1 = 2 0 3 0 2 1 0 0 1 Caution: matrix multiplication is NOT commutative! MIT EECS 6.

2) (6.4) (1.0) Translate(3.2) (3.2) MIT EECS 6.2) Translate(3.1) (5.1) (4.837. Durand and Cutler .Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (1.2) (0.1) Translate then Scale: p' = S ( T p ) = ST p (8.0) Scale(2.1) (0.1) (0.1) Scale(2.0) (2.3) (3.

Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p TS = 1 0 3 0 1 1 0 0 1 2 0 0 0 2 0 0 0 1 2 0 3 0 2 1 0 0 1 = Translate then Scale: p' = S ( T p ) = ST p ST = 2 0 0 0 2 0 0 0 1 1 0 3 0 1 1 0 0 1 = 2 0 6 0 2 2 0 0 1 MIT EECS 6.837. Durand and Cutler .

Outline • • • • • • Assignment 0 Recap Intro to Transformations Classes of Transformations Representing Transformations Combining Transformations Change of Orthonormal Basis MIT EECS 6. Durand and Cutler .837.

Review of Dot Product b a MIT EECS 6.837. Durand and Cutler .

Durand and Cutler u x .z) v y x p u v u y x • Find: p = (u.Change of Orthonormal Basis • Given: coordinate frames xyz and uvn point p = (x.n) y v p n z MIT EECS 6.837.v.y.

u z n x u y x y z = (x .837. u) u + (y .Change of Orthonormal Basis v y.v u x. n) n (z . n) n (y .v x x. v) v + = (z . u) u + (x . v) v + = (y . Durand and Cutler (x . u) u + (z . v) v + MIT EECS 6.u y v y. n) n .

837. u) u + (y . n) n ] + (z . u) u + (x . u) u + (y . v) v + (x . n) n ] + (y .Change of Orthonormal Basis x y z = (x . v) v + z [ (z . n) n Substitute into equation for p: p = (x. Durand and Cutler (x . n) n (z .y. v) v + MIT EECS 6.z) = x x + y y + z z p = x [ (x . n) n (y . u) u + (x . v) v + y [ (y . u) u + (z . u) u + (z . v) v + = (z . n) n ] . v) v + = (y .

u) ] u + z (z .Change of Orthonormal Basis p = x [ (x . v) ] v + z (z . v) v + z [ (z . u) u + (x . u) + [ x (x . n) + y (y . Durand and Cutler (x . v) + [ x (x . n) n ] + (z . v) v + Rewrite: p = [ x (x . u) + y (y . u) u + (y . v) + y (y . n) + MIT EECS 6. n) ] n . n) n ] z (z . v) v + y [ (y . u) u + (z . n) n ] + (y .837.

u) z (z . v) + y (y . n) + y (y . u) + v = x (x . n) + y (y . v) z (z . Durand and Cutler z (z . v) ] v + z (z .n) = u u + v v + n n Expressed in uvn basis: u = x (x .837. u) + [ x (x . u) + y (y . v) + n = x (x . n) ] n z (z . n) + p = (u.v. n) . u) ] u + z (z . v) + [ x (x . v) + y (y . u) + y (y . n) + MIT EECS 6.Change of Orthonormal Basis p = [ x (x .

u) z (z . u) + y (y . z (z . v) + n = x (x . v) + y (y . n) + y (y .Change of Orthonormal Basis u = x (x . n) MIT EECS 6. u uy = y . u) + v = x (x . v) z (z . u etc.837. n) + In matrix form: u v n ux uy uz = vx vy vz nx ny nz x y z where: ux = x . Durand and Cutler .

Durand and Cutler . u = u . the inverse? xu xv xn x y = yu yv yn zu zv zn z u v n ux = x . x = xu M-1 = MT MIT EECS 6.Change of Orthonormal Basis u v n ux uy uz = vx vy vz nx ny nz x y z = M x y z What's M-1.837.

Durand and Cutler .Next Time: Adding Transformations to the Ray Caster (Assignment 2) MIT EECS 6.837.