CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 11 September 29, 2011 October 8, 2011 College of Computer and Information Science, Northeastern Universit 1
Toda s Topics Linear Algebra Review Matrices Transformations New Linear Algebra Homogeneous Coordinates October 8, 2011 College of Computer and Information Science, Northeastern Universit 2
Matrices b b b c c c c 11 12 13 14 11 12 13 a11 a 12 c21 c22 c23 c 24 A = B b21 b22 b 23 C a21 a = = 22 c31 c32 c33 c34 b31 b32 b33 c41 c42 c43 c44 We use 22, 33, and 44 matrices in computer graphics. We ll start with a review of 2D matrices and transformations. October 8, 2011 College of Computer and Information Science, Northeastern Universit 3
Basic 2D Linear Transforms a11 a12 a11 + a12 a a = a + a 21 22 21 22 a11 a12 1 a11 a11 a12 0 a12 a a 0 = = a a a 1 a 21 22 21 21 22 22 October 8, 2011 College of Computer and Information Science, Northeastern Universit 4
Scale b.5 scale (.5,.5).5 0 0.5 (1, 0) (0.5, 0) = (0, 1) (0, 0.5) October 8, 2011 College of Computer and Information Science, Northeastern Universit 5
Scaling b.5 0.5 0 0 0.5 October 8, 2011 College of Computer and Information Science, Northeastern Universit 6
General Scaling s 0 1 s s = 0 s 0 0 0 0 0 0 s 1 = s October 8, 2011 College of Computer and Information Science, Northeastern Universit 7
General Scaling 1 scale s (, ) s s 0 0 s = s 1 s October 8, 2011 College of Computer and Information Science, Northeastern Universit 8
rot( ϕ) = Rotation cos( ϕ) sin( ϕ) sin( ϕ) cos( ϕ) φ cos(φ) sin(φ) -sin(φ) φ cos(φ) October 8, 2011 College of Computer and Information Science, Northeastern Universit 9
Rotation rot( ϕ) = cos( ϕ) sin( ϕ) sin( ϕ) cos( ϕ) φ October 8, 2011 College of Computer and Information Science, Northeastern Universit 10
Reflection in -ais reflect- = 1 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 11
Reflection in -ais reflect- = 1 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 12
Reflection in -ais reflect- = 1 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 13
Reflection in -ais reflect- = 1 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 14
Shear- shear-( s) = 1 s 0 1 s October 8, 2011 College of Computer and Information Science, Northeastern Universit 15
Shear 1 s 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 16
Shear- shear-( s) = 1 0 s 1 s October 8, 2011 College of Computer and Information Science, Northeastern Universit 17
Shear 1 0 s 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 18
Linear Transformations Scale, Reflection, Rotation, and Shear are all linear transformations The satisf: T(au + bv) = at(u) + bt(v) u and v are vectors a and b are scalars If T is a linear transformation T((0, 0)) = (0, 0) October 8, 2011 College of Computer and Information Science, Northeastern Universit 19
Composing Linear Transformations If T 1 and T 2 are transformations T 2 T 1 (v) = def T 2 ( T 1 (v)) If T 1 and T 2 are linear and are represented b matrices M 1 and M 2 T 2 T 1 is represented b M 2 M 1 T 2 T 1 (v) = T 2 ( T 1 (v)) = (M 2 M 1 )(v) October 8, 2011 College of Computer and Information Science, Northeastern Universit 20
Reflection About an Arbitrar Line (through the origin) October 8, 2011 College of Computer and Information Science, Northeastern Universit 21
Reflection as a Composition October 8, 2011 College of Computer and Information Science, Northeastern Universit 22
Decomposing Linear Transformations An 2D Linear Transformation can be decomposed into the product of a rotation, a scale, and a rotation if the scale can have negative numbers. M = R 1 SR 2 October 8, 2011 College of Computer and Information Science, Northeastern Universit 23
Rotation about an Arbitrar Point φ φ This is not a linear transformation. The origin moves. October 8, 2011 College of Computer and Information Science, Northeastern Universit 24
Translation (, ) (+a,+b) (a, b) This is not a linear transformation. The origin moves. October 8, 2011 College of Computer and Information Science, Northeastern Universit 25
Homogeneous Coordinates Embed the -plane in R 3 at z = 1. (, ) (,, 1) z October 8, 2011 College of Computer and Information Science, Northeastern Universit 26
2D Linear Transformations as 3D Matrices An 2D linear transformation can be represented b a 22 matri a11 a12 a11 + a12 a a = a + a 21 22 21 22 or a 33 matri a11 a12 0 a11 + a12 a a 0 = a + a 21 22 21 22 0 0 1 1 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 27
2D Linear Translations as 3D Matrices An 2D translation can be represented b a 33 matri. 1 0 a + a 0 1 b = + b 0 0 1 1 1 This is a 3D shear that acts as a translation on the plane z = 1. October 8, 2011 College of Computer and Information Science, Northeastern Universit 28
Translation as a Shear z October 8, 2011 College of Computer and Information Science, Northeastern Universit 29
2D Affine Transformations An affine transformation is an transformation that preserves co-linearit (i.e., all points ling on a line initiall still lie on a line after transformation) and ratios of distances (e.g., the midpoint of a line segment remains the midpoint after transformation). With homogeneous coordinates, we can represent all 2D affine transformations as 3D linear transformations. We can then use matri multiplication to transform objects. October 8, 2011 College of Computer and Information Science, Northeastern Universit 30
Rotation about an Arbitrar Point φ φ October 8, 2011 College of Computer and Information Science, Northeastern Universit 31
Rotation about an Arbitrar Point T(c, c ) R(φ) T(-c, -c ) φ φ October 8, 2011 College of Computer and Information Science, Northeastern Universit 32
Windowing Transforms (A,B) (a,b) translate (A-a,B-b) scale (C-c,D-d) (C,D) translate (c,d) October 8, 2011 College of Computer and Information Science, Northeastern Universit 33
3D Transformations Remember: z z 1 A 3D linear transformation can be represented b a 33 matri. a a a a a a 0 11 12 13 11 12 13 a21 a22 a22 0 a21 a22 a 23 a31 a32 a33 0 a31 a32 a33 0 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 34
( s ) s sz scale,, 3D Affine Transformations s 0 0 0 0 s 0 0 = 0 0 sz 0 0 0 0 1 ( t ) t tz translate,, 1 0 0 t 0 1 0 t = 0 0 1 tz 0 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 35
3D Rotations rotate rotate z ( θ ) ( θ ) 1 0 0 0 0 cos( θ ) sin( θ ) 0 = 0 sin( θ ) cos( θ ) 0 0 0 0 1 ( θ ) ( θ ) ( θ ) ( θ ) rotate cos sin 0 0 sin cos 0 0 = 0 0 1 0 0 0 0 1 ( θ ) ( θ ) ( θ ) cos 0 sin 0 0 1 0 0 = sin( θ ) 0 cos( θ ) 0 0 0 0 1 October 8, 2011 College of Computer and Information Science, Northeastern Universit 36