| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 3 | |
Hi , What is the conceptual difference between translation and rotation the in the context of QGraphicsItem ? The documentation is silent of the difference, but they seem to have different effects when transforming QGraphicsItems... Thnx Prateek
On Tuesday 12 June 2007, Prateek Tiwari wrote: > What is the conceptual difference between translation and rotation the > in the context of QGraphicsItem ? There are three basic graphics-operations: translation -> move an item from point A to point B rotation -> turn the item around the center point (0,0) of the coordinate system scaling -> make the item bigger or smaller All other operations are usually composed of those. Konrad
Attachment:
Attachment:
pgpZt7Aft3Rkq.pgp
Description: PGP signature
Message 3 in thread
OOPS !! I meant difference between translation and move.
Sorry for the typo.
Both operations look similar but there is a difference when we combine
translation/move with rotation.
Thnx
Prateek
-----Original Message-----
From: Konrad Rosenbaum [mailto:konrad@xxxxxxxxx]
Sent: Tuesday, June 12, 2007 11:42 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Translation Vs Rotation ?
On Tuesday 12 June 2007, Prateek Tiwari wrote:
> What is the conceptual difference between translation and rotation the
> in the context of QGraphicsItem ?
There are three basic graphics-operations:
translation -> move an item from point A to point B
rotation -> turn the item around the center point (0,0) of the
coordinate system
scaling -> make the item bigger or smaller
All other operations are usually composed of those.
Konrad
--
[ signature omitted ]
Message 4 in thread
<html><div style='background-color:'><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">
<P>
<HR color=#a0c6e5 SIZE=1>
</P>
<P><BR>>OOPS !! I meant difference between translation and move.<BR>>Sorry for the typo.<BR>><BR>>Both operations look similar but there is a difference when we combine<BR>>translation/move with rotation.<BR>><BR>>Thnx<BR>>Prateek<BR></P>
<P>According to the documentation its a conceptual difference.</P>
<P>A translation is a transformation often expressed by a transformation matrix. Actually this seems to be the case hereas well. When you translate a QGraphicsItem its transformation matrix will be modified and the item will be displayed accordingly.</P>
<P>A moveBy() changes the original position of the item.</P>
<P> </P>
<P>I might be a little speculative here but it seems to me that if you translate an item, its position pos() wont be changed. If you move it it will be changed. Nevertheless if you display an item a simpel moveBy() and a translation() have the same visual effects. If its true though what i said about the position (which you can easily test), then a moveBy should be a little more efficient as there is no matrix calculation.</P></FONT></div><br clear=all><hr>Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig im Web, Ihren E-Mails und auf Ihrem PC! - <a href="http://g.msn.com/8HMBDEDE/2743??PS=47575" target="_top">Hier kostenlos downloaden!</a> </html>
--
[ signature omitted ]
Message 5 in thread
Yup. You are correct Bastian. On translation, the position pos() does
not change.
But since it has the same visual effect as moveBy(), I wonder why dosent
translate change the position of the
item as well ? Why would one want to "move" an item and not change its
position ?
In that sense, If an application is a canvas application and needs to
keep track of the positions of the
items, is translate() is safe function to use ?
As I understand, translate() should be used only if you would be
translating the item back to its original position, such as if one wants
to rotate/scale an item from any other point except the origin. Am I
correct ?
Is there are other place where one needs the translate function ?
Thnx
Prateek
________________________________
From: Bastian Dittmar [mailto:keulerman@xxxxxxxxxxx]
Sent: Tuesday, June 12, 2007 1:02 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: RE: Translation Vs Rotation ?
________________________________
>OOPS !! I meant difference between translation and move.
>Sorry for the typo.
>
>Both operations look similar but there is a difference when we
combine
>translation/move with rotation.
>
>Thnx
>Prateek
According to the documentation its a conceptual difference.
A translation is a transformation often expressed by a
transformation matrix. Actually this seems to be the case hereas well.
When you translate a QGraphicsItem its transformation matrix will be
modified and the item will be displayed accordingly.
A moveBy() changes the original position of the item.
I might be a little speculative here but it seems to me that if
you translate an item, its position pos() wont be changed. If you move
it it will be changed. Nevertheless if you display an item a simpel
moveBy() and a translation() have the same visual effects. If its true
though what i said about the position (which you can easily test), then
a moveBy should be a little more efficient as there is no matrix
calculation.
________________________________
Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie
gleichzeitig im Web, Ihren E-Mails und auf Ihrem PC! - Hier kostenlos
downloaden! <http://g.msn.com/8HMBDEDE/2743??PS=47575> -- To
unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body. List archive and information:
http://lists.trolltech.com/qt-interest/
Message 6 in thread
>Yup. You are correct Bastian. On translation, the position pos() does
>not change.
>But since it has the same visual effect as moveBy(), I wonder why dosent
>translate change the position of the
>item as well ? Why would one want to "move" an item and not change its
>position ?
>In that sense, If an application is a canvas application and needs to
>keep track of the positions of the
>items, is translate() is safe function to use ?
>As I understand, translate() should be used only if you would be
>translating the item back to its original position, such as if one wants
>to rotate/scale an item from any other point except the origin. Am I
>correct ?
>
>Is there are other place where one needs the translate function ?
>
>Thnx
>Prateek
>
>
You kind of answered your questions by yourself with what you said in the
end :)
When you move an item to a new position it can be seen as a transformation
of the item which translated it by some offset sx and sy (in 2D). Because an
item might be often moved there is a function moveBy which is a more
efficient than the actual transformation. That raises the question why not
discarding translate as moveBY is more efficient...
well translate is more powerfull. Most complex transformations can be
divided into simpler operations as you already said, first translate,
rotate, ... All of them are expressed by a transformation matrix. The
beauty fo this is, that you can simply multiply the matrices to yield the
matrix for the complex transformation. This wouldnt work if you used moveBY
instead. You would need a single matrix for each accumulated transformation
until a translation occurs as it directly modifies the item.
What you said is actually a great example. If you wanan have a different
rotation point than your item's origin you translate it, rotate and
translate back. At the end you have only ONE matrix that expresses the whole
transformation!!! If you would move it insteda of translation this would be
way less effecient. Of course there are other complex transformations as
well that need a translation.
If you wanna keep track of your item's position it depends on how you do it
i guess. I havent worked with QGraphicsView and QGraphicsItem yet. If you
are moving items from one point to another i would definately use moveBy()
and setPos() and to keep track i would use pos().
Sorry cant help you more with your main problem :(
_________________________________________________________________
Haben Spinnen Ohren? Finden Sie es heraus ? mit dem MSN Suche Superquiz via
http://www.msn-superquiz.de Jetzt mitmachen und gewinnen!
--
[ signature omitted ]