Why do transformation matrices always have an extra dimension? [duplicate]

virtouso 07/16/2018. 1 answers, 1.988 views
3d mathematics graphics-programming

This question already has an answer here:

In 3D math I always see matrices with one additional dimension. For example, in 3D graphics, matrices are always 4x4 and in 2d they are 3x3 matrices. Can anyone explain why?

1 Answers


Sean Middleditch 07/16/2018.

This is a facet of the math of affine transformations crammed into a single matrix.

In an affine transformation you have the equation: x' = Ax + b, where x is the original vector, A is the transformation matrix, and b is the translation vector.

To combine A and b into a single matrix requires some extra work. Namely, we must be sure that we can "turn off" the translation when transforming a geometric vector (they have no position in space and hence cannot move) but still apply it when transforming a geometric point (which is nothing but a position in space).

The trick is to put the translation into a fourth column on the transformation matrix as well as adding an additional component to the vectors themselves. This additional component is 1 for geometric points and 0 for geometric vectors. The math of the matrix multiply then works out that the translation components are multiplied by 1 (the identity) for geometric points and added to the final result after rotation/scaling, while the components are multiplied by 0 for geometric vectors and hence nothing is added to the final result.

Explanation with pictures and math examples: https://medium.com/hipster-color-science/computing-2d-affine-transformations-using-only-matrix-multiplication-2ccb31b52181

Related questions

Hot questions

Language

Popular Tags