foundations of computer graphics (fall 2012 )
DESCRIPTION
Foundations of Computer Graphics (Fall 2012 ). http://inst.eecs.berkeley.edu/~cs184. CS 184, Lecture 2: Review of Basic Math. To Do. Complete Assignment 0 (a due 29, b due 31) Get help if issues with compiling, programming Textbooks: access to OpenGL references About first few lectures - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/1.jpg)
Foundations of Computer Graphics (Fall 2012)
CS 184, Lecture 2: Review of Basic Mathhttp://inst.eecs.berkeley.edu/~cs184
![Page 2: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/2.jpg)
To Do
Complete Assignment 0 (a due 29, b due 31) Get help if issues with compiling, programming Textbooks: access to OpenGL references 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
![Page 3: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/3.jpg)
Motivation 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 object can be matrix-vector multiply
Should be refresher on very basic material for most of you Only basic high school math required If you don’t understand, talk to me (review in office hours)
![Page 4: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/4.jpg)
Vectors
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.
=
![Page 5: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/5.jpg)
Vector Addition
Geometrically: Parallelogram rule In cartesian coordinates (next), simply add coords
a
ba+b = b+a
![Page 6: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/6.jpg)
Cartesian Coordinates
X and Y can be any (usually orthogonal unit) vectors
X
A = 4 X + 3 Y
![Page 7: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/7.jpg)
Vector Multiplication
Dot product Cross product Orthonormal bases and coordinate frames
Note: Some books talk about right and left-handed coordinate systems. We always use right-handed
![Page 8: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/8.jpg)
Dot (scalar) product
a
b
![Page 9: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/9.jpg)
Dot product in Cartesian components
![Page 10: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/10.jpg)
Dot 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: computed easily in cartesian components
![Page 11: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/11.jpg)
Projections (of b on a)
a
b
![Page 12: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/12.jpg)
Vector Multiplication
Dot product Cross product Orthonormal bases and coordinate frames
Note: Some books talk about right and left-handed coordinate systems. We always use right-handed
![Page 13: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/13.jpg)
Cross (vector) product
Cross product orthogonal to two initial vectors Direction determined by right-hand rule Useful in constructing coordinate systems (later)
a
b
![Page 14: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/14.jpg)
Cross product: Properties
![Page 15: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/15.jpg)
Cross product: Cartesian formula?
Dual matrix of vector a
![Page 16: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/16.jpg)
Vector Multiplication
Dot product Cross product Orthonormal bases and coordinate frames
Note: book talks about right and left-handed coordinate systems. We always use right-handed
![Page 17: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/17.jpg)
Orthonormal bases/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 lectures
![Page 18: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/18.jpg)
Coordinate Frames
Any set of 3 vectors (in 3D) so that
![Page 19: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/19.jpg)
Constructing 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)
![Page 20: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/20.jpg)
Constructing a coordinate frame?
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 u
![Page 21: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/21.jpg)
Matrices
Can be used to transform points (vectors) Translation, rotation, shear, scale
(more detail next lecture)
![Page 22: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/22.jpg)
What is a matrix
Array of numbers (m×n = m rows, n columns)
Addition, multiplication by a scalar simple: element by element
![Page 23: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/23.jpg)
Matrix-matrix multiplication
Number of columns in first must = rows in second
Element (i,j) in product is dot product of row i of first matrix and column j of second matrix
![Page 24: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/24.jpg)
Matrix-matrix multiplication
Number of columns in first must = rows in second
Element (i,j) in product is dot product of row i of first matrix and column j of second matrix
![Page 25: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/25.jpg)
Matrix-matrix multiplication
Number of columns in first must = rows in second
Element (i,j) in product is dot product of row i of first matrix and column j of second matrix
![Page 26: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/26.jpg)
Matrix-matrix multiplication
Number of columns in first must = rows in second
Element (i,j) in product is dot product of row i of first matrix and column j of second matrix
![Page 27: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/27.jpg)
Matrix-matrix multiplication
Number of columns in first must = rows in second
Non-commutative (AB and BA are different in general) Associative and distributive
A(B+C) = AB + AC (A+B)C = AC + BC
![Page 28: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/28.jpg)
Matrix-Vector Multiplication
Key for transforming points (next lecture) Treat vector as a column matrix (m×1)
E.g. 2D reflection about y-axis
![Page 29: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/29.jpg)
Transpose of a Matrix (or vector?)
![Page 30: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/30.jpg)
Identity Matrix and Inverses
![Page 31: Foundations of Computer Graphics (Fall 2012 )](https://reader030.vdocument.in/reader030/viewer/2022033106/56815fb3550346895dceb031/html5/thumbnails/31.jpg)
Vector multiplication in Matrix form Dot product?
Cross product?
Dual matrix of vector a