linear transformations - loyola university marylandmath.loyola.edu › ~chidyagp › sp20 › slides...

31
Linear Transformations Linear Transformations 1 / 21

Upload: others

Post on 31-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations

Linear Transformations 1 / 21

Page 2: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations

A function T from Rn → Rm is called a linear transformation if thereexists an m × n matrix A such that

T (~x) = A~x

for all ~x ∈ Rn satisfying the following:

T (~v + ~w) = T (~v) + T (~w), ∀~v , ~w ∈ Rn

T (c~v) = cT (~v), ∀~v ∈ Rn, c ∈ R

Linear transformations preserve lines, unlike nonlinear transformations thatmay transform a line segment into a parabolic curve, or ellipse

Linear Transformations 2 / 21

Page 3: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations

A function T from Rn → Rm is called a linear transformation if thereexists an m × n matrix A such that

T (~x) = A~x

for all ~x ∈ Rn satisfying the following:

T (~v + ~w) = T (~v) + T (~w), ∀~v , ~w ∈ Rn

T (c~v) = cT (~v), ∀~v ∈ Rn, c ∈ R

Linear transformations preserve lines, unlike nonlinear transformations thatmay transform a line segment into a parabolic curve, or ellipse

Linear Transformations 2 / 21

Page 4: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations

A function T from Rn → Rm is called a linear transformation if thereexists an m × n matrix A such that

T (~x) = A~x

for all ~x ∈ Rn satisfying the following:

T (~v + ~w) = T (~v) + T (~w), ∀~v , ~w ∈ Rn

T (c~v) = cT (~v), ∀~v ∈ Rn, c ∈ R

Linear transformations preserve lines, unlike nonlinear transformations thatmay transform a line segment into a parabolic curve, or ellipse

Linear Transformations 2 / 21

Page 5: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations in 2D

We focus on T from R2 → R2

A is a 2× 2 matrix and ~v is a 2× 1 column vector.

Special examples of linear transformations include:1 scaling transformations2 rotations3 translations

Linear Transformations 3 / 21

Page 6: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations in 2D

We focus on T from R2 → R2

A is a 2× 2 matrix and ~v is a 2× 1 column vector.

Special examples of linear transformations include:1 scaling transformations2 rotations3 translations

Linear Transformations 3 / 21

Page 7: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Linear Transformations in 2D

We focus on T from R2 → R2

A is a 2× 2 matrix and ~v is a 2× 1 column vector.

Special examples of linear transformations include:1 scaling transformations2 rotations3 translations

Linear Transformations 3 / 21

Page 8: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Scaling Transformations

T : R2 → R2 defined by T (~v) = c~v for c ∈ (0,∞)

c > 1 - dilation by a factor of c

c < 1 - contraction by a factor of c

In matrix form

T([

xy

])=

[c 00 c

] [xy

]=

[cxcy

]

Linear Transformations 4 / 21

Page 9: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Scaling Transformations

-10 -8 -6 -4 -2 0 2 4 6 8 10

-10

-8

-6

-4

-2

0

2

4

6

8

10Scaling

Linear Transformations 5 / 21

Page 10: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Rotations

Rotations by an angle θ about the origin where the rotation is measuredfrom the positive x-axis in an anticlockwise direction

In matrix form, the linear transformation can be represented as:

T([

xy

])=

[cos θ − sin θsin θ cos θ

] [xy

]

Linear Transformations 6 / 21

Page 11: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Reflections

Reflections about a line L through the origin, e.g.

Reflecting a point in R2 about the y -axis:

T([

xy

])=

[−xy

]in matrix form

T([

xy

])=

[−1 00 1

] [xy

]In general, the transformation corresponding to a reflection about theline L making an angle θ with the positive x − axis is given by

A =

[cos 2θ sin 2θsin 2θ − cos 2θ

]=

[a bb −a

], a2 + b2 = 1

Linear Transformations 7 / 21

Page 12: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Reflections

Reflections about a line L through the origin, e.g.

Reflecting a point in R2 about the y -axis:

T([

xy

])=

[−xy

]in matrix form

T([

xy

])=

[−1 00 1

] [xy

]

In general, the transformation corresponding to a reflection about theline L making an angle θ with the positive x − axis is given by

A =

[cos 2θ sin 2θsin 2θ − cos 2θ

]=

[a bb −a

], a2 + b2 = 1

Linear Transformations 7 / 21

Page 13: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Reflections

Reflections about a line L through the origin, e.g.

Reflecting a point in R2 about the y -axis:

T([

xy

])=

[−xy

]in matrix form

T([

xy

])=

[−1 00 1

] [xy

]In general, the transformation corresponding to a reflection about theline L making an angle θ with the positive x − axis is given by

A =

[cos 2θ sin 2θsin 2θ − cos 2θ

]=

[a bb −a

], a2 + b2 = 1

Linear Transformations 7 / 21

Page 14: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Reflection

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3

Linear Transformations 8 / 21

Page 15: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Shear

y -shear

T =

[1 0a 1

]x-shear

T =

[1 b0 1

]

Linear Transformations 9 / 21

Page 16: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

x-shear

T =

[1 2.50 1

]

-10 -5 0 5 10

-10

-8

-6

-4

-2

0

2

4

6

8

10Shear

Linear Transformations 10 / 21

Page 17: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Compositions of transformations

Given two linear transformations T and S both R2 → R2 with

T (~v) = A~v and S(~v) = B~v ∀~v ∈ R2

then the composition of the transformation T and S , T ◦ S AB(T ◦ S

)(~v) = T

(S(~v

))= T

(B~v

)= AB~v

Linear Transformations 11 / 21

Page 18: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Compositions of transformations

Rotation θ = π8 then reflection about y = 0, then dilation by a factor of 2.

-6 -4 -2 0 2 4 6

-6

-4

-2

0

2

4

6

Linear Transformations 12 / 21

Page 19: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Orthogonal transformations

A linear transformation T : Rn → Rn is called orthogonal if itpreserves the length of vectors:

||T (~v)|| = ||~v ||, ∀~v ∈ Rn

If T (~v) = A~v is an orthogonal transformation, A is an orthogonalmatrix

1 ||A~v || = ||~v ||, ∀~v ∈ Rn

2 The columns of A form an orthonormal basis of Rn

3 ATA = I n4 A−1 = AT

Orthogonal transformations also preserve dot products of vectors andthus angles are preserved

Linear Transformations 13 / 21

Page 20: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Orthogonal transformations

A linear transformation T : Rn → Rn is called orthogonal if itpreserves the length of vectors:

||T (~v)|| = ||~v ||, ∀~v ∈ Rn

If T (~v) = A~v is an orthogonal transformation, A is an orthogonalmatrix

1 ||A~v || = ||~v ||, ∀~v ∈ Rn

2 The columns of A form an orthonormal basis of Rn

3 ATA = I n4 A−1 = AT

Orthogonal transformations also preserve dot products of vectors andthus angles are preserved

Linear Transformations 13 / 21

Page 21: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Orthogonal transformations

A linear transformation T : Rn → Rn is called orthogonal if itpreserves the length of vectors:

||T (~v)|| = ||~v ||, ∀~v ∈ Rn

If T (~v) = A~v is an orthogonal transformation, A is an orthogonalmatrix

1 ||A~v || = ||~v ||, ∀~v ∈ Rn

2 The columns of A form an orthonormal basis of Rn

3 ATA = I n4 A−1 = AT

Orthogonal transformations also preserve dot products of vectors andthus angles are preserved

Linear Transformations 13 / 21

Page 22: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Random Orthogonal transformations

T= orth(rand(2,2))

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3Orthorgonal Transformation

Linear Transformations 14 / 21

Page 23: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Random Transformation

M =

[0.8212 0.04300.0154 0.1690

]

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3Random Transformation

Can this transformation be undone?

Yes! det(M)= 0.1381

Linear Transformations 15 / 21

Page 24: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Random Transformation

M =

[0.8212 0.04300.0154 0.1690

]

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3Random Transformation

Can this transformation be undone?Yes! det(M)= 0.1381

Linear Transformations 15 / 21

Page 25: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Random non-invertible Transformation

M =

[0.9884 0.34090.0000 0.0000

]

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3Random Singular Transformation

Linear Transformations 16 / 21

Page 26: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Affine transformations

These are mappings of the form

T (~v) = A~v + ~b

i.e. affine transformations are composed of a linear transformation (A~v)then shifted in the direction ~b

Affine transformations preserve collinearity and ratios of distances.

Translations, dilations, contractions,reflections and rotations are allexamples of affine transformations.

Linear Transformations 17 / 21

Page 27: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Affine transformations

These are mappings of the form

T (~v) = A~v + ~b

i.e. affine transformations are composed of a linear transformation (A~v)then shifted in the direction ~b

Affine transformations preserve collinearity and ratios of distances.

Translations, dilations, contractions,reflections and rotations are allexamples of affine transformations.

Linear Transformations 17 / 21

Page 28: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Affine transformations

T =

[12 00 −1

2

]+

[34

]

-6 -4 -2 0 2 4 6

-6

-4

-2

0

2

4

6Affine Transformations

Linear Transformations 18 / 21

Page 29: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Affine transformations and fractals

Consider four different linear transformations on points ~v = (x , y) starting at

(0, 0) and one linear transformation performed randomly with different

probabilities85% of the time:

T 1 = A1~v + ~b1 =

[0.85 0.04−0.04 0.85

]~v +

[0

1.6

]7% of the time:

T 2 = A2~v + ~b2 =

[0.20 −0.260.23 0.22

]~v +

[0

1.6

]7% of the time:

T 3 = A3~v + ~b3 =

[−0.15 0.280.26 0.24

]~v +

[0

0.44

]1% of the time:

T 4 = A4~v =

[0 00 0.16

]~v

Linear Transformations 19 / 21

Page 30: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Exercise: Affine transformations and fractals -Implementation notes

Use randsample(4,1,true,[0.85 0.07 0.07 0.01]) to generaterandom integers with weights

Starting with the origin apply a transformation based on the outcomefrom randsample, (a switch statement may be useful here).

plot each point after applying the transformation - use drawnow tovisualize the points as they are computed.

Linear Transformations 20 / 21

Page 31: Linear Transformations - Loyola University Marylandmath.loyola.edu › ~chidyagp › sp20 › slides › linear_transformations.pdf · Linear transformations preserve lines, unlike

Affine transformations and fractals

Linear Transformations 21 / 21