summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2021-06-10 15:41:25 +0200
committerPaul Wicking <paul.wicking@qt.io>2021-06-25 17:30:47 +0200
commitae2ef9dbf060ba101e32bae2b5edfed979630e30 (patch)
treef673b41a1a1a9aaa3bd36617d13deff83f023718 /src/gui/painting
parentaf5f91fdf9edc96149fd2070c2b32985c5773778 (diff)
Doc: Improve QTransform documentation
* Explain QTransform's model of vector/matrix operations. * Improve snippets used to illuminate QTransform's behavior. Fixes: QTBUG-83869 Pick-to: 6.2 6.1 5.15 Change-Id: I84c3b1a221c139ee992f82c3ee4aebadeef8ee63 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qtransform.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 8f2dc21a21..7d057732c7 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -213,6 +213,7 @@ static void nanWarning(const char *func)
transformation is achieved by setting both the projection factors and
the scaling factors.
+ \section2 Combining Transforms
Here's the combined transformations example using basic matrix
operations:
@@ -223,6 +224,26 @@ static void nanWarning(const char *func)
\snippet transform/main.cpp 2
\endtable
+ The combined transform first scales each operand, then rotates it, and
+ finally translates it, just as in the order in which the product of its
+ factors is written. This means the point to which the transforms are
+ applied is implicitly multiplied on the left with the transform
+ to its right.
+
+ \section2 Relation to Matrix Notation
+ The matrix notation in QTransform is the transpose of a commonly-taught
+ convention which represents transforms and points as matrices and vectors.
+ That convention multiplies its matrix on the left and column vector to the
+ right. In other words, when several transforms are applied to a point, the
+ right-most matrix acts directly on the vector first. Then the next matrix
+ to the left acts on the result of the first operation - and so on. As a
+ result, that convention multiplies the matrices that make up a composite
+ transform in the reverse of the order in QTransform, as you can see in
+ \l {Combining Transforms}. Transposing the matrices, and combining them to
+ the right of a row vector that represents the point, lets the matrices of
+ transforms appear, in their product, in the order in which we think of the
+ transforms being applied to the point.
+
\sa QPainter, {Coordinate System}, {painting/affine}{Affine
Transformations Example}, {Transformations Example}
*/