1 / 23

SE 313 – Computer Graphics

SE 313 – Computer Graphics. Lecture 7 : Mathematical Basis for 3D Transformations Lecturer: Gazihan Alankuş. Please look at the last three slides for assignments (marked with TODO ). Plan for Today. One hour lecture Two hour quiz and lab. Exam Talk. Next week is the midterm exam

danil
Télécharger la présentation

SE 313 – Computer Graphics

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. SE 313 – Computer Graphics Lecture 7: Mathematical Basis for 3D Transformations Lecturer: GazihanAlankuş Please look at the last three slides for assignments (marked with TODO)

  2. Plan for Today • One hour lecture • Two hour quiz and lab

  3. Exam Talk • Next week is the midterm exam • I can ask about anything that we have done here. • Slides may not be enough.

  4. Our Goal • Understand the mathematical basis of 3D transformations.

  5. What we know already • Math • Point, vector, magnitude, dot product, cross product, etc. • Transformations • Translation, rotation, scale • They have a mathematical basis

  6. What will we transform? • Objects are made of points • Pairs of such points define vectors • Points • Translate, rotate? (around origin), scale? (wrt. origin) • Vectors • Translate?(no!), rotate, scale

  7. Translation • How can we move an object? • Add numbers to the coordinates of all of its points • Explanation on the board

  8. Rotation • How can we rotate an object (around the origin)? • Trigonometry! • Ok but how can we make these calculations more systematically? • Matrix-vector multiplication! • M x v (the column vector is on the right) • Explanation on the board

  9. Scale • How can we scale an object (wrt the origin)? • Multiplication! • Explanation on the board

  10. Combining Transformations • Of the same kind • Translation • Just add the numbers that you will add for each • Scale • Just multiply the numbers that you will multiply for each • Rotate? • Guess what, matrix multiplication from linear algebra is actually useful

  11. Combining Transformations • What if I want to do “rotate, translate, and then rotate” like we did last week? • How will you combine element-wise addition, element-wise multiplication and matrix multiplication? • You can’t. Unless you make them be the same operation.

  12. Scaling as Matrix Multiplication • Instead of doing element-wise multiplication, why not get an identity matrix, multiply the diagonals of that identity matrix with the scale factors and then use it? • Explanation on the board

  13. Scaling as Matrix Multiplication • Now we can combine rotation and scale however we wish! • R x S x R x R x S x S x R x S • The result is still a 3 by 3 matrix! Ready to be applied to a vector or combined with whatever else you’ve got!

  14. Translation as a matrix multiplication? • Think about it for a minute.

  15. Translation as a matrix multiplication? • It is possible if we add one more dimension • The fourth column holds the translation nicely – very clever hack • Explanation on the board

  16. Homogeneous Coordinates • Four entities in a column vector represent three dimensions. The last entry is always 1. If not, divide all with the last entry. • The fourth dimension does not have any significant meaning. It’s just a hack. • 3x3 rotation/scale matrices -> 4x4 matrices with the rest coming from identity • Transformation column vectors -> 4x4 identity matrices, with the column vector pasted to the fourth column.

  17. Combining Transformations Using Homogeneous Coordinates • Mr x Mt x Ms x Mt x Mr x Mr x Mt • Still a 4x4 matrix, ready to be applied to your 3 dimensional column vectors with a 1 in the end (for points) • For vectors, you put a 0 in the end. Remember slide #4, you cannot translate vectors! • The math works nicely.

  18. Combining Transformations and the Order of Matrix Multiplication • When you read the matrix multiplication from left to right, it is the world-to-local order of applying transformations

  19. Combinations of Translations and Rotations • Mt x Mr x Mr x Mt x Mt x Mr • Whichever order you apply, this is equal to Mt’ x Mr’ for some t’ and r’ • The 3x3 part of the matrix is the rotation • The last column is the translation

  20. More interesting facts • When you apply a transformation to an object that was straight in the origin, the object’s local coordinate frame moves with the object. The location and the x, y, z vectors of this local frame can be represented in global coordinates. • The x, y, z vectors of the local coordinate frame are the first three columns of the transformation matrix! • The location of this local coordinate frame is the fourth column of the transformation matrix. • You can use this information to construct transformation matrices.

  21. Quaternions • 3x3 matrices have too much data. We can represent it with three numbers (three rotations). But this does not play well with mathematics. • Instead, we represent them with four numbers. Quaternions happen to be a good mathematical construct for this. • , blah blahblah. DON’T CARE! We don’t need them.

  22. Quaternions • What we care about is that they represent rotations as an angle and an axis • http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation • They encode it in a funny way though: • Or, the four tuple: • We still do not care as strongly. Just know that, for you, quaternion means rotation. • You can use it instead of 3x3 matrices • You can create it using an axis and an angle • You can extract from it an axis and an angle • With quaternion multiplication, you can combine them just like you combine matrices • Most 3D libraries enable you to rotate a vector with a quaternion

  23. Quizzes and Lab • For two hours, the assistant will administer • A closed-book quiz (15 minutes, on paper) • An open-book quiz (rest of class, on paper) • The blender implementation of the last two questions of the open-book quiz (graded by demonstrating to the assistant)

More Related