English 中文(简体)
2. 确定调任QPolygon的正确来源 页: 1
原标题:Determining the correct origin to rotate a QPolygonF around

Edit: 增加更多信息。

我愿轮流使用<条码>QPolygonF。 a. 来源如下:

“blocktations”/

象这个多功能(图像中心是来源——<代码>0, 0):

https://i.stack.imgur.com/08ImV.png” alt=“first polygon”/>

To rotate clockwise so that it ends up here:

“entergraph

www.un.org/Depts/DGACM/index_french.htm 上面图象中第一组位置相同:

QPolygonF p1 =  QPolygonF() << QPointF(0, 1) << QPointF(4, 1) << QPointF(4, 2) << QPointF(0, 2);

接着,我轮值了我认为正确的来源(2, 2):

QTransform t;
t.translate(2, 2);
t.rotate(-90);
t.translate(-2, -2);
QPolygonF p2 = t.map(p1);
qDebug() << p1 << "rotated = " << p2;

产出:

QPolygonF(QPointF(0, 1) QPointF(4, 1) QPointF(4, 2) QPointF(0, 2) ) rotated =  QPolygonF(QPointF(1, 4) QPointF(1, 0) QPointF(2, 0) QPointF(2, 4) )

当我想要的产出是:

QPolygonF(QPointF(0, 1) QPointF(4, 1) QPointF(4, 2) QPointF(0, 2) ) rotated =  QPolygonF(QPointF(2, 0) QPointF(3, 0) QPointF(3, 4) QPointF(2, 4) )

但是,根据上述产出,多角将最终考虑:

“wrong的轮调”/

在什么时候,我应轮流?

最佳回答

<><>Edit>>

在阐述你之后,我知道实现这一点的正确守则:

QTransform t; 
t.translate(2, 2); 
t.rotate(90); 
t.translate(-2, -2); 
QPolygonF p2 = t.map(p1); 
qDebug() << p1 << "rotated = " << p2;

这将使问题更加棘手:

QPolygonF(QPointF(3, 0) QPointF(3, 4) QPointF(2, 4) QPointF(2, 0) )

这正是你所期望的(尽管由于轮换而改变次序)。 值得注意的是,<代码>rotate(90)和rotate(-90)与你轮流使用直径,而不是middle

接受QT tranforms

Some confusion may arise because of the direction of the qt rotate function. Although this will enact a counter clockwise rotation, because we "see" the y-axis inverted (at least in this case) it appears clockwise to us.

As an analogy if I m in a room and observer a lamp falling over to the left, from the point of view of someone hanging on the cieling it has "fallen over" to the right.

问题回答

我只是简短的眼光,但我认为这是错误的:

t.translate(2, 2);

To obtain your transformation should be:

t.translate(2, 1);

从我的理解看, rec子的下限为1。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签