How does 4x4 matrix work in 3d graphic?

后端 未结 2 1554
天命终不由人
天命终不由人 2021-01-06 14:44

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

2条回答
  •  天涯浪人
    2021-01-06 15:28

    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.

提交回复
热议问题