Why do 2D transformations need 3x3 matrices?

后端 未结 2 1698
醉酒成梦
醉酒成梦 2020-12-28 16:38

I want to do some 2D drawing and thus want to implement some matrix transformations. With my light mathematics background I am trying to understand how to do so in C# (any o

相关标签:
2条回答
  • 2020-12-28 17:04

    this is with multiplications of the matrices that we create our transformations

    This is why we want square matrices.

    Suppose we did what you propose, and used 2x3 matrices for our transformations.

    Then a rotation would be

    ( x1, x2, 0 )
    ( y1, y2, 0 )
    

    and a translation would be

    ( 1, 0, tx )
    ( 0, 1, ty )
    

    and we could perform either rotations or translations by multiplying our matrix by a column vector representing the point:

        ( x )
    M   ( y )
        ( 0 )
    

    to get correct answers.

    However - how would we go about composing transformations? Indeed, for your "for a rotation + translation I have a matrix like this" example, how did you get to that matrix? Sure, in this case you can just write it out, but in general? Well, you know the answer:

    this is with multiplications of the matrices that we create our transformations

    So it must be possible to multiply two transformation matrices to give another transformation matrix. And the rules of matrix multiplication show that this:

    ( . . . ) ( . . . )
    ( . . . ) ( . . . ) = ???
    

    is not a valid matrix multiplcation. We need matrices that can be multipled in order for our transformations to be composable. So we have that extra row.


    Now, the way I've expressed it here is in fact completely backward from the standard mathematical presentation, in which the familiar transformations of rotation and translation are just special cases of the full power of homogeneous coordinate transformations on the projective plane - but I think it will do to show you why we need that extra row - to make the matrix square, and thus able to be multipled with like matrices.

    0 讨论(0)
  • 2020-12-28 17:13

    The answer is Homogeneous Coordinates. To combine rotation and translation in one operation one extra dimension is needed than the model requires. For planar things this is 3 components and for spatial things this is 4 components. The operators take 3 components and return 3 components requiring 3x3 matrices.

    0 讨论(0)
提交回复
热议问题