* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download SE 320
Jordan normal form wikipedia , lookup
Euclidean vector wikipedia , lookup
Eigenvalues and eigenvectors wikipedia , lookup
Determinant wikipedia , lookup
Matrix (mathematics) wikipedia , lookup
Covariance and contravariance of vectors wikipedia , lookup
Perron–Frobenius theorem wikipedia , lookup
Gaussian elimination wikipedia , lookup
Non-negative matrix factorization wikipedia , lookup
Singular-value decomposition wikipedia , lookup
Rotation matrix wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
Orthogonal matrix wikipedia , lookup
Matrix calculus wikipedia , lookup
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) 1 Plan for Today • One hour lecture • Two hour quiz and lab 2 Exam Talk • Next week is the midterm exam • I can ask about anything that we have done here. – Slides may not be enough. 3 Our Goal • Understand the mathematical basis of 3D transformations. 4 What we know already • Math – Point, vector, magnitude, dot product, cross product, etc. • Transformations – Translation, rotation, scale – They have a mathematical basis 5 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 6 Translation • How can we move an object? – Add numbers to the coordinates of all of its points • Explanation on the board 7 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 8 Scale • How can we scale an object (wrt the origin)? – Multiplication! • Explanation on the board 9 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 10 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. 11 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 12 Scaling as Matrix Multiplication • Now we can combine rotation and scale however we wish! • RxSxRxRxSxSxRxS – The result is still a 3 by 3 matrix! Ready to be applied to a vector or combined with whatever else you’ve got! 13 Translation as a matrix multiplication? • Think about it for a minute. 14 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 15 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. 16 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. 17 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 18 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 19 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. 20 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. • −1, blah blah blah. DON’T CARE! We don’t need them. 21 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: 𝜃 𝜃 𝜃 𝜃 (𝑐𝑜𝑠 , 𝑎𝑥 𝑠𝑖𝑛 , 𝑎𝑦 𝑠𝑖𝑛 , 𝑎𝑧 𝑠𝑖𝑛 ) 2 2 2 2 • 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 22 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) 23