Decompose 2D Transformation Matrix

后端 未结 3 925
余生分开走
余生分开走 2021-01-03 09:49

So, I have a Direct2D Matrix3x2F that I use to store transformations on geometries. I want these transformations to be user-editable, and I don\'t want the user

3条回答
  •  日久生厌
    2021-01-03 10:18

    This is the solution I found for a Direct2D transformation matrix:

    • scale x = sqrt(M11 * M11 + M12 * M12)

    • scale y = sqrt(M21 * M21 + M22 * M22) * cos(shear)

    • rotation = atan2(M12, M11)

    • shear (y) = atan2(M22, M21) - PI/2 - rotation

    • translation x = M31

    • translation y = M32

    If you multiply these values back together in the order scale(x, y) * skew(0, shear) * rotate(angle) * translate(x, y) you will get a matrix that performs an equivalent transformation.

提交回复
热议问题