400 likes | 601 Vues
CS32310. MATRICES. 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. Example comparison.
E N D
CS32310 MATRICES
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
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?
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
Derivation of Matrix form • Take x, y, zcomponents of the vector scaling formula This leads to (with )
Derivation of Matrix form • Regrouping the component formulae for leads to (with )
Derivation of Matrix form • Recognise the equivalent matrix formulation of (with )
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
Op count of Matrix form • Consider carrying out 3 successive scaling operations in tandem
Op count of Matrix form No gain over vector approach – not this way!
Op count of Matrix form • Consider carrying out 3 successive scaling operations by successive substitution and concatenation:
Op count of Matrix form Back to 35
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
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
Matrix Product • Motivation for product formula • Let Then
Matrix Product Thus where
Matrix Product Thus we can write C = BA where Inner product of row i and column j. Op count: (3,2) in this case.
Matrix Product In general, if C = BA B and A must satisfy a compatibility constraint: No of columns in first factor (row length) = No of rows in second factor (col length)
Matrix Algebra • Vectors and Matrices are branches of Linear Algebra
Matrix Transposition See http://en.wikipedia.org/wiki/Transpose
Linear Mapping property Table 5