1 / 72

Animation and Games Development

Animation and Games Development. 242-515 , Semester 1 , 2014-2015. Objective to give some background on the course. 7. Basic Maths. Overview. Vectors Matricies The Dot Product The Cross Product Transformations as Matricies Multiple Coordinate Spaces Models in a Scene Graph.

Download Presentation

Animation and Games Development

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. Animation and Games Development 242-515, Semester 1, 2014-2015 • Objective • to give some background on the course 7. Basic Maths

  2. Overview • Vectors • Matricies • The Dot Product • The Cross Product • Transformations as Matricies • Multiple Coordinate Spaces • Models in a Scene Graph

  3. 1. Vectors • A vector is a magnitude(size) and a direction. • drawn as an arrow

  4. Two vectors V and W are added by placing the beginning of W at the end of V • Subtraction reverses the second vector W V V + W W –W V V – W V

  5. Triangle Rule for Subtraction • Place c and d tail-to-tail. • d – c is the vector from the head of c to the head of d

  6. Vectors are added and subtracted component-wise:

  7. Vector Magnitude • The magnitude of a vector is a scalar (a number):

  8. Normalization • A normalized vector always has unit length. • To normalize a non-zero vector, divide by its magnitude.

  9. Normalize [12, -5]:

  10. Normalization as a Diagram unit circle

  11. 2. Matrices • A matrix is an array of numbers arranged in rows and columns • A matrix with n rows and m columns is an nm matrix • M is a 2  3 matrix • If n = m, the matrix is a square matrix

  12. The transpose of a matrix M is denoted MT and has its rows and columns exchanged:

  13. An n-dimensional vector V can be thought of as an n 1 columnmatrix: • Or a 1 nrow matrix:

  14. Matrix Multiplication • The entries of the product of two matricies A and B are calculated by: • The number of columns in Amust equal the number of rows in B. • If A is a nm matrix, and B is an mp matrix, then AB is an np matrix.

  15. Example:

  16. In three dimensions, the product of a matrix and a column vector looks like:

  17. Identity Matrix In For any nn matrix M, the product with the identity matrix is M itself • InM = M • MIn = M

  18. Invertible • An nn matrix M is invertible if there exists another matrix G such that • The inverse of M is denoted M-1

  19. Determinant • The determinant of a square matrix M is denoted det M or |M| • A matrix is invertible if its determinant is not zero. • For a 2  2 matrix,

  20. The determinant of a 3  3 matrix is

  21. Inverse • Explicit formulas exist for matrix inverses • These are good for small matrices, but other methods are generally used for larger matrices • In computer graphics, we usually deal with 2  2, 3  3, and a special form of 4  4 matrices

  22. 3. The Dot Product • The dot product is a product between two vectors that produces a magnitude (a number). • The dot product between twon-dimensional vectors V and W is given by • In three dimensions,

  23. Dot product a· b is the magnitude of the projection of the b vector onto the a vector.

  24. Sign of the Dot Product

  25. The dot product equation: • a is the angle between the two vectors • That's why the dot product is 0 between perpendicular vectors • If V and W are unit vectors, the dot product is 1 for parallel vectors pointing in the same direction, -1 for opposite

  26. Dot Product for Finding Angles • The dot product can be used to find the angle between two vertors a and b. • First normalize a and b. • The angle between them is cos-1â . b ^

  27. A Line as a Vector • A line in 3D space can be represented by • S is a point on the line, and V is the direction along which the line runs. R is a point on the line, t is a magnitude. R(t) = S + t V V t R S

  28. Distance to a Line • Distance d from a point P to the line R(t)= S + t V P d S V

  29. Use Pythagorean theorem: • Taking square root, • If V is unit length, then V 2 = 1

  30. 4. The Cross Product • The cross product between two vectors a and b produces a vector (a x b) which is perpendicular to both.

  31. The cross product between V and W is • One way of remembering this equation is as the determinant:

  32. It can also be expressed as a matrix-vector product • The perpendicularity property means that:

  33. The cross product equation is: • This is equal to the area of the parallelogram formed by V and W: V ||V|| sin a a W

  34. Here's why:

  35. b a

  36. What about the axb Direction? • Does the vector a x bpoint up or down from the plane of a and b? • Place the tail of b at the head of a. • Using your right hand, curl your fingers in the direction of the vectors. • Your thumb points in the direction of a x b

  37. Reversing the order of the vectors negates the cross product: • the cross product is anti-commutative • If a x b = 0, then a is parallel to b.

  38. 5. Transformations as Matricies • A complex transformation can be built by combining simple transformations, of the types: • translations • scaling • rotations • Transformations are combined by multiplying their matrices together.

  39. 2D Translation (x+dx, y+dy) y y (x, y) dy x x dx (0,0)

  40. 2D Scaling • Resizes an object in each dimension about origin y y (sxx, syy) (x, y) x x

  41. 2D Rotation • Rotate counter-clockwise about the origin by angle  y y (x', y') (x, y)  x x

  42. Homogenous Transformation Matricies • An 4x4 homogenous matrix can store 3D transformations. • This makes matrix inversion and combinations of transformations simpler. • It also makes it possible to define perspective transformations.

  43. 3D Translation Translation by (Δx, Δy, Δz):

  44. 3D Scaling Scaling about the origin

  45. 3D Rotations • z-axis rotation • Rotates about the z-axis through the angle q

  46. Rotations about the x-, y- axes

  47. Combining Transformations • The combined 4  4 homogenenous matrix is very common in computer graphics: • R is a 3  3 rotation matrix, and T is a translation vector

More Related