{"id":37,"date":"2013-11-08T15:46:23","date_gmt":"2013-11-08T15:46:23","guid":{"rendered":"\/\/3dbym.ru\/2013\/11\/matrix-multiplication\/"},"modified":"2013-11-08T15:46:23","modified_gmt":"2013-11-08T15:46:23","slug":"matrix-multiplication","status":"publish","type":"post","link":"https:\/\/3dbym.ru\/2013\/11\/matrix-multiplication\/","title":{"rendered":"Matrix Multiplication"},"content":{"rendered":"
Okay, on to matrix multiplication! Lots of people get confused when it comes to multiplying matrices. In reality, however, it really isn\u2019t that hard. The first thing you need to do is determine whether the matrices are conformable. Lets say you have two matrices, A and B, that have the dimensions mxn and pxq. The matrices are conformable only if n=p. For instance, a 3×3 matrix and a 3×7 matrix can be multiplied to\u00adgether, but a 3×2 and a 4×5 matrix cannot. If your two matrices satisfy this requirement, you can move to the next step.<\/p>\n
The resulting matrix will have the dimensions mxq. That means in the previous example, a 3×3 and a 3×7 matrix multiplied together would produce a 3×7 matrix. The nice thing about 3D graphics is that the matrices you use are usually square. When you multiply two square<\/p>\n
<\/p>\n
matrices together, you guessed it, you get a square matrix of the same size, so a 4×4 matrix multiplied by another 4×4 matrix will give you a final matrix with dimensions 4×4.<\/p>\n
But just how do you multiply them together you ask? Well the idea is pretty simple. You take the first row of the first matrix and multiply it by the first column of the second matrix. This results in a single num\u00adber that goes in the first row and first column of the result. The second element of the result is the first row of the first matrix times the sec\u00adond column of the second matrix, and so on. Sound confusing? Maybe you need to look at it a little differently.<\/p>\n
Consider two 3×3 matrices, A and B, which are multiplied together to form C. You know that the first row of A contains the elements An, A12, and A, D. The first column of B contains Bn, B21, and B31. In order to get<\/p>\n
13′<\/p>\n
Cn you take (An x B11) + (A12 x B21) + (A13 x B31). You do that a total of nine times to get all the elements for the 3×3 result. Let\u2019s try multiply\u00ading one in Figure 1.6.<\/p>\n
\n 3<\/p>\n<\/td>\n | \n 5<\/p>\n<\/td>\n | \n 0<\/p>\n<\/td>\n | \n 2<\/p>\n<\/td>\n | \n 5<\/p>\n<\/td>\n | \n 2<\/p>\n<\/td>\n | \n<\/td>\n | \n 3X2+5X7+0X4<\/p>\n<\/td>\n | \n 3X5+5X3+0X5<\/p>\n<\/td>\n | \n 3X2+5X1+0X9<\/p>\n<\/td>\n | \n<\/td>\n | \n 41<\/p>\n<\/td>\n | \n 30<\/p>\n<\/td>\n | \n 11<\/p>\n<\/td>\n<\/tr>\n | |||||||||||
\n 4<\/p>\n<\/td>\n | \n 4<\/p>\n<\/td>\n | \n 8<\/p>\n<\/td>\n | \n 7<\/p>\n<\/td>\n | \n 3<\/p>\n<\/td>\n | \n 1<\/p>\n<\/td>\n | \n =<\/p>\n<\/td>\n | \n 4×2+4×7+8×4<\/p>\n<\/td>\n | \n 4×5+4×3+8×5<\/p>\n<\/td>\n | \n 4×2+4×1+8×9<\/p>\n<\/td>\n | \n =<\/p>\n<\/td>\n | \n 68<\/p>\n<\/td>\n | \n 72<\/p>\n<\/td>\n | \n CO<\/p>\n<\/td>\n<\/tr>\n | |||||||||||
\n 9<\/p>\n<\/td>\n | \n 6<\/p>\n<\/td>\n | \n 1<\/p>\n<\/td>\n | \n 4<\/p>\n<\/td>\n | \n 5<\/p>\n<\/td>\n | \n 9<\/p>\n<\/td>\n | \n<\/td>\n | \n 9X2+6X7+1X4<\/p>\n<\/td>\n | \n 9X5+6X3+1×5<\/p>\n<\/td>\n | \n 9X2+6X1+1X9<\/p>\n<\/td>\n | \n<\/td>\n | \n 64<\/p>\n<\/td>\n | \n 68<\/p>\n<\/td>\n | \n 33<\/p>\n<\/td>\n<\/tr>\n<\/table>\n
|