PDA

View Full Version : Rotate about point



Andree
17th May 2014, 23:21
Hello,

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

I have a triangle, let's say like this



static const QPoint T[3] = {
QPoint(80, 80),
QPoint(80, 88),
QPoint(-80, 84)
};
painter.drawConvexPolygon(T, 3);



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.

anda_skoa
18th May 2014, 12:23
To rotate around a certain point you need to translate() into that point and then rotate()

Cheers,
_

Andree
18th May 2014, 13:44
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:


painter.translate(-80, 84);
painter.rotate(20);

But then this triangle change his own position
It should look something like this, only end of needle change position
10368