Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get the rotate angle by QMatrix.
Forum Updated to NodeBB v4.3 + New Features

How to get the rotate angle by QMatrix.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dxwang
    wrote on last edited by
    #1

    hi,everyone!
    now I have a QMatrix, maybe it has been moved, scaled, sheared,and rotated. and I have found that scaling x and y by different factors can change the angle, but it doesn't go rotate command, so I can't record this angle. now how I can get the degree by this QMatrix, Because I want to let my graphic to be horizontal as the original.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Neither QMatrix nor QTransform gives you the value of the rotation. You should however be able to calculate the rotation from the mxy() (i.e. m11, m23()) values. Can't tell you how you should do that though.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dxwang
        wrote on last edited by
        #3

        ok,thanks Franzk。 who can tell me how to calculate the rotation from mxy()(i.e. m11, m23()) .

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          I was just looking through the "wiki article on transformation matrices":http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations and it seems to me that you could use the following information:
          @transform.m11() == cos(theta)
          transform.m12() == -sin(theta)
          transform.m21() == sin(theta)
          transform.m22() == -cos(theta)@

          That would mean that
          @qreal theta = acos(transform.m11());@

          This all is assuming you are using QTransform (QMatrix is deprecated).

          Note that the math.h trigonometric function work with "radians":http://en.wikipedia.org/wiki/Radians rather than degrees.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jim_kaiser
            wrote on last edited by
            #5

            But, the real problem is probably the order of transformations you are doing because that can alter the result completely.. I say this because you should be able to write your transforms to get the intended result (mathematically).. without needing to try and hard-modify the matrix like you plan to.. maybe you need more specific transformation than a matrix can provide...

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved