1
play

1 Vector Multiplication Dot (scalar) product Vector Multiplication - PDF document

To Do To Do Foundations of Computer Graphics Foundations of Computer Graphics Complete Assignment 0 (a due 26, b due 31) (Spring 2012) (Spring 2012) Get help if issues with compiling, programming CS 184, Lecture 2: Review of Basic Math


  1. To Do To Do Foundations of Computer Graphics Foundations of Computer Graphics  Complete Assignment 0 (a due 26, b due 31) (Spring 2012) (Spring 2012)  Get help if issues with compiling, programming CS 184, Lecture 2: Review of Basic Math  Textbooks: access to OpenGL references http://inst.eecs.berkeley.edu/~cs184  About first few lectures  Somewhat technical: core math ideas in graphics  HW1 is simple (only few lines of code): Lets you see how to use some ideas discussed in lecture, create images Motivation and Outline Vectors Motivation and Outline Vectors  Many graphics concepts need basic math like linear algebra  Vectors (dot products, cross products, …) =  Matrices (matrix-matrix, matrix-vector mult., …)  E.g: a point is a vector, and an operation like translating or rotating points on object can be matrix-vector multiply  Length and direction. Absolute position not important    Chapters 2.4 (vectors) and 5.2 (matrices) Usually written as or in bold. Magnitude written as a a  Worthwhile to read all of chapters 2 and 5  Use to store offsets, displacements, locations  Should be refresher on very basic material for most of you  But strictly speaking, positions are not vectors and cannot be added:  If you don’t understand, talk to me (review in office hours) a location implicitly involves an origin, while an offset does not. Vector Addition Vector Addition Cartesian Coordinates Cartesian Coordinates A = 4 X + 3 Y a+b = b+a b a X  Geometrically: Parallelogram rule  X and Y can be any (usually orthogonal unit ) vectors  In cartesian coordinates (next), simply add coords   x       T 2 2 A   A x y A x y   y 1

  2. Vector Multiplication Dot (scalar) product Vector Multiplication Dot (scalar) product b  Dot product (2.4.3)  Cross product (2.4.4)   Orthonormal bases and coordinate frames (2.4.5,6) a        a b b a ? a b a b cos         a b ( c ) a b a c   Note: book talks about right and left-handed a b    1   cos   coordinate systems. We always use right-handed      ( ka b ) a kb ( ) k a b ( ) a b   Projections (of b on a) Dot product: some applications in CG Dot product: some applications in CG Projections (of b on a) b  Find angle between two vectors (e.g. cosine of angle between light source and surface for shading)   Finding projection of one vector on another (e.g. a coordinates of point in arbitrary coordinate system)  a b     b a b cos   b a ?  Advantage: computed easily in cartesian components a   b a ?  a a b     b a b a a 2 a a Dot product in Cartesian components Vector Multiplication Vector Multiplication Dot product in Cartesian components  Dot product (2.4.3)     x x     a b a b     ?  Cross product (2.4.4)  y   y  a b  Orthonormal bases and coordinate frames (2.4.5,6)     x x      a b a b     x x y y a b a b  y   y  a b  Note: book talks about right and left-handed coordinate systems. We always use right-handed 2

  3. Cross (vector) product Cross product: Properties Cross (vector) product Cross product: Properties     a b b a       a b a b sin x y z        a b b a y x z b      a a 0 y z x           a ( b c ) a b a c z y x       a ( kb ) k a ( b ) z x y a     Cross product orthogonal to two initial vectors x z y  Direction determined by right-hand rule  Useful in constructing coordinate systems (later) Vector Multiplication Cross product: Cartesian formula? Cross product: Cartesian formula? Vector Multiplication  Dot product (2.4.3)    x y z y z y z a b b a    Cross product (2.4.4)     a b x y z z x x z   a a a a b a b    Orthonormal bases and coordinate frames (2.4.5,6)  x y z  x y y x  b b b a b a b     0 z y x a a b        * a b A b z 0 x y     Note: book talks about right and left-handed a a b     y x 0 z    coordinate systems. We always use right-handed a a b Dual matrix of vector a Orthonormal bases/coordinate frames bases/coordinate frames Coordinate Frames Coordinate Frames Orthonormal  Important for representing points, positions, locations  Any set of 3 vectors (in 3D) so that    u v w 1  Often, many sets of coordinate systems (not just X, Y, Z)     Global, local, world, model, parts of model (head, hands, …)    u v v w u w 0   w u v  Critical issue is transforming between these systems/bases  Topic of next 3 lectures       p ( p u u ) ( p v v ) ( p w w ) 3

  4. Constructing a coordinate frame Constructing a coordinate frame? Constructing a coordinate frame Constructing a coordinate frame?  Often, given a vector a (viewing direction in HW1), want to We want to associate w with a , and v with b  But a and b are neither orthogonal nor unit norm construct an orthonormal basis  And we also need to find u  Need a second vector b (up direction of camera in HW1) a   Construct an orthonormal basis (for instance, camera w a coordinate frame to transform world objects into in HW1)  b w  u  b w   v w u Matrices What is a matrix Matrices What is a matrix  Can be used to transform points (vectors)  Array of numbers (m × n = m rows, n columns)  Translation, rotation, shear, scale (more detail next lecture)   1 3    Section 5.2.1 and 5.2.2 of text 5 2    Instructive to read all of 5 but not that relevant to course    0 4   Addition, multiplication by a scalar simple: element by element Matrix Matrix- -matrix multiplication matrix multiplication Matrix- Matrix -matrix multiplication matrix multiplication  Number of columns in first must = rows in second  Number of columns in first must = rows in second   1 3     1 3 9 2 7 3 3 13    3 6 9 4       3 6 9 4  5 2    5 2   19 44 61 26     2 7 8 3     2 7 8 3       0 4      0 4 8 28 3 2 1 2  Element (i,j) in product is dot product of row i of first  Element (i,j) in product is dot product of row i of first matrix and column j of second matrix matrix and column j of second matrix 4

  5. Matrix- -matrix multiplication matrix multiplication Matrix- -matrix multiplication matrix multiplication Matrix Matrix  Number of columns in first must = rows in second  Number of columns in first must = rows in second         1 3 9 2 7 3 3 13 1 3 9 2 7 3 3 13             3 6 9 4 3 6 9 4       5 2 19 44 61 26 5 2 19 44 61 26               2 7 8 3     2 7 8 3    0 4   8 28 3 2 1 2   0 4   8 28 3 2 1 2   Element (i,j) in product is dot product of row i of first  Element (i,j) in product is dot product of row i of first matrix and column j of second matrix matrix and column j of second matrix Matrix- -matrix multiplication matrix multiplication Matrix- -Vector Multiplication Vector Multiplication Matrix Matrix  Number of columns in first must = rows in second  Key for transforming points (next lecture)  Treat vector as a column matrix (m × 1)   1 3    3 6 9 4   5 2 NOT EVEN LEGAL!!    2 7 8 3   0 4   E.g. 2D reflection about y-axis (from textbook)  Non-commutative (AB and BA are different in general)        1 0 x x        Associative and distributive      0 1 y y  A(B+C) = AB + AC  (A+B)C = AC + BC Transpose of a Matrix (or vector?) Transpose of a Matrix (or vector?) Identity Matrix and Inverses Identity Matrix and Inverses   T 1 0 0   1 2       1 3 5   3 4      I  0 1 0  2 4 6     3 3  5 6     0 0 1   ) T T T ( AB B A     1 1 AA A A I     1 1 1 ( AB ) B A 5

  6. Vector multiplication in Matrix form Vector multiplication in Matrix form  Dot product?   T a b a b   x b          x y z y x x y y z z   a a a b a b a b a b   z   b  Cross product?     0 z y x a a b        * a b A b z 0 x y    a a b      y x 0  z  a a b Dual matrix of vector a 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend