1Computer Graphics (Fall 2005)Computer Graphics (Fall 2005)COMS 4160, Lecture 2: Review of Basic Mathhttp://www.cs.columbia.edu/~cs4160To DoTo Do Complete Assignment 0; e-mail by tomorrow Download and compile skeleton for assignment 1 Read instructions re setting up your system Ask TA if any problems, need visual C++ etc. 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 imagesMotivation and OutlineMotivation and Outline 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 Much more, but beyond scope of this course (e.g. 4162) Chapters 2.4 (vectors) and 5.2.1,5.2.2 (matrices) Worthwhile to read all of chapters 2 and 5 Should be refresher on very basic material for most of you If not understand, talk to me (review in office hours)VectorsVectors Length and direction. Absolute position not important Use to store offsets, displacements, locations But strictly speaking, positions are not vectors and cannot be added: a location implicitly involves an origin, while an offset does not.=Usually written as or in bold. Magnitude written as aaVector AdditionVector Addition Geometrically: Parallelogram rule In cartesian coordinates (next), simply add coordsaba+b= b+aCartesian CoordinatesCartesian Coordinates X and Y can be any (usually orthogonal unit) vectorsXA = 4 X +3Y()22 TxAAxyAxyy===+2Vector MultiplicationVector Multiplication Dot product (2.4.3) Cross product (2.4.4) Orthonormal bases and coordinate frames (2.4.5,6) Note: book talks about right and left-handed coordinate systems. We always use right-handedDot (scalar) productDot (scalar) productabφ?ab ba==ii1coscosab a bababφφ−==ii()() () ( )ab c ab acka b a kb k a b+=+==iiiii iDot product: some applications in CGDot product: some applications in CG 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. coordinates of point in arbitrary coordinate system) Advantage: can be computed easily in cartesian componentsProjections (of b on a)Projections (of b on a)abφ??baba→=→=cosabba baφ→= =i2aabbaba aaa→= → =iDot product in Cartesian componentsDot product in Cartesian components?ababxxabyy•= • =abab ababxxab xx yyyy•= • = +Vector MultiplicationVector Multiplication Dot product (2.4.3) Cross product (2.4.4) Orthonormal bases and coordinate frames (2.4.5,6) Note: book talks about right and left-handed coordinate systems. We always use right-handed3Cross (vector) productCross (vector) product Cross product orthogonal to two initial vectors Direction determined by right-hand rule Useful in constructing coordinate systems (later)abφab ba×=−×sinab abφ×=Cross product: PropertiesCross product: Properties0()() ( )ab baaaabc abacakb kab×=−××=×+=×+××=×xyzyx zyz xzy xzx yxzy×=+×=−×=+×=−×=+×=−Cross product: Cartesian formula?Cross product: Cartesian formula?ab baaaa ababbbb ababxyz yzyzab x y z zx xzxyz xyyx−×= = −−*000aa baabaa bzy xab Ab z x yyx z−×= = −−Dual matrix of vector aVector MultiplicationVector Multiplication Dot product (2.4.3) Cross product (2.4.4) Orthonormal bases and coordinate frames (2.4.5,6) Note: book talks about right and left-handed coordinate systems. We always use right-handedOrthonormalOrthonormalbases/coordinate framesbases/coordinate frames Important for representing points, positions, locations Often, many sets of coordinate systems (not just X, Y, Z) Global, local, world, model, parts of model (head, hands, …) Critical issue is transforming between these systems/bases Topic of next 3 lecturesCoordinate FramesCoordinate Frames Any set of 3 vectors (in 3D) so that 10()()( )uvwuv vw uwwuvppuu pvv pww== =====×=++ii iiii4Constructing a coordinate frameConstructing a coordinate frame Often, given a vector a (viewing direction in HW1), want to construct an orthonormal basis Need a second vector b (up direction of camera in HW1) Construct an orthonormal basis (for instance, camera coordinate frame to transform world objects into in HW1)Constructing a coordinate frame?Constructing a coordinate frame?awa=We want to associate w with a, and v with b But a and b are neither orthogonal nor unit norm And we also need to find ubwubw×=×vwu=×MatricesMatrices Can be used to transform points (vectors) Translation, rotation, shear, scale (more detail next lecture) Section 5.2.1 and 5.2.2 of text Instructive to read all of 5 but not that relevant to courseWhat is a matrixWhat is a matrix Array of numbers (m×n = m rows, n columns) Addition, multiplication by a scalar simple: element by element135204MatrixMatrix--matrix multiplicationmatrix multiplication Number of columns in second must = rows in first Element (i,j) in product is dot product of row i of first matrix and column j of second matrix13369452278304MatrixMatrix--matrix multiplicationmatrix multiplication Number of columns in second must = rows in first Element (i,j) in product is dot product of row i of first matrix and column j of second matrix9 213 7 352041339618331928 242636441728 2 = 5MatrixMatrix--matrix multiplicationmatrix multiplication Number of columns in second must = rows in first Element (i,j) in product is dot product of row i of first matrix and column j of second matrix9 213 7 352041339618331928 242636441728 2 = MatrixMatrix--matrix
View Full Document