Transformations I CS5600Computer Graphics by Rich Riesenfeld 27 February 2002 Lecture Set 5
CS Transformations and Matrices Transformations are functions Matrices are functions representations Matrices represent linear transf’s
CS What is a 2D Linear Transf ? Recall from Linear Algebra:
CS Example: Scale in x
CS Example: Scale in x by 2 What is the graphical view?
CS Scale in x by 2
CS5600 7
8
9
10 Summary on Scale “Scale then add,” is same as “Add then scale”
CS Matrix Representation Scale in x by 2:
CS Matrix Representation Scale in y by 2:
CS Matrix Representation Overall Scale by 2:
CS Matrix Representation Showing Same
CS What about Rotation? Is it linear?
CS Rotate by
CS Rotate by : 1 st Quadrant
CS Rotate by : 1 st Quadrant
CS Rotate by : 2 nd Quadrant
CS Rotate by : 2 nd Quadrant
CS Rotate by : 2 nd Quadrant
CS Summary of Rotation by
CS Summary (Column Form)
CS Using Matrix Notation (Note that unit vectors simply copy columns)
CS General Rotation by Matrix
CS Who had linear algebra? Who understand matrices?
CS What do the off diagonal elements do?
CS Off Diagonal Elements
CS Example 1 S
CS Example 1 S
CS Example 1 T(S)
CS Example 2 S
CS Example 2 S
CS Example 2 T(S)
CS Summary Shear in x: Shear in y:
CS Double Shear
CS Sample Points: unit inverses
CS Geometric View of Shear in x
Another Geometric View of Shear in x 39
Another Geometric View of Shear in x 40
CS Geometric View of Shear in y
Another Geometric View of Shear in y h h 42
Another Geometric View of Shear in y 43
CS “Lazy 1”
CS Translation in x
CS Translation in x
CS Homogeneous Coordinates
CS Homogeneous Coordinates
CS Homogeneous Coordinates Homogeneous term effects overall scaling
Homogeneous Coordinates An infinite number of points correspond to (x,y,1). They constitute the whole line (tx,ty,t). w = 1 (tx,ty,t) (x,y,1)
CS We’ve got Affine Transformations Linear + Translation
CS Compound Transformations Build up compound transformations by concatenating elementary ones Use for complicated motion Use for complicated modeling
CS Elementary Transformations Scale Rotate Translate Shear (Reflect)
CS Refection about y-axis
CS Reflection about y-axis
CS Reflection about x-axis
CS Reflection about x-axis
Is Reflection “Elementary?” Can we effect reflection in an elementary way? (More elementary means scale, shear, rotation, translation.) 58
CS Reflection is Scale (-1)
CS Example:Move clock hands
CS Example:Move clock hands
CS Example:Move clock hands
CS Example:Move clock hands
CS Clock Transformations Translate to Origin Move hand with rotation Move hand back to clock Do other hand
CS Clock Transformations
CS Clock Transformations
CS Map [a,b] [0,1] 0 [ ] ab 1
CS Map [a,b] [0,1] Translate to Origin Map x to translated interval
CS Map [a,b] [0,1] Normalize the interval Map x to normalized interval
CS Map [a,b] [0,1]
CS Just Look at This is a homogeneous form for 1D
CS Map [a,b] [-1,1] 0 [ ] +1 a b
CS Map [a,b] [-1,1] Translate center of interval to origin Normalize interval to [-1,1]
CS Map [a,b] [-1,1] Substitute x =a (analogous for x =b) : x
CS Now Map [a,b] [c,d] First map [a,b] to [0,1] –(We already did this) Then map [0,1] to [c,d]
CS Now Map [a,b] [c,d] Scale [0,1] by (d-c) Then translate by c That is, in 1D homogeneous form:
CS All Together: [a,b] [c,d]
CS Now Map Rectangles
CS Transformation in x and y
This is the Viewport Transformation Good for mapping objects from one coordinate system to another This is what we do with windows and viewports 80
CS D Transformations Scale Rotate Translate Shear
CS D Scale in x
CS D Scale in x
CS D Scale in y
CS D Scale in z
CS Overall 3D Scale
CS Overall 3D Scale Same in x,y and z:
What is a Positive Rotation in 3D ? Sit at end of given axis Look at Origin CC Rotation is in Positive direction 88
3D Positive Rotations
CS D Rotation about z-axis by We have already done this:
CS D Rotation about x-axis by
CS D Rotation about x-axis
3D Rotation about y-axis by 93
CS D Rotation about y-axis
CS Elementary Transformations Scale Rotate Translate Shear (Reflect)
CS Consider an arbitrary 3D rotation What is its inverse? What is its transpose? Can we constructively elucidate this relationship?
Want to rotate by about arbitrary axis a 97
CS First rotate about by Now in the (y-z)-plane
CS Then rotate about by Rotate in the (y-z)-plane
Now perform rotation about - Now aligned with z-axis 100
Now perform rotation about - Now aligned with z-axis 101
CS Then rotate about by Rotate again in the (y-z)-plane
CS Then rotate about by Now to original position of a
We effected a rotation by about arbitrary axis a 104
We effected a rotation by about arbitrary axis a 105
CS Rotation about an arbitrary axis Rotation about a-axis can be effected by a composition of 5 elementary rotations We show arbitrary rotation as succession of 5 rotations about principal axes
CS In matrix terms,
CS Similarly, so,
CS Recall, Consequently, for because,
CS It follows directly that,
CS
CS Constructively, we have shown, This will be useful later
CS D Translation in x
CS D Translation in y
CS D Translation in z
CS D Shear in x -direction
CS D Shear in x -direction
CS D Shears:clamp a principal plane, shear in other 2 DoFs
CS D Shear in y -direction
CS D Shear in y -direction
CS D Shear in z -direction
CS D Shear in z
CS D Shear in z
CS What is “Perspective?” A mechanism for portraying 3D in 2D “True Perspective” corresponds to projection onto a plane “True Perspective” corresponds to an ideal camera image
Many Kinds of Perspective Used Mechanical Engineering Cartography Art
CS Perspective in Art Naïve (wrong) Egyptian Cubist (unrealistic) Esher –Impossible (exploits local property) –Hyperpolic (non-planar) –etc
CS “True” Perspective in 2D (x,y) p h
CS “True” Perspective in 2D
CS “True” Perspective in 2D This is right answer for screen projection
CS “True” Perspective in 2D
End Transformations I Lecture Set 5 133