Linear and affine transformations Linear Algebra Review Matrices Transformations Affine transformations in Euclidean space 1 The linear transformation given b a matri Let A be an mn matri. The function T defined b T( v) Av is a linear transformation from R n into R m. Note: n m R vector R vector a11 a12 a1n v1 a11v1 a12v2 a1nvn a21 a22 a 2n v 2 a21v1 a22v2 a2nv n Av a a a v a v a v a v m1 m2 mn n m1 1 m2 2 mn n T( v) Av T : R n R m 6-2 1
Two representations of the linear transformation T:R 3 R 3 : ( 1) T( 1, 2, 3) (21 2 3, 1 32 23,32 43) 2 (2) T( ) A 1 0 1 3 3 11 2 2 4 3 Three reasons for matri representation of a linear transformation: It is simpler to write. It is simpler to read. It is more easil adapted for computer use. Geometric transformations Geometric transformations map points in one space to points in another: (',',z') = f(,,z), i.e. in vector form X = f(x) These transformations can be ver simple, such as scaling each coordinate, or comple, such as non-linear twists and bends. We'll focus on transformations that can be represented easil with matri operations. We'll start in 2D... 2
Representation of 2D linear map We can represent a 2-D transformation M b a matri M a b c d If is a column vector, M goes on the left: ' M a b c d If is a row vector, M T goes on the right: M We will use column vectors. a c b d T Basic 2D Linear Transforms Base vectors map to columns of matri. M a b a b M c d c d ' M a b c d a b 1 a a b 0 b c d 0 c c d 1 d (1, 0) 6 3
Scaling b 0.5 M M 0.5 0 0 0.5 November 7, 2016 7 General Scaling scale( s, s ) 1 scale s, s s 0 0 s s 1 s November 7, 2016 8 4
Rotation rot( ) cos sin rot sin cos November 7, 2016 9 Reflection in -ais ref ref 1 0 0 1 November 7, 2016 10 5
Reflection in -ais ref ref 1 0 0 1 November 7, 2016 11 Shear- M 1 s 0 1 November 7, 2016 12 6
Shear- M 1 0 s 1 November 7, 2016 13 Composing Linear Transformations If T 1 and T 2 are transformations T1( v) M1v T T 2 T 1 (v) = def T 2 ( T 1 (v)) 2( v) M2 v If T 1 and T 2 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) Order is important! reflect() (rot(o,α)): A A A rot(o,α) (reflect()): A A A A' Rot A A'' Ref A' 14 7
Composing Linear Transformations Order is important! reflect() (rot(o,α)): A A A rot(o,α) (reflect()): A A A A' Rot A A'' Ref A' cos sin 1 0 Rot ; Ref sin cos 0 1 cos sin Rot*Ref sin cos cos sin Ref*Rot sin cos 15 Decomposing Linear Transformations An 2D Linear Transformation can be decomposed into the product of a rotation, a scale (or line reflection), and a rotation M = R 1 SR 2. An 2D Linear Transformation can be decomposed into the product of 3 line reflection at the most. Isometr (congruent transformation) Isometr preserves length, whereas direct isometr preserves orientation and opposite does not preserve orientation Direct Isometr R = 1 (Rotation) Opposite Isometr R = -1 (Line Reflection) November 7, 2016 16 8
Reflection About an Arbitrar Line (through the origin) November 7, 2016 17 Reflection as a Composition -1 F ref F new base B = B = B -1-1 B = ref B B B B = B ref B -1 B B B F e1, e2 f 1,f 2 f 1 f 2 9
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) Q: What important operation does that leave out? 19 Rotation about an Arbitrar Point This is not a linear transformation. The origin moves. November 7, 2016 20 10
Translation (, )(+a,+b) (a, b) This is not a linear transformation. The origin moves. November 7, 2016 21 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 November 7, 2016 22 11
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 With homogeneous coordinates, we can represent all 2D affine transformations as 3D linear transformations. We can then use matri multiplication to transform objects. 23 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). 24 12
T(c, c ) R() T(-c, -c ) Rotation about an Arbitrar Point November 7, 2016 25 Windowing Transforms (A,B) (a,b) translate (A-a,B-b) scale (C-c,D-d) (C,D) translate (c,d) November 7, 2016 26 13
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 November 7, 2016 27 3D Affine Transformations scale s, s, s z s 0 0 0 0 s 0 0 0 0 sz 0 0 0 0 1 translate t, t, t z 1 0 0 t 0 1 0 t 0 0 1 tz 0 0 0 1 28 14
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 29 15