7

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?

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51
Zaay
  • 622
  • 2
  • 8
  • 23
  • You need to do some study. See, for example http://stackoverflow.com/questions/11966779/learning-webgl-and-three-js/11970687#11970687 – WestLangley Mar 16 '15 at 15:14
  • 1
    Each line is a row in the matrix; the commas separate the column values in that row. This a transformation matrix. You can't understand it without knowing something about matricies. – duffymo Mar 16 '15 at 15:20
  • 2
    look here http://stackoverflow.com/a/28084380/2521214 – Spektre Mar 16 '15 at 18:30
  • You can't avoid matrices and vectors if you're serious about 3d graphics. As for 'why' the use of a 4x4 matrix, this falls under the auspices of [homogenous coordinates](http://en.wikipedia.org/wiki/Homogeneous_coordinates). – Brett Hale Mar 17 '15 at 13:57

3 Answers3

14

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.

andand
  • 17,134
  • 11
  • 53
  • 79
  • Thank you for explanation. What does the x between Tz and z stand for ? – Zaay Mar 17 '15 at 09:36
  • That's a multiplication operator. http://en.wikipedia.org/wiki/Matrix_multiplication – andand Mar 17 '15 at 14:31
  • 2
    Great explanation. I've always wondered why 3d graphical transformations seem linear but don't use a 3x3 matrix. Turns out I forgot the constraint on "origin must stay at origin" for linear transformations. The "fake" 4x4 matrix with a 1 so it's "never at the origin" explains it perfectly. – WSBT Apr 15 '20 at 22:02
4

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.

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51
0

Intuitive example: imagine how you can change the position (translation) of 2D rectangle on the wall, which is projected by a projector. In 3D space (in which we live) you can just rotate a projector a little bit and at the end the projected screen is moved even though the projector stays at the same position on the table, so it is a linear translation in a 3D space.

You can use the same principle to 3D space and 4D projector, which can be simply rotated in a 4D space.

slsy
  • 1,257
  • 8
  • 21