[Qt-interest] QTransform SRT order

Anton Chernov mechernov at gmail.com
Sat Jun 4 12:51:08 CEST 2011


>From qgraphicsitem_p.h

QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const

    {

        if (onlyTransform) {

            if (!postmultiplyTransform || postmultiplyTransform->isIdentity())

                return transform;

            if (transform.isIdentity())

                return *postmultiplyTransform;

            return transform * *postmultiplyTransform;

        }

        QTransform x(transform);

        if (!graphicsTransforms.isEmpty()) {

            QMatrix4x4 m;

            for (int i = 0; i < graphicsTransforms.size(); ++i)

                graphicsTransforms.at(i)->applyTo(&m);

            x *= m.toTransform();

        }

        x.translate(xOrigin, yOrigin);

        x.rotate(rotation);

        x.scale(scale, scale);

        x.translate(-xOrigin, -yOrigin);

        if (postmultiplyTransform)

            x *= *postmultiplyTransform;

        return x;

    }


2011/6/3 Malyushytsky, Alex <alex at wai.com>

> >>doesn't matter what order the
> QTransform::scale(), QTransform::rotate(), and QTransform::translate()
> functions are called in, does it?
>
> Yes it does.
> It uses matrix operation and stores transformation matrix.
> http://doc.qt.nokia.com/latest/qtransform.html#basic-matrix-operations
>
> Think it this way if you move rectangle from the center of the origin along
> x axis and rotate it
> 45 degrees around origin will not be equal to rotating it first and then
> moving.
>
>    Alex
>
>
> -----Original Message-----
> From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:
> qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of Joshua Grauman
> Sent: Friday, June 03, 2011 10:13 AM
> To: qt-interest at qt.nokia.com
> Subject: [Qt-interest] QTransform SRT order
>
> Hello all,
>
> I am using QTransform to Scale, Rotate, and Translate an image. I was
> wondering about the order of these operations. I'm assuming that
> QTransform operates in the order of: Scale, then Rotate, then Translate.
> Can anyone confirm this? It doesn't matter what order the
> QTransform::scale(), QTransform::rotate(), and QTransform::translate()
> functions are called in, does it? Thanks!
>
> Josh
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> “This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments. Thank you.”
>
> “Please consider our environment before printing this email.”
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110604/9343b5c0/attachment.html 


More information about the Qt-interest-old mailing list