1. Trang chủ
  2. » Mẫu Slide

matrix math

20 107 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 20
Dung lượng 150,5 KB

Nội dung

Matrix Math ©Anthony Steed 1999 Overview ■ To revise • Vectors • Matrices ■ New stuff • Homogenous co-ordinates • 3D transformations as matrices Vectors and Matrices ■ Matrix is an array of numbers with dimensions M (rows) by N (columns) • by matrix • element 2,3 is (3) ■ Vector can be considered a x M matrix  0 − − 2  1 −1  −5 0    • v = ( x y z) Types of Matrix ■ Identity matrices - I 1 0  ■ 0  Diagonal 1 0 0 0  0 1 0 0 0  0 −1 0 0 ■ 0 0 0 0 −  0 0 0  Symmetric a b c  b d e  c e f    • Diagonal matrices are (of course) symmetric • Identity matrices are (of course) diagonal Anthony AnthonySteed: Steed: EQ EQneeds needsfixing fixing Operation on Matrices ■ Addition • Done elementwise a b   p q a + p b + q  + =  c d   r s   c + r d + s ■ Transpose • “Flip” (M by N becomes N by M) T 1 9 1 6  8 =  7  3  3     Operations on Matrices ■ Multiplication • Only possible to multiply of dimensions – x1 by y1 and x2 by y2 iff y1 = x2 • resulting matrix is x1 by y2 – e.g Matrix A is by and Matrix by by • resulting matrix is by – Just because A x B is possible doesn’t mean B x A is possible! Matrix Multiplication Order ■ ■ A is n by k , B is k by m C = A x B defined by k ■ c = ∑a b BxA ijnot necessarily equal il ljto AxB l =1 *   * * * * *  *   *     * *    *   =              * * * * *          * * * * *    *      =             * * * * *       * * * * *      * =           Example Multiplications 1   1 − 1 =    − 1           −  0     −  0  =   − − 1        Inverse ■ If A x B = I and B x A = I then A = B-1 and B = A-1 Anthony AnthonySteed: Steed: EQ EQneeds needsfixing fixing 3D Transforms ■ In 3-space vectors are transformed by by matrices a b c  ( x y z )  d e f  = ( xa + yd + zg xb + ye + zf xc + yf + zi ) g h i  ■ Example? 10 Scale ■ ■ Scale uses a diagonal matrix  a 0  b  = ( xa yb zc ) ( ) x y z Scale by along x and -2 along z 0 c   2 0  ( 5)   = ( − 10)  0 − 2 11 Rotation ■ Rotation about z axis Y  cos(θ ) sin(θ )   - sin(θ ) cos(θ )    0 1 ■  Note z values remain the same whilst x and y change ( cos( θ ) x - sin ( θ ) y θ sin ( θ ) x + cos( θ ) y ) ( x y) X 12 Rotation X, Y and Scale ■ About X 1 0   cos(θ ) - sin(θ )    sin( θ ) cos( θ )   ■ About Y ■ Scale (should look familiar)  a 0  b 0 0 c    cos(θ ) - sin(θ )     sin(θ ) cos(θ )    13 Homogenous Points ■ ■ Add 1D, but constrain that to be equal to (x,y,z,1) Homogeneity means that any point in 3-space can be represented by an infinite variety of homogenous 4D points • (2 1) = (4 2) = (3 4.5 1.5) ■ Why? • 4D allows as to include 3D translation in matrix form 14 Homogenous Vectors ■ Vectors != Points ■ Remember points can not be added ■ If A and B are points A-B is a vector ■ Vectors have form (x y z 0) ■ Addition makes sense 15 Translation in Homogenous Form ■  0 0  0 ( x y z 1)  0  = ( x + a y + b z + c 1) Note that the homogenous is preserved (* * * 1), and aside from the translation  a component   b c 1 the matrix is I 16 Putting it Together ■ ■  R1 R  R R5  R R8 R is rotation and scale components T T2  T is translation component R3 R6 R9 T3 0 0 0  1 17 Order Matters ■ Composition order of transforms matters • Remember that basic vectors change so “direction” of translations changed 1  ( X Y Z 1)  00 0  1  ( X Y Z 1)  00 2  0 0 0 −1 0   0   0   0   0 0 −1 0 0 0 1  = ( X Z − Y 1)  0 0 2   0 0  = ( X + Z + − Y + 1) 0  0 1  = ( X + Y + Z + 1)  0  −1 0 0   −1 0  = ( X + Z + − Y − 1) 0  18 Exercises ■ Show that rotation byΠ/2 about X and then Π/2 about Y is equivalent to Π/2 about Y then Π/2 about X ■ Calculate the following matrix Π/2 about X then Π/2 about Y then Π/2 about Z (remember “then” means multiply on the right) What is a simpler form of this matrix? ■ Compose the following matrix translate along X, rotate Π/2 about Y, translate -2 along X Draw a figure with a few points (you will only need 2D) and then its translation under this transformation 19 Summary ■ Rotation, Scale, Translation ■ Composition of transforms ■ The homogenous form 20 [...]... that rotation byΠ/2 about X and then Π/2 about Y is equivalent to Π/2 about Y then Π/2 about X ■ Calculate the following matrix Π/2 about X then Π/2 about Y then Π/2 about Z (remember “then” means multiply on the right) What is a simpler form of this matrix? ■ Compose the following matrix translate 2 along X, rotate Π/2 about Y, translate -2 along X Draw a figure with a few points (you will only need... in matrix form 14 Homogenous Vectors ■ Vectors != Points ■ Remember points can not be added ■ If A and B are points A-B is a vector ■ Vectors have form (x y z 0) ■ Addition makes sense 15 Translation in Homogenous Form ■  1 0 0 0  0 1 0 0 ( x y z 1)  0 0 1 0  = ( x + a y + b z + c 1) Note that the homogenous is preserved (* * * 1), and aside from the translation  a component   b c 1 the matrix. ..Scale ■ ■ Scale uses a diagonal matrix  a 0 0  0 b 0  = ( xa yb zc ) ( ) x y z Scale by 2 along x and -2 along z 0 0 c   2 0 0  ( 3 4 5)  0 1 0  = ( 6 4 − 10)  0 0 − 2 11 Rotation ■ Rotation about z axis Y  cos(θ ) sin(θ

Ngày đăng: 30/11/2016, 22:50

Xem thêm

w