Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does 4x4 matrix work in 3d graphic?

I am learning about 3d graphics and have stumbled upon matrixes, which I don't fully understand. I have a 3d object, with topology, points in coordinate system and ECS (4x4 matrix of the object). ECS is:

-1.1247455413666E-32 , 1.83690953073357E-16, 1                    , -95  , 
 1                   , 6.12303176911189E-17, 0                    , 604  , 
-6.12303176911189E-17, 1                   , -1.83690953073357E-16, 200.5, 
 0                   , 0                   , 0                    , 1    , 

What does each line separated with comma mean ? Are these translation vectors?

like image 912
Zaay Avatar asked Mar 16 '15 14:03

Zaay


People also ask

Why do we use 4x4 matrices in 3D graphics?

the reason to use a 4x4 matrix is so that the operation is a linear transformation. this is an example of homogeneous coordinates. The same thing is done in the 2d case (using a 3x3 matrix).

How is matrix used in 3D computer graphics?

The usefulness of a matrix in computer graphics is its ability to convert geometric data into different coordinate systems. A matrix is composed of elements arranged in rows and columns.

What is a 4x4 matrix used for?

A 4x4 matrix can represent all affine transformations (including translation, rotation around origin, reflection, glides, scale from origin contraction and expansion, shear, dilation, spiral similarities).


2 Answers

Matrices define linear transformations between vector spaces. All linear transformations map the origin of the domain to the origin of the range. Therefore 3x3 matrices cannot perform translation on 3D vectors since the origin in one space cannot be mapped to anything but the origin on another using linear maps.

To overcome this problem, we can fake the system into performing translations through the use of an extra dimension where all vectors will have a 1 in the last vector component. These 4D vectors will never be at the origin (having 1 in the last component) and so are not required to always map to the origin. Through the use of this we can construct a 4x4 matrix to perform translation as in:

| 1  0  0  Tx|   | x |   | x + Tx |
| 0  1  0  Ty|   | y |   | y + Ty |
| 0  0  1  Tz| x | z | = | z + Tz |
| 0  0  0   1|   | 1 |   |   1    |

For rendering purposes, the 1 in the last position is dropped.

like image 126
andand Avatar answered Sep 28 '22 02:09

andand


The upper left 3x3 block gives the rotation of the coordinate system, the upper 3 coordinates of the last column give the translation vector.

The general idea of this affine parametrization is that for the transformation one multiplies

[ x, y, z, 1 ]^T

from the right.

like image 27
Lutz Lehmann Avatar answered Sep 28 '22 02:09

Lutz Lehmann