1 / 51

CSCE 552 Spring 2011

CSCE 552 Spring 2011. Math. By Jijun Tang. Layered. Initialization/Shutdown. Resource Acquisition Is Initialization A useful rule to minimalize mismatch errors in the initialization and shutdown steps

schancy
Download Presentation

CSCE 552 Spring 2011

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. CSCE 552 Spring 2011 Math By Jijun Tang

  2. Layered

  3. Initialization/Shutdown • Resource Acquisition Is Initialization • A useful rule to minimalize mismatch errors in the initialization and shutdown steps • Means that creating an object acquires and initializes all the necessary resources, and destroying it destroys and shuts down all those resources • Optimizations • Fast shutdown • Warm reboot

  4. Main Game Loop • Structure • Hard-coded loops • Multiple game loops: for each major game state • Consider steps as tasks to be iterated through • Coupling • Can decouple the rendering step from simulation and update steps • Results in higher frame rate, smoother animation, and greater responsiveness • Implementation is tricky and can be error-prone

  5. Math

  6. Applied Trigonometry • Trigonometric functions • Defined using right triangle h y a x

  7. Applied Trigonometry • Angles measured in radians • Full circle contains 2p radians

  8. Applied Trigonometry • Sine and cosine used to decompose a point into horizontal and vertical components y r r sin a a x r cos a

  9. Trigonometry

  10. Trigonometric identities

  11. Inverse trigonometric functions • Return angle for which sin, cos, or tan function produces a particular value • If sin a = z, then a = sin-1z • If cos a = z, then a = cos-1z • If tan a = z, then a = tan-1z

  12. arcs

  13. Applied Trigonometry • Law of sines • Law of cosines Reduces to Pythagorean theorem wheng = 90 degrees a c b b g a

  14. Vectors and Scalars • Scalars represent quantities that can be described fully using one value • Mass • Time • Distance • Vectors describe a magnitude and direction together using multiple values

  15. Examples of vectors • Difference between two points • Magnitude is the distance between the points • Direction points from one point to the other • Velocity of a projectile • Magnitude is the speed of the projectile • Direction is the direction in which it’s traveling • A force is applied along a direction

  16. Visualize Vectors • The length represents the magnitude • The arrowhead indicates the direction • Multiplying a vector by a scalar changes the arrow’s length 2V V –V

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

  18. High-Dimension Vectors • An n-dimensional vector V is represented by n components • In three dimensions, the components are named x, y, and z • Individual components are expressed using the name as a subscript:

  19. Add/Subtract Componentwise

  20. Vector Magnitude • The magnitude of an n-dimensional vector V is given by • In three dimensions, this is

  21. Vector Normalization • A vector having a magnitude of 1 is called a unit vector • Any vector V can be resized to unit length by dividing it by its magnitude: • This process is called normalization

  22. Matrices • A matrix is a rectangular array of numbers arranged as rows and columns • A matrix having n rows and m columns is an nm matrix • At the right, M is a2  3 matrix • If n = m, the matrix is a square matrix

  23. Matrix Representation • The entry of a matrix M in the i-th row and j-th column is denoted Mij • For example,

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

  25. Vectors and Matrices • An n-dimensional vector V can be thought of as an n 1 column matrix: • Or a 1 n row matrix:

  26. Vectors and Matrices • Product of two matrices A and B • Number of columns of A must equal number of rows of B • Entries of the product are given by • If A is a nm matrix, and B is an mp matrix, then AB is an np matrix

  27. Vectors and Matrices • Example matrix product

  28. Vectors and Matrices • Matrices are used to transform vectors from one coordinate system to another • In three dimensions, the product of a matrix and a column vector looks like:

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

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

  31. Properties of Inverse • Not every matrix has an inverse • A noninvertible matrix is called singular • Whether a matrix is invertible can be determined by calculating a scalar quantity called the determinant

  32. 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,

  33. Determinant • The determinant of a 3  3 matrix is

  34. 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 are usually dealing with 2  2, 3  3, and a special form of 4  4 matrices

  35. Inverse of 2x2 and 3x3 • The inverse of a 2  2 matrix M is • The inverse of a 3  3 matrix M is

  36. 4x4 • A special type of 4  4 matrix used in computer graphics looks like • R is a 3  3 rotation matrix, and T is a translation vector

  37. Inverse of 4x4

  38. General Matrix Inverse • (AB) -1 = B-1A-1 • A general nxn matrix can be inverted using methods such as • Gauss-Jordan elimination • Gaussian elimination • LU decomposition

  39. Gauss-Jordan Elimination Gaussian Elimination

  40. The Dot Product • The dot product is a product between two vectors that produces a scalar • The dot product between twon-dimensional vectors V and W is given by • In three dimensions,

  41. Dot Product Usage • The dot product can be used to project one vector onto another V a W

  42. Dot Product Properties • The dot product satisfies the formula • a is the angle between the two vectors • Dot product is always 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

  43. Self Dot Product • The dot product of a vector with itself produces the squared magnitude • Often, the notation V 2 is used as shorthand for VV

  44. The Cross Product • The cross product is a product between two vectors the produces a vector • The cross product only applies in three dimensions • The cross product is perpendicular to both vectors being multiplied together • The cross product between two parallel vectors is the zero vector (0, 0, 0)

  45. Illustration • The cross product satisfies the trigonometric relationship • This is the area ofthe parallelogramformed byV and W V ||V|| sin a a W

  46. Area and Cross Product • The area A of a triangle with vertices P1, P2, and P3 is thus given by

  47. Rules • Cross products obey the right hand rule • If first vector points along right thumb, and second vector points along right fingers, • Then cross product points out of right palm • Reversing order of vectors negates the cross product: • Cross product is anticommutative

  48. Rules in Figure

  49. Formular • The cross product between V and W is • A helpful tool for remembering this formula is the pseudodeterminant (x, y, z) are unit vectors

More Related