CY-FAIR I.S.D. Donna Lynn Glover, COMS K.C. Crager, COMS Amy Tange, COMS Chuck Holcomb, COMS
Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.
-
date post
22-Dec-2015 -
Category
Documents
-
view
216 -
download
1
Transcript of Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.
![Page 1: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/1.jpg)
Computer Graphics (Fall 2005)Computer Graphics (Fall 2005)
COMS 4160, Lecture 2: Review of Basic Math
http://www.cs.columbia.edu/~cs4160
![Page 2: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/2.jpg)
To 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 images
![Page 3: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/3.jpg)
Motivation 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)
![Page 4: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/4.jpg)
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 a a
![Page 5: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/5.jpg)
Vector AdditionVector Addition
Geometrically: Parallelogram rule
In cartesian coordinates (next), simply add coords
a
ba+b = b+a
![Page 6: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/6.jpg)
Cartesian CoordinatesCartesian Coordinates
X and Y can be any (usually orthogonal unit) vectors
X
A = 4 X + 3 Y
2 2 TxA A x y A x y
y
![Page 7: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/7.jpg)
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-handed
![Page 8: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/8.jpg)
Dot (scalar) productDot (scalar) product
a
b
?a b b a
1
cos
cos
a b a b
a b
a b
( )
( ) ( ) ( )
a b c a b a c
ka b a kb k a b
![Page 9: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/9.jpg)
Dot 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 components
![Page 10: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/10.jpg)
Projections (of b on a)Projections (of b on a)
a
b
?
?
b a
b a
cosa b
b a ba
2
a a bb a b a a
a a
![Page 11: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/11.jpg)
Dot product in Cartesian componentsDot product in Cartesian components
?a b
a b
x xa b
y y
a ba b a b
a b
x xa b x x y y
y y
![Page 12: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/12.jpg)
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-handed
![Page 13: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/13.jpg)
Cross (vector) productCross (vector) product
Cross product orthogonal to two initial vectors
Direction determined by right-hand rule
Useful in constructing coordinate systems (later)
a
b
a b b a
sina b a b
![Page 14: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/14.jpg)
Cross product: PropertiesCross product: Properties
0
( )
( ) ( )
a b b a
a a
a b c a b a c
a kb k a b
x y z
y x z
y z x
z y x
z x y
x z y
![Page 15: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/15.jpg)
Cross product: Cartesian formula?Cross product: Cartesian formula?
a b b a
a a a a b a b
b b b a b a b
x y z y z y z
a b x y z z x x z
x y z x y y x
*
0
0
0
a a b
a a b
a a b
z y x
a b A b z x y
y x z
Dual matrix of vector a
![Page 16: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/16.jpg)
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-handed
![Page 17: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/17.jpg)
Orthonormal bases/coordinate framesOrthonormal 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: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/18.jpg)
Coordinate FramesCoordinate Frames
Any set of 3 vectors (in 3D) so that
1
0
( ) ( ) ( )
u v w
u v v w u w
w u v
p p u u p v v p w w
![Page 19: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/19.jpg)
Constructing 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)
![Page 20: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/20.jpg)
Constructing a coordinate frame?Constructing a coordinate frame?
aw
a
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
b wu
b w
v w u
![Page 21: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/21.jpg)
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 course
![Page 22: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/22.jpg)
What is a matrixWhat is a matrix
Array of numbers (m×n = m rows, n columns)
Addition, multiplication by a scalar simple: element by element
1 3
5 2
0 4
![Page 23: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/23.jpg)
Matrix-matrix multiplicationMatrix-matrix 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 matrix
1 33 6 9 4
5 22 7 8 3
0 4
![Page 24: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/24.jpg)
Matrix-matrix multiplicationMatrix-matrix 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 matrix
9 21 3 7 3
5 2
0 4
1339
618
3
319
28 2
426
3
644
17
28 2
![Page 25: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/25.jpg)
Matrix-matrix multiplicationMatrix-matrix 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 matrix
9 21 3 7 3
5 2
0 4
1339
618
3
319
28 2
426
3
644
17
28 2
![Page 26: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/26.jpg)
Matrix-matrix multiplicationMatrix-matrix 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 matrix
9 21 3 7 3
5 2
0 4
1339
618
3
319
28 2
426
3
644
17
28 2
![Page 27: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/27.jpg)
Matrix-matrix multiplicationMatrix-matrix multiplication
Number of columns in second must = rows in first
Non-commutative (AB and BA are different in general)
Associative and distributive A(B+C) = AB + AC (A+B)C = AC + BC
1 33 6 9 4
5 2 NOT EVEN LEGAL!!2 7 8 3
0 4
![Page 28: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/28.jpg)
Matrix-Vector MultiplicationMatrix-Vector Multiplication
Key for transforming points (next lecture)
Treat vector as a column matrix (m×1)
E.g. 2D reflection about y-axis (from textbook)
1 0
0 1
x x
y y
![Page 29: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/29.jpg)
Transpose of a Matrix (or vector?)Transpose of a Matrix (or vector?)
1 21 3 5
3 42 4 6
5 6
T
( )T T TAB B A
![Page 30: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/30.jpg)
Identity Matrix and InversesIdentity Matrix and Inverses
1 1
1 1 1( )
AA A A I
AB B A
3 3
1 0 0
0 1 0
0 0 1
I
![Page 31: Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math cs4160.](https://reader034.fdocuments.in/reader034/viewer/2022051516/56649d7f5503460f94a63082/html5/thumbnails/31.jpg)
Vector multiplication in Matrix formVector multiplication in Matrix form
Dot product?
Cross product?
T
b
a a a b a b a b a b
b
a b a b
x
x y z y x x y y z z
z
*
0
0
0
a a b
a a b
a a b
z y x
a b A b z x y
y x z
Dual matrix of vector a