To Do To Do Computer Graphics (Fall 2004) Computer Graphics (Fall 2004) � Complete Assignment 0; e - m a il by tomorrow � Download and compile skeleton for assignment 1 COMS 4160, Lecture 2: Review of Basic Math � Read instructions re setting up your system � Ask TA if any problems, need visual C++ etc. http://www.cs.columbia.edu/~cs4160 � We won’t answer compilation issues after next lecture � Are there logistical problems with getting textbooks, programming (using MRL lab etc.?), office hours? � About first few lectures � Somewhat technical: core mathematical 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 Motivation and Outline Vectors 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 an object can be a matrix-vector multiply � Length and direction. Absolute position not important � Much more, but beyond scope of this course (e.g. 4162) � � Usually written as or in bold. Magnitude written as a a � Chapters 2.4 (vectors) and 4.2.1,4.2.2 (matrices) � Worthwhile to read all of chapters 2 and 4 � Use to store offsets, displacements, locations � But strictly speaking, positions are not vectors and cannot be added: a � Should be refresher on very basic material for most of you location implicitly involves an origin, while an offset does not. � If not understand, talk to me (review in office hours) 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
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 i a b cos a b i b a i ? + = + a b i ( c ) a b i a c i a b i � Note: book talks about right and left - h anded − φ = 1 cos coordinate systems. We always use right - h anded = = ( ka b ) i a kb i ( ) k a b ( i ) a b Dot product: some applications in CG Projections (of b on a) Projections (of b on a) Dot product: some applications in CG b � Find angle between two vectors (e.g. cosine of angle between light source and surface for shading) φ a � Finding projection of one vector on another (e.g. coordinates of point in arbitrary coordinate system) a b i → = φ = b a b cos → = b a ? a � Advantage: can be computed easily in cartesian components → = b a ? a a b i → = → = b a b a a 2 a a Vector Multiplication Vector Multiplication Dot product in Cartesian components 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 - h anded coordinate systems. We always use right - h anded
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 × = − x z y � Cross product orthogonal to two initial vectors � Direction determined by right - h and rule � Useful in constructing coordinate systems (later) Cross product: Cartesian formula? Vector Multiplication Vector Multiplication Cross product: Cartesian formula? � 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 - h anded a a b − y x 0 z coordinate systems. We always use right - h anded a a b Dual matrix of vector a Coordinate Frames Coordinate Frames Orthonormal bases/coordinate frames Orthonormal bases/coordinate frames � 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 i v w i u w i 0 = × w u v � Critical issue is transforming between these systems/bases � Topic of next 3 lectures = + + p ( p u u i ) ( p v v i ) ( p w w i )
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 = w � Construct an orthonormal basis (for instance, camera a coordinate frame to transform world objects into in HW1) × b w = u × b w = × v w u Matrices Matrices What is a matrix 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 4.2.1 and 4.2.2 of text � Instructive to read all of 4 but not that relevant to course 5 2 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 second must = rows in first � Number of columns in second must = rows in first 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
Matrix- -matrix multiplication matrix multiplication Matrix- -matrix multiplication matrix multiplication Matrix Matrix � Number of columns in second must = rows in first � Number of columns in second must = rows in first 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 -matrix multiplication matrix multiplication Matrix Matrix- -Vector Multiplication Vector Multiplication � Number of columns in second must = rows in first � 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 - a xis (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 1 0 0 T 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
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
Recommend
More recommend