Transformations
Specifying Complex Scenes (x,y,z) (r x,r y,r z ) 2 (,,)
Specifying Complex Scenes Absolute position is not very natural Need a way to describe relative relationship: The lego is on top of the roof, which is above the house Work locally for every object and then combine 3
Transformations Transforming an object = transforming all its points For a polygon = transforming its vertices 4
Scaling vector in plane Scaling operator with parameters :, 5 (,) (s x,s y )=(.7,.7) (s x,s y )=(.7, 1.) (s x,s y )=(3., 1.5)
Scaling Matrix Form, Independent in and Non uniform scaling is allowed 6
Rotation W v x V (,) = -45 o = -135 o (,) r v y Polar form: cos sin Rotate V anti clockwise by to W: cos sin cos sin sin cos 7
Rotation Matrix form: Rotation operator with parameter : 8
Rotation Properties cos sin sin cos is orthogonal Rotation by is 9
Translation (t x,t y )=(., 1.) (t x,t y )=(1.,.) (t x,t y )=(1.5,.3) Translation operator with parameters :, Can we express in a matrix form? 1
Homogeneous Coordinates in Points of the form Where we identify For all nonzero 11
Conversion Formulae From Euclidean to homogeneous From homogeneous to Euclidean 12
Example In homogeneous coordinates 13
Translation using Homogeneous Coordinates, 14
Matrix Form Why bother writing transformations in matrix form? 15
Transformation Composition What operation rotates by around? Translate to origin Rotate around origin by Translate back P P 16
Transformation Composition performs one transformation performs a second transformation performs the composed transformation 17
Transformation Composition,, 18
Transformation Quiz What do these Euclidean transformations do? 19
Transformation Quiz And these homogeneous ones? 2
Transformation Quiz Can one rotate in the plane by reflection? How can one reflect through an arbitrary line in the plane? 21
Arbitrary Reflection Shift by Rotate by Reflect through Rotate by Shift by,,, 22
Rotate by Shear Shear Rotation by composition of 3 shears 23
Rotate by Shear cos sin sin cos 1 1 Solve for,, : cos 1 sin Solution: sin When is this useful? tan 2 24
Rotate by Shear Can we rotate with two (scaled) shears? What happens for? 25
Rotation Approximation For small angles we have: cos 1 and sin (Taylor expansion of sin/cos) Can approximate: Examples (steps of ): 26
3D Transformations All 2D transformations extend to 3D In homogeneous coordinates:,,,,, 1 1 1 1 1 cos sin sin cos 1 1 What is?? 27
3D Transformations Questions (commutativity): Scaling: Is S 1 S 2 = S 2 S 1? Translation: Is T 1 T 2 = T 2 T 1? Rotation: Is R 1 R 2 = R 2 R 1? 28
3D Coordinate Systems left right 29
Example: Arbitrary Rotation Y Z W V X U Problem: Given two orthonormal coordinate systems XYZ and UVW, find a transformation from one to the other. 3
Arbitrary Rotation Answer: Transformation matrix R whose columns are U, V, W: Proof: Similarly R(Y) = V and R(Z) = W 31
Arbitrary Rotation (cont.) Inverse (=transpose) transformation, R -1, provides mapping from UVW to XYZ E.g. X u u u w v u w v u w v u u u u U R z y x z z z y y y x x x z y x (1,,),,) ( ),, ( ) ( 2 2 2 1 32
Line Objects Line through two points in parametric form: 1 1. 1 1,.5 1 /2,.5, 1 1 1, 1 Ray:, Segment:,1 1 Intuitively: Coordinates of trajectory of particle at time. 33
Viewing Transformations Screen space View space projectors z Object space Question: How can we view (draw) 3D objects on a 2D screen? Answer: Project the transformed object along Z axis onto XY plane and from there to screen (space) Canonical projection: 1 1 1 In practice ignore the z axis simply use the x and y coordinates for screen coordinates 34
35 Parallel Projection
Projectors are all parallel Parallel Projection Orthographic: Projectors perpendicular to projection plane Axonometric: Rotation + translation + orthographic projection 36
37 Pinhole Camera Model
Perspective Projection Viewing is from point at a finite distance Without loss of generality: Viewpoint at origin Viewing plane is Given similarity gives: triangle X center of projection projectors projection plane x 2 p z = d x 1 p= x 3 p p 2 p 3 p 1 = (x 1, y 1, z 1 ) Z x z x d p and y z y d p x p z x / d and y p z y / d 38
Perspective Projection (cont d) In homogeneous coordinates: In Euclidean coordinates: P not injective & singular: det.,,, 1/ 1 1 1,1),, (,1),, ( d z z y x d z y x z y x P ).,, (, /, / /, /, / d y x d d z y d z x d z z d z y d z x p p 39
4
41 original
Scale Dolly 42
Perspective Projection What is the difference between: Moving the projection plane Moving the viewpoint (center of projection) Z y y Scale y Dolly Z Z z z z 43
Examples Orthographic view Perspective view 44
Perspective Warp Matrix formulation d z d d z y x d d d d d z y x, ) (,, 1 1 1,1),, ( z d z d d z y d z x z y x p p p 2, /, / ),, ( 45
2 2 d ( z) d f( z) 1 ( d ) z d z f(z) d 2 /(d-α) d monotonic increasing in z preserves z ordering α d z 1 z 2 z 46
47 Perspective Warp
Quiz Which transformation preserves which geometric form? lines parallel lines distance angles normals convexity conics scaling rotation translation shear perspective 48
49
5 3D Sidewalk Art by Julian Beever
51
52
53
54
55
56
57
58
59