Results 1 to 3 of 3

Thread: Rotate about point

  1. #1
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Question Rotate about point

    Hello,

    At first I would like to apologize you for my english.

    I have a triangle, let's say like this
    Qt Code:
    1. static const QPoint T[3] = {
    2. QPoint(80, 80),
    3. QPoint(80, 88),
    4. QPoint(-80, 84)
    5. };
    6. painter.drawConvexPolygon(T, 3);
    To copy to clipboard, switch view to plain text mode 

    and I want to rotate this triangle about point a(-80.0,84.0). HHow can I do this?
    It will be in loop so i want to change only degrees. And when i want to change degrees it should be come back on the first position. Thanks for help.
    Last edited by Andree; 17th May 2014 at 22:24. Reason: spelling corrections

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Rotate about point

    To rotate around a certain point you need to translate() into that point and then rotate()

    Cheers,
    _

  3. #3
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Rotate about point

    so if i have a triangle which is used like a needle in analog gauge and i want rotate only end of needle, the beginning of the needle must be in this same position. so if i want rotate needle i must use this:
    Qt Code:
    1. painter.translate(-80, 84);
    2. painter.rotate(20);
    To copy to clipboard, switch view to plain text mode 
    But then this triangle change his own position
    It should look something like this, only end of needle change position
    wgauge2.jpg

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.