1 / 50

Lecture 03: Linear Algebra

Lecture 03: Linear Algebra. COMP 175: Computer Graphics January 28, 2014. Linear Algebra for 3D Graphics. Linear Algebra that you should know… 3D Coordinate Geometry 3D Points and Vectors dot products and cross products Vector and Matrix notations and algebra

Download Presentation

Lecture 03: Linear Algebra

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 03:Linear Algebra COMP 175: Computer Graphics January 28, 2014

  2. Linear Algebra for 3D Graphics • Linear Algebra that you should know… • 3D Coordinate Geometry • 3D Points and Vectors • dot products and cross products • Vector and Matrix notations and algebra • Properties of matrix multiplication (associative property, but NOT communicative property) • Associative => (5 + 2) + 1 = 5 + (2 + 1) • Commutative => 5 +2 + 1 = 1 + 2 + 5 • Matrix operations (multiplication, transpose, inverse, etc.)

  3. Y -1 5 5 -1 R2 4 -2 4 -2 3 3 -3 -3 R 1 X 2 -4 2 -4 1 1 -5 -5 -5 -5 -4 -4 -3 -3 -5 -4 -3 -2 -2 -1 -1 0 -2 -1 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 Y R 3 5 1 2 4 3 3 4 2 5 1 Z 1024 1024 5 1 2 3 4 5 1 2 3 4 Cartesian Coordinate System • 1D, 2D, and 3D real coordinate spaces • Compare this with positive integer coordinate spaces “normal” coordinate axes computer screen axes 1024 … 1024 0 … … … 0

  4. Y Point at (2, 3) -1 5 5 -1 R2 4 4 -2 -2 3 3 -3 -3 X 2 2 -4 -4 1 1 -5 -5 -5 -4 -3 -5 -4 -3 -2 -1 -2 -1 1 1 2 2 3 3 4 4 5 5 Y R 3 Point at (4, -2, 3) Z Points • Denotes a location in the Cartesian coordinate system

  5. Vectors • Denotes: • Magnitude • Direction • NO POSITION!! • In , a vector can be defined as an ordered d-tuple: • A vector is often written as for clarity

  6. Vectors • Because a vector has no position, one way to think of a 2D vector is as an “offset from the origin”. • Such offset can be translated (moved around)

  7. Vectors - Length • Find the length of the following vector:

  8. Vectors - Length • the Euclidean length of a 2D vector is: • The length of a -dimensional vector is: • Question: Can you prove it? • Note that the length of a vector is sometimes called the “norm” of the vector

  9. Vectors – Scalar Multiple • For a vector , the vector can be multiplied by a scalar value such that the resulting vector is: • Question: what happens when is negative?

  10. Vectors – Scalar Multiple • Examples of scalar multiples of the vector • These vectors are said to be parallel to the vector . • Question: What happens if ?

  11. Vectors – Unit Vector • If I don’t care about magnitude of the vector – that is, all I care about is the direction, I can represent the vector such that: • This vector is said to be a “unit vector” (often denoted as , called v-hat), and the process of making a vector be of length = 1 is called “normalization”.

  12. Vectors – Unit Vector • Question: Given a vector , how do you find ? • Question: Can every vector be normalized?

  13. 5 5 10 10 9 9 4 4 8 8 3 3 2 7 2 7 1 1 6 6 1 1 2 2 3 3 5 5 4 4 6 6 7 7 8 8 9 9 10 10 v + u v v u u Vectors - Addition • Addition of vectors is commutative (and associative).

  14. 5 5 10 10 9 9 4 4 8 8 3 3 2 7 2 7 1 1 6 6 1 1 2 2 3 3 5 5 4 4 6 6 7 7 8 8 9 9 10 10 u+ v v v u u Vectors - Addition • Addition of vectors is commutative (and associative).

  15. 5 5 10 10 9 9 4 4 3 8 3 8 7 2 7 2 1 1 6 6 1 1 2 2 3 3 5 5 4 4 6 6 7 7 8 8 9 9 10 10 v + u u+ v v v u u Vectors – Addition • Given two vectors, Which is equal to:

  16. 5 4 -1 -2 3 2 -3 -4 1 -4 -3 -2 -1 1 2 3 4 5 Vectors - Subtraction • Subtraction works the same as addition (with negative values): • Given two vectors, v u -u -u

  17. 2 1 1.8 0.8 0.6 1.6 0.4 1.4 0.2 1.2 0.2 0.4 0.6 1 0.8 1.2 1.4 1.6 1.8 2 Vectors – Basis • Give two vectors , and • There are two interesting things about , and : • They are perpendicular to each other • They are both unit vectors

  18. 2 1 1.8 0.8 0.6 1.6 0.4 1.4 0.2 1.2 0.2 0.4 0.6 1 0.8 1.2 1.4 1.6 1.8 2 Vectors – Basis • For , and : • They are perpendicular to each other (, and are said to be “orthogonal” to each other) • They are both unit vectors • These two vectors form the 2D Cartesian Coordinate System. • We can say that and are the “basis vectors” of the 2D Cartesian Coordinate System

  19. Vector - Basis • For , and , we say that the two vectors form an “orthonormal basis” because they: • Are orthogonal to each other, and • Are both unit vectors

  20. 5 10 9 4 3 8 2 7 1 6 1 2 3 5 4 6 7 8 9 10 Vectors – Basis • It turns out, any two “linearly independent” vectors, , can form a 2D basis. • In other words, given a vector , we can always express as a linear combination of the basis vectors

  21. Vector - Basis • More formally, given a 2D vector , we can express it using two basis vectors and : • Question: Can you think of two vectors that CANNOT form basis vectors for a 2D space? • (Hint: think linear independence)

  22. OK not OK not OK OK Vector - Basis • The last two conditions are NOT ok because the two vectors are “linearly dependent”. • That is, one vector is the scalar multiple of the other

  23. Algebraic Properties of Vectors • Commutative: • Associative: • Additive identity: there is a vector 0 (the null vector), such that: • Additive inverse: • Distributive (vector): • Distributive (scalar): v • Multiplicative identity: For any

  24. Questions?

  25. Vector – Cross Product • The Cross Product of two vectors is a vector that is perpendicular to both original vectors. That is, it is normal to the plane containing the two vectors. • Given two vectors and , the dot product is written as .

  26. Vector – Cross Product • Important Note: • Cross Product is not commutative. That is: • In fact, • The “Right Hand Rule”

  27. Vector – Cross Product • More formally: the cross product of and is written as: , and is defined as:

  28. Vector – Cross Product • In addition, it is important to note that: • That is, the cross product of two vectors is not a normal vector. • In fact, where is the angle between the two vectors and . • What is the area of a parallelogram?

  29. Vector – Cross Product • If you think about it, this equation: • says that the magnitude of the cross product is “how perpendicular and are” • Hint, think about the . If , then • Since the magnitude of a 3D vector is: • We can think of the cross product as the “magnitude” of the sum of the x, y, and z components

  30. Vector – Cross Product • Deriving the cross product… For a simple 2D Case:

  31. Vector – Cross Product • When the axes are x and y, we get: • We could have easily labeled the axes as y and z, or z and x, and we would get: • In other words, if we take two 3D vectors, and project them down to the (x,y), (y,z), and (z,x) planes, we could get the areas of the parallelogram in each of the planes.

  32. Vector – Cross Product • Since we can think of the (x,y) plane as defined by a unit vector at the origin (0, 0, 0). Meaning that we can think of the relationship as: , we can rewrite the previous equations as: • Similarly:

  33. Vector – Cross Product • Or more simply:

  34. Vector – Cross Product • Another way to derive the cross product: • Let’s say that we’re in , which is formed by three orthonormal basis vectors: • If it makes things easier, you can imagine , , and . • Based on our definition of the cross product: , , , ,

  35. Vector – Cross Product • Given two and , we can rewrite each as a sum of its components in the i, j, k basis, such that: , and • So

  36. Vector – Cross Product • One More Thought: • For those of you who are ninja’s in linear algebra. You might have already noticed that: • Recall that the determinant of a matrix is:

  37. Vector – Cross Product • Recall that the determinant of a matrix is: • Organize the terms a little bit, and you get:

  38. Questions?

  39. Vector – Dot Product • Basic Formula: • For two vectors, and , the dot product (or “inner product” or “scalar product”) is defined as: • Or,

  40. Vector – Dot Product • As it turns out, if and are two non-zero vectors:

  41. Vector – Dot Product • This is important because if I want to know the angle between two vectors, I can trivially compute: • Note that if both and are unit vectors, then: • Note that will be in radians (that is, )

  42. Vector – Dot Product • Other useful things with dot products • What are the results?

  43. Vector – Dot Product • Other useful things with dot products

  44. Vector – Dot Product • Determining “front” vs. “back” facing triangles • Back-face culling

  45. 5 4 3 2 1 -5 -4 -3 -2 -1 1 2 3 4 5 Vector – Dot Product • Example: • Perpendicular vectors always have a dot product of 0 because the cosine of 90o is 0 • For , and

  46. v u Vector – Dot Product • More use of the Dot Product: Finding the length of a projection • If is a unit vector, then is the length of the projection of onto the line containing Recall dot product: If = 1, then u’

  47. radius = ||v|| |v| sin() |v| cos() Vector – Dot Product • Prove that: • By trigonometric identity: (see proof: http://www.themathpage.com/atrig/sum-proof.htm) • So,

  48. Questions?

  49. Exercises: • What is the result? A point , a vector , or a scalar ? • Show that is orthogonal to both and

  50. Questions?

More Related