Vector Algebra Transformations Lecture 4 Cornell CS4620 Fall 2008 Lecture 4 2008 Steve Marschner 1
Geometry A part of mathematics concerned with questions of size, shape, and relative positions of figures Coordinates are used to represent points and vectors a naming scheme The same point can be described by different coordinates Points vectors (60,-40) Coordinates [KAIST] 2
3
Geometry Linear Algebra Scalar Vector Linear independence Linear transformations Frames (=Coordinates) Points Vectors Affine transformations Translation Rotation 4
y z [a b c]t v x 5
6
t denotes transpose 7
Transforming geometry Move a subset of the space (in 2D case, plane) using a mapping from the plane to itself 2008 Steve Marschner 8
Linear transformations One way to define a transformation is by matrix multiplication: Such transformations are linear, which is to say: (and in fact all linear transformations can be written this way) 2008 Steve Marschner 9
What is a Matrix? A matrix is a set of elements, organized into rows and columns rows columns a b c d
Matrix operating on vectors Matrix is like a function that transforms the vectors on a plane Matrix operating on a general point => transforms x and y components System of linear equations: matrix is just the bunch of coefficients x = ax + by y = cx + dy a b x x' c d y y'
Bases & Orthonormal Bases Basis vectors (or axes): frame of reference Any point in a space is a linear combination of the basis vectors Usually, orthonormal matrices are used for defining coordinate frames Ortho Normal: orthogonal + normal [Orthogonal: dot product is zero Normal: magnitude is one ] x 1 0 0 T y 0 1 0 z 0 0 1 T T x y 0 x z 0 y z 0
Geometry of 2D linear trans. 2x2 matrices have simple geometric interpretations uniform scale non-uniform scale rotation shear reflection 2008 Steve Marschner 13
Linear transformation gallery Uniform scale 2008 Steve Marschner 14
Linear transformation gallery Nonuniform scale 2008 Steve Marschner 15
Linear transformation gallery Rotation 2008 Steve Marschner 16
Matrices: Scaling, Rotation, Identity Scaling without rotation => diagonal matrix Rotation without stretching => orthonormal matrix O Identity ( do nothing ) matrix = unit scaling, no rotation r1 0 0 r2 [0,1]T scaling [0,r2]T [r1,0]t [1,0]T cos -sin sin cos [0,1]T rotation [1,0]T [-sin, cos ]T [cos, sin ]T
Linear transformation gallery Reflection can consider it a special case of nonuniform scale 2008 Steve Marschner 18
Linear transformation gallery Shear 2008 Steve Marschner 19
Composing transformations Want to move an object, then move it some more We need to represent S o T ( S compose T ) and would like to use the same representation as for S and T 2008 Steve Marschner 20
Composing transformations Composing linear transformations is straightforward Transforming first by MT then by MS is the same as transforming by MSMT only sometimes commutative e.g. 2D rotations & uniform scales e.g. non-uniform scales w/o rotation Note MSMT, or S o T, is T first, then S 2008 Steve Marschner 21
Translation P t P P ' ( x t x, y t y ) P t ty y P t P x tx
Composing translations Composing translations is easy Translation by ut then by us is translation by ut + us commutative! 2008 Steve Marschner 23
Is translation linear transformation? Translation is the simplest transformation: Inverse: 2008 Steve Marschner 24
Is translation linear transformation? No! because T(v)= I v + u!= I v Affine transformation T(v)=Mv + u 2008 Steve Marschner 25
Affine transformations straight lines preserved; parallel lines preserved ratios of lengths along lines preserved (midpoints preserved) Origin 2008 Steve Marschner 26
Combining linear with translation Need to use both in single framework Can represent arbitrary seq. as e. g. Transforming by MT and ut, then by MS and us, is the same as transforming by MSMT and MsuT+ us This will work but is a little awkward 2008 Steve Marschner 27
Homogeneous coordinates A trick for representing the foregoing more elegantly Extra component w for vectors, extra row/column for matrices for affine, can always keep w = 1 Represent linear transformations with dummy extra row and column 2008 Steve Marschner 28
Homogeneous coordinates Represent translation using the extra column 2008 Steve Marschner 29
Homogeneous coordinates Composition just works, by 3x3 matrix multiplication This is exactly the same result but cleaner and generalizes in useful ways as we ll see later 2008 Steve Marschner 30
Homogeneous coordinates in 3D (Affine transformation) ( v 1x v 2x v 3x o x c 1 v x c +o x v 1y v 2y v 3y o y c 2 v y c+o y V c +o = = 1 v 1z v 2z v 3z o z c 3 v z c+o z 0 0 0 1 1 1 )( ) ( ) transformation coordinates ( ) 31
32
Coordinates : 33
34
35
2D Affine transformation gallery Translation 2008 Steve Marschner 36
Affine transformation gallery Uniform scale 2008 Steve Marschner 37
Affine transformation gallery Nonuniform scale 2008 Steve Marschner 38
Affine transformation gallery Rotation 2008 Steve Marschner 39
Affine transformation gallery Reflection can consider it a special case of nonuniform scale 2008 Steve Marschner 40
Affine transformation gallery Shear 2008 Steve Marschner 41
Composite affine transformations In general not commutative: order matters! rotate, then translate translate, then rotate 2008 Steve Marschner 42
Composite affine transformations Another example scale, then rotate rotate, then scale 2008 Steve Marschner 43
Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 2008 Steve Marschner 44
Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 2008 Steve Marschner 45
Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 2008 Steve Marschner 46
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 47
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 48
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 49
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 50
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 51
Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 2008 Steve Marschner 52
More math background Coordinate systems Expressing vectors with respect to bases Linear transformations as changes of basis 2008 Steve Marschner 53
Affine change of coordinates Six degrees of freedom or 2008 Steve Marschner 54
Affine change of coordinates A new way to read off the matrix e.g. shear from earlier can look at picture, see effect on basis vectors, write down matrix Also an easy way to construct transforms e. g. scale by 2 across direction (1,2) 2008 Steve Marschner 55
Rigid motions (Proper Euclidean space) A transform made up of only translation and rotation is a rigid motion or a rigid body transformation The linear part is an orthonormal matrix Inverse of orthonormal matrix is transpose so inverse of rigid motion is easy: 2008 Steve Marschner 56
Transforming points and vectors Recall distinction points vs. vectors vectors are just offsets (differences between points) points have a location represented by vector offset from a fixed origin Points and vectors transform differently points respond to translation; vectors do not 2008 Steve Marschner 57
Transforming points and vectors Homogeneous coords. let us exclude translation just put 0 rather than 1 in the last place and note that subtracting two points cancels the extra coordinate, resulting in a vector! 2008 Steve Marschner 58
59
60
61
Note that = 62
63
64
65
66
67
68
Vectors: Cross Product The cross product of vectors A and B is a vector C which is perpendicular to A and B The magnitude of C is proportional to the sin of the angle between A and B The direction of C follows the right hand rule if we are working in a right-handed coordinate system A B B A A B A B sin( )
MAGNITUDE OF THE CROSS PRODUCT
DIRECTION OF THE CROSS PRODUCT The right hand rule determines the direction of the cross product
72
73
74