CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to...

40
CS32310 MATRICES 1

Transcript of CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to...

Page 1: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

1

CS32310

MATRICES

Page 2: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

2

Vector vs Matrix transformation formulae

• Geometric reasoning allowed us to derive vector expressions for the various transformation formulae

• For efficiency reasons, the transformation formulae are usually executed in matrix form

Page 3: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

3

Example comparison

• Consider the scaling formula, for scaling the component of vector r in the ŝ direction:

• What is the operation count for executing this formula?

Page 4: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

4

Page 5: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

5

• The operation count (mults,adds) = (7,6) is for the transformation of one vector.

• 3 sequential scalings (in directions ŝ1, ŝ2, ŝ3 for factors α1, α2, α3) for 1000 points Cost: 3000(7,6) = 39000 operations.

• Slightly reduced cost by evaluating (α-1)ŝ once for each scaling operations (cost: 3(3,1)), and reusing these results of every point. Resulting cost:

3(3,1) + 3000(6,5) = 33012 operations

Page 6: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

6

Derivation of Matrix form

• Take x, y, z components of the vector scaling formula

This leads to (with )

Page 7: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

7

Derivation of Matrix form

• Regrouping the component formulae for

leads to (with )

Page 8: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

8

Derivation of Matrix form

• Recognise the equivalent matrix formulation of

(with )

Page 9: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

9

Derivation of Matrix form

Page 10: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

10

Page 11: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

11

Op count of Matrix form

• Cost of setting up the matrix– (10,3) for the scaling matrix

• Cost of doing one matrix multiplication A r– 3(3,2) = (9,6) – 3 elements of a 3 x 1 matrix to be computed– Same operations as for the written out form

Page 12: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

12

Op count of Matrix form

• Consider carrying out 3 successive scaling operations in tandem

Page 13: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

13

Page 14: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

14

Op count of Matrix form

No gain over vector approach – not this way!

Page 15: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

15

Op count of Matrix form

• Consider carrying out 3 successive scaling operations

by successive substitution and concatenation:

Page 16: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

16

Page 17: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

17

Op count of Matrix form

Page 18: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

18

Op count of Matrix formBack to 35

Page 19: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

19

Op count of Matrix form

• Each of the formulae is linear and homogeneous in the vector r

• Each follows the pattern

• can be expressed in matrix form

Page 20: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

20

Op count of Matrix form

• or

• Details of the operation (in A) are separated from the details of the point being transformed (operand r)

• Abstraction!• Concatenation possible

Page 21: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

21

Matrix Product

• Motivation for product formula• Let

Then

Page 22: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

22

Matrix Product

Thus

where

Page 23: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

23

Matrix Product

Thus we can write C = BA

where

Inner product of row i and column j.Op count: (3,2) in this case.

Page 24: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

24

Page 25: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

25

Matrix Product

In general, if C = BAB and A must satisfy a compatibility constraint: No of columns in first factor (row length)

= No of rows in second factor (col

length)

Page 26: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

26

Page 27: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

27

Matrix Algebra

• Vectors and Matrices are branches of Linear Algebra

Page 28: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

28

Page 29: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

29

Page 30: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

30

Page 31: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

31

Matrix Transposition

See http://en.wikipedia.org/wiki/Transpose

Page 32: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

32

Matrix Transposition Examples

Page 33: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

33

Matrix block multiplication

Page 34: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

34

Matrix block multiplication

Page 35: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

35

Linear Mapping propertyTable 5

Page 36: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

36

Derivation of Matrix form II

Page 37: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

37

Page 38: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

38

Page 39: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

39

Page 40: CS32310 MATRICES 1. Vector vs Matrix transformation formulae Geometric reasoning allowed us to derive vector expressions for the various transformation.

40

Summary