Results 1 to 6 of 6

Thread: Extracting current rotation

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Extracting current rotation

    Hi,
    In my app based entirely on GraphicsView, I have items which can be rotated , mirrored etc. I want to save these states in a file without having to maintain separate variable like currentAngle . I thought of saving the matrix itself but I want to support old file format
    And hence I need a way to extract only rotation part, mirroring separately!
    Is it possible to extract only them from an item ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  2. #2
    Join Date
    Mar 2006
    Posts
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Extracting current rotation

    You can calculate all you want from the matrix with some math, search the web for it. For example:

    http://en.wikipedia.org/wiki/Transformation_matrix

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Extracting current rotation

    I had seen that link. What I want is to extract only rotation angle from a matrix on which all possible operations could have been done. For eg if i do
    item->rotate(23), item->scale(1.3)
    I should be able to extract '23' from the item->matrix.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Extracting current rotation

    Quote Originally Posted by Gopala Krishna View Post
    I had seen that link. What I want is to extract only rotation angle from a matrix on which all possible operations could have been done. For eg if i do
    item->rotate(23), item->scale(1.3)
    I should be able to extract '23' from the item->matrix.
    Due to the complexity of computations involved and the combination properties of matrices there's practically no way to extract an angle from a transformation matrix nuless you know ALL the others transformations applied to the matrix... As QMatrix doesn't record successive transformations it can't provide the function you're looking for and I guess you'll have a hard time implementing such an extraction on your own... IMHO, you'd better change your state file format to use QMatrix. It does not mean that you should stop supporting the previous one but just indicates in the file header which version is used (i.e with plain old values or with matrices...)
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Extracting current rotation

    Thanks for your reply. If that is the case, I'll stick on to using conventional method.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Extracting current rotation

    The answer to this question is no.

    Once you apply another transformation over a rotation you loose the rotation matrix.
    I have just tested this in Illustrator. If you rotate a rectangle then the bounding box will alos reflect the items' rotation. If you save it to pdf without "Illustrator editing capabilities", when you load it again, the bounding box will be mapped with an identity matrix ( meaning that the rotation was lost ).

    If you really want to do this, you can attach extra information to the item as you edit it ( store it's rotation, scaling, etc ) with the QGraphicsItem::setData function.

    Regards

Similar Threads

  1. Replies: 15
    Last Post: 21st April 2007, 17:46
  2. Replies: 1
    Last Post: 19th April 2007, 22:23
  3. How to get current row(column) index in the QTextTable?
    By denny.t in forum Qt Programming
    Replies: 3
    Last Post: 5th April 2006, 07:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.