matrices transformation

44
Matrices Transformation

Upload: karthikesan48

Post on 20-Jul-2016

244 views

Category:

Documents


5 download

DESCRIPTION

yhjghjh

TRANSCRIPT

Page 1: Matrices Transformation

Matrices Transformation

Page 2: Matrices Transformation

Slide number 2

Matrices and transformations

• A coordinate system can be used to uniquely identify points in m-dimensional space as column vectors (m  1 matrices).

• e.g. in 2-dimensional space the points A, B, and C are represented as:

A 11

B 23

C 1 1

AB

C

Page 3: Matrices Transformation

Slide number 3

Multiple points

• The position of n points in space can be characterised by a grouping of n column vectors forming an m  n matrix.

• e.g. in 2-dimensional space the triangle with vertices A, B, and C can be representedby the matrix:

1 2 11 3 1

AB

C

Page 4: Matrices Transformation

Slide number 4

Matrix transformations…

• Matrices can also be used to represent transformations of points.

• e.g. the matrix

will transform A, B, and C to A’, B’, and C’.

2 11 1

AB

CA«

Page 5: Matrices Transformation

Slide number 5

…Matrix transformations…

• i.e.

AB

CA«

A' 2 11 1

11

30

B' 2 11 1

23

15

C' 2 11 1

1 1

30

Page 6: Matrices Transformation

Slide number 6

…Matrix transformations…

• Or, more succinctly in matrix form:

AB

CA«

2 11 1

1 2 11 3 1

3 1 30 5 0

Page 7: Matrices Transformation

Slide number 7

…Matrix transformations…

• Note: the determinant of the transformation matrix gives the scale of the area change.

• e.g. area [A, B, C] = 5, area [A´, B´, C´] = 15

AB

CA«

det 2 11 1

3

Page 8: Matrices Transformation

Slide number 8

…Matrix transformations…

• e.g. transform the shape with vertices

by the matrix

• Note that the determinant gives the scale factor for the change in area

det 1 12 1

3

A 2 1

, B 1

1, C 1

2

, D 2

1

,

1 12 1

Page 9: Matrices Transformation

Slide number 9

…Matrix transformations

• All four vertices can be transformed using a single matrix equation

• Negative determinant reverses the ordering of vertices.

1 12 1

2 1 1 2 1 1 2 1

3 0 3 13 3 0 5

AB

CA«

D

Page 10: Matrices Transformation

Slide number 10

The unit square

• It is instructive to look at the effect of transformations on a simple shape such as the unit square.

• The matrix for the unit square is given by

O P

Q R

O P Q R0 1 0 10 0 1 1

Page 11: Matrices Transformation

Slide number 11

a11 a12a21 a22

O P Q R0 1 0 10 0 1 1

O' P' Q' R' 0 a11 a12 a11 a120 a21 a22 a21 a22

Transforming the unit square

• Transforming the unit square gives information about the transformation matrix

• i.e. transforming the unit square results in [zeros, original matrix, sums of rows]

Page 12: Matrices Transformation

Slide number 12

Transformations: uniform scaling

• The general form of uniform scaling by k is:

• e.g. uniform scaling by 2 is given by

O P

Q R

O« P«

Q« R«

k 00 k

2 00 2

Page 13: Matrices Transformation

Slide number 13

Transformations: scaling

Page 14: Matrices Transformation

Slide number 14

Transformations: scaling

Page 15: Matrices Transformation

Slide number 15

Transformations: stretch…

• The general form of a stretch by k in the x–direction is:

• e.g. x–direction stretch by 2 is given by

k 00 1

2 00 1

O P

Q R

O« P«

Q« R«

Page 16: Matrices Transformation

Slide number 16

…Transformations: stretch

• The general form of a stretch by k in the y–direction is:

• e.g. y–direction stretch by -2 is given by

1 00 k

1 00 2

O P

Q R

O« P«

Q« R«

Page 17: Matrices Transformation

Slide number 17

Transformations: shear…

• The general form of a shear by k in the x–direction is:

• e.g. x–direction shear by 1.5 is given by

1 k0 1

1 1.50 1

O P

Q R

O« P«

Q« R«

Page 18: Matrices Transformation

Slide number 18

…Transformations: shear

• The general form of a shear by k in the y–direction is:

• e.g. y–direction shear by -1 is given by

1 0k 1

1 0 1 1

O P

Q R

O«P«

Q«R«

Page 19: Matrices Transformation

Slide number 19

Transformations: reflection

• The general forms of reflections in the x–axis and y–axis are:

• e.g. an x–axis reflection is given by

1 00 1

and 1 0

0 1

1 00 1

O P

Q R

O« P«Q« R«

Page 20: Matrices Transformation

Slide number 20

Transformations: reflection

The general forms of reflections in the y=x are

0110

Page 21: Matrices Transformation

Slide number 21

Transformations: reflection

• The general forms of reflections in the original point (0,0) are

10

01

Page 22: Matrices Transformation

Slide number 22

Transformations: rotation…

• The general form of a rotation by k about the origin is:

cos k sin k sin k cos k

P«kQ«

cos(k)

sin(k)

kk

–sin(k)

cos(k)

Page 23: Matrices Transformation

Slide number 23

…Transformations: rotation

• e.g. the matrices representing rotations of 90° and –30° are:

cos 90 sin 90 sin 90 cos 90

0 11 0

cos 30 sin 30 sin 30 cos 30

32

12

12

32

Page 24: Matrices Transformation

Slide number 24

Transformation:Rotation

• For rotation by an angle θ anticlockwise about the origin, the functional form is

• x' = xcosθ − ysinθ• y' = xsinθ + ycosθ• The matrix form is:

yx

yx

cossinsincos

''

Page 25: Matrices Transformation

Slide number 25

Transformation:Rotation

• for a rotation clockwise about the origin, the functional form is

• x' = xcosθ + ysinθ • y' = − xsinθ + ycosθ and • the matrix form is

yx

yx

cossinsincos

''

Page 26: Matrices Transformation

Slide number 26

Combined transformations…

• If the matrices A and B represent two transformations, then the matrix product AB represents the combined transformation of first applying B and then applying A.

• i.e. let the matrix U represent the unit square.Then BU represents the transformation B applied to the unit square.Now A(BU) represents the transformation A applied to the unit square transformed by B.This sequence of transformations is the same as the combined transformation (AB) applied to U (matrix multiplication is associative)ABU = A(BU) = (AB)U

Page 27: Matrices Transformation

Slide number 27

…Combined transformations…

• e.g. let the matrices A and B represent x–shear by 1 and y–stretch by 2 transformations

A 1 10 1

, B 1 0

0 2

BU 1 00 2

0 1 0 10 0 1 1

0 1 0 10 0 2 2

A BU 1 10 1

0 1 0 10 0 2 2

0 1 2 30 0 2 2

AB 1 10 1

1 00 2

1 20 2

AB U 1 20 2

0 1 0 10 0 1 1

0 1 2 30 0 2 2

Page 28: Matrices Transformation

Slide number 28

…Combined transformations

• Note that combined transformations are not commutative.i.e. AB ≠ BAe.g.

A 1 10 1

, B 1 0

0 2

AB 1 10 1

1 00 2

1 20 2

, BA 1 0

0 2

1 10 1

1 10 2

ABU 0 1 2 30 0 2 2

, BAU 0 1 1 2

0 0 2 2

Page 29: Matrices Transformation

Slide number 29

Inverse transformations…

• Let A be a transformation, so AU = V represents the transformation A applied to the unit square.

• Now if we premultiply the equation by A-1, the inverse of A, we get A-1AU =  A-1V

• But A-1A = I , so U =  A-1V. In other words A-1

reverses the transformation A.• A-1 (if it exists) is thus the inverse

transformation of A.

Page 30: Matrices Transformation

Slide number 30

…Inverse transformations

• e.g. y–shear by -1 is given by

A 1 0 1 1

AU 1 0 1 1

0 1 0 10 0 1 1

0 1 0 10 1 1 0

A 1AU 1 01 1

0 1 0 10 1 1 0

0 1 0 10 0 1 1

O P

Q R

O«P«

Q«R«

Page 31: Matrices Transformation

Slide number 31

Inverse transformations: singular…

• What if the transformation is singular?e.g.

A 1 2 1 2

, det A 0

AU 1 2 1 2

0 1 0 10 0 1 1

0 1 2 10 1 2 1

O P

Q R

O«P«

Q«R«

Page 32: Matrices Transformation

Slide number 32

…Inverse transformations: singular

• Singular transformations collapses the unit square into a straight line (or a single point).

• Singular transformations cannot be reversed because there isn’t a one-to-one mapping between the original and transformed spaces.

O P

Q R

O«P«

Q«R«

Page 33: Matrices Transformation

Slide number 33

Transition matrices

• Consider a system that can be characterised by a set of m variables, called state variables.

• Furthermore, these state variables are allowed to change value only at discrete time points, called transitions.

• If the system state variables at transition i are linearly related related to the state variables at transition (i – 1) the transition can be described using a transition matrix.

• Examples of such systems include Markov chains, where the transition matrix elements represent probabilities of changing from one state to another.

Page 34: Matrices Transformation

Slide number 34

Transition matrices: example 1…

• e.g. A railway has 600 wagons carrying goods from point A to point B. At the end of each week it finds that 30% of the wagons that started the week at A are at B and 20% of the wagons that have started at B are now at A.1) How many wagons are at A and B at the end of two

weeks if 300 wagons started at A and 300 started at B?

2) If there are 400 wagons at A and 200 at B at the end of a week, how many wagons were there at A and at B at the start of the week?

3) How many wagons would need to be at A and at B at the start of the week if there were to be the same numbers at the end of the week?

Page 35: Matrices Transformation

Slide number 35

…Transition matrices: example 1…

• The transition matrix describes the way the distribution of wagons changes from the start to the end of each week. It does not describe all the changes that may take place during the week.

• Think of the columns of the matrix representing “from” and the rows representing “to”

from A from Bto Ato B

a11 a12a21 a22

Page 36: Matrices Transformation

Slide number 36

…Transition matrices: example 1…

• A railway has 600 wagons carrying goods from point A to point B. At the end of each week it finds that 30% of the wagons that started the week at A are at B and 20% of the wagons that have started at B are now at A.

• Fill in the elements of the matrix remembering that if 0.3 of A's wagons end up at B then 0.7 remain at A (i.e. go from A to A).

from A from Bto Ato B

0.7 0.20.3 0.8

Page 37: Matrices Transformation

Slide number 37

…Transition matrices: example 1…

1) How many wagons are at A and B at the end of two weeks if 300 wagons started at A and 300 started at B?

• Construct a vector representing the numbers of wagons:

• Calculate the numbers of wagons at the end of week 1:

• Calculate the numbers of wagons at the end of week 2:

• i.e. there are 255 wagons at A and 345 at B.

0.7 0.20.3 0.8

300300

270330

at Aat B

300300

0.7 0.20.3 0.8

270330

255345

Page 38: Matrices Transformation

Slide number 38

…Transition matrices: example 1…

2) If there are 400 wagons at A and 200 at B at the end of a week, how many wagons were there at A and at B at the start of the week?

• If the transition matrix represents the forward process, the inverse represents the reverse process.

• Calculate the inverse of the transition matrix:

• Apply the inverse transformation:

• i.e. there were 560 wagons at A and 40 at B.

0.7 0.20.3 0.8

1

1

0.56 0.060.8 0.2 0.3 0.7

1.6 0.4 0.6 1.4

1.6 0.4 0.6 1.4

400200

56040

Page 39: Matrices Transformation

Slide number 39

…Transition matrices: example 1…

3) How many wagons would need to be at A and at B at the start of the week if there were to be the same numbers at the end of the week?

• This is called the steady state problem:

0.7 0.20.3 0.8

xy

I

xy

where I 1 0

0 1

0.7 0.20.3 0.8

xy

I

xy

00

0.7 0.20.3 0.8

I

xy

00

0.3 0.20.3 0.2

xy

00

find xy

such that 0.7 0.2

0.3 0.8

xy

xy

Page 40: Matrices Transformation

Slide number 40

…Transition matrices: example 1…

3) How many wagons would need to be at A and at B at the start of the week if there were to be the same numbers at the end of the week?

• Since the total number of wagons is 600, the steady state distribution is:

0.3 0.20.3 0.2

xy

00

gives xy

23

, or xx y

25

and yx y

35

25600 240 at A

35600 360 at B

Page 41: Matrices Transformation

Slide number 41

…Transition matrices: example 1

3) How many wagons would need to be at A and at B at the start of the week if there were to be the same numbers at the end of the week?

• Check that the answer is the steady state solution:

0.7 0.20.3 0.8

240360

240360

Page 42: Matrices Transformation

Slide number 42

Transition matrices: example 2…

• e.g. A company has 2 warehouses with initial stock 20,000 and 10,000 in warehouse A and B, respectively. At the end of each week 70% of stock in A is sold and 2% transferred to B, while 85% of stock in B is sold and 1% transferred to A. How much stock is left in each warehouse at the end of 2 weeks?

• Construct the transition matrix:

• Note: we need an extra row and column to track movement between A, B, and outside.

from A from B from outto Ato B

to out

0.28 0.01 0.000.02 0.14 0.000.70 0.85 1.00

Page 43: Matrices Transformation

Slide number 43

…Transition matrices: example 2

• How much stock is left in each warehouse at the end of 2 weeks?

• Construct a vector representing the stock:

• Calculate the stock at the end of week 1:

• Calculate the stock at the end of week 2:

0.28 0.01 0.000.02 0.14 0.000.70 0.85 1.00

20,00010,000

0

5, 7001,800

22,500

at Aat B

at out

20,00010,000

0

0.28 0.01 0.000.02 0.14 0.000.70 0.85 1.00

5, 7001,800

22,500

1,614366

28,020

Page 44: Matrices Transformation

Slide number 44

Matrices lecture objectives

• After this lecture you should have a clear understanding of:• Representing sets of points in matrix form;• What the unit square is;• Performing and classifying matrix transformations;• Performing combined matrix transformations;• The effect of an inverse matrix;• The relationship between the the determinant of a

transformation and the change in area of a shape;• The effect of a transformation using a singular matrix.