{"id":50,"date":"2013-11-08T15:46:23","date_gmt":"2013-11-08T15:46:23","guid":{"rendered":"\/\/3dbym.ru\/2013\/11\/transforming-a-vector-by-a-matrix\/"},"modified":"2013-11-08T15:46:23","modified_gmt":"2013-11-08T15:46:23","slug":"transforming-a-vector-by-a-matrix","status":"publish","type":"post","link":"https:\/\/3dbym.ru\/2013\/11\/transforming-a-vector-by-a-matrix\/","title":{"rendered":"Transforming a Vector by a Matrix"},"content":{"rendered":"

Often in computer graphics and game programming, you will need to use matrices to move vectors and points around onscreen, such as to move a point or piece of geometry to a new position. This process is called trans\u00adformation. Matrices are used here for two reasons. First, they are excellent ways to store transformations as you saw previously, and second, they can easily be used to transform vectors and points by multiplication.<\/p>\n

In order to transform a vector, you simply use the vector as a 3×1 or 4×1 matrix, depending on which type of matrix you are using to transform. This is important because if you try to multiply a 3×1 matrix with a 4×4 matrix, it will not work. The same goes for a 4×1 matrix being multiplies with a 3×3. Do not worry if your vector does not fill<\/p>\n

<\/p>\n

the whole matrix, for instance a 3D vector being transformed by a 4×4 matrix. All you need to do is set the last element in the 4×1 matrix to 1. Then, after transformation, the last value can be discarded and you will once again have a vector with the same number of dimensions that you started with. Multiply your matrices together, and you will get a new, transformed, vector. This operation is shown in Figure 1.22.<\/p>\n\n\n\n\n
\n

1<\/p>\n<\/td>\n

\n

2<\/p>\n<\/td>\n

\n

3~<\/p>\n<\/td>\n

\n<\/td>\n\n

~3~<\/p>\n<\/td>\n

\n<\/td>\n\n

1×3+2×1+3×4<\/p>\n<\/td>\n

\n<\/td>\n\n

~17~<\/p>\n<\/td>\n<\/tr>\n

\n

4<\/p>\n<\/td>\n

\n

5<\/p>\n<\/td>\n

\n

6<\/p>\n<\/td>\n

\n<\/td>\n\n

1<\/p>\n<\/td>\n

\n

—<\/p>\n<\/td>\n

\n

4 x 3 + 5 x1+6×4<\/p>\n<\/td>\n

\n

—<\/p>\n<\/td>\n

\n

41<\/p>\n<\/td>\n<\/tr>\n

\n

7<\/p>\n<\/td>\n

\n

8<\/p>\n<\/td>\n

\n

9<\/p>\n<\/td>\n

\n<\/td>\n\n

4<\/p>\n<\/td>\n

\n<\/td>\n\n

7 x 3 + 8 x1+9×4<\/p>\n<\/td>\n

\n<\/td>\n\n

65<\/p>\n<\/td>\n<\/tr>\n<\/table>\n\n\n
\n

Figure 1.22 Transforming a vector by a matrix. Multiplying a vector by a matrix will yield a new vector with a new, transformed position. The operation is just regular matrix multiplication as defined earlier in the chapter, only this time it isn\u2019t using two square matrices.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"

Often in computer graphics and game programming, you will need to use matrices to move vectors and points around onscreen, such as to move a point or piece of geometry to a new position. This process is called trans\u00adformation. Matrices are used here for two reasons. First, they are excellent ways to store transformations as […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts\/50"}],"collection":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":0,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3dbym.ru\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}