summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-01-26 11:37:45 +0400
committerSean Harmer <sean.harmer@kdab.com>2015-01-28 12:37:52 +0000
commit6ef40175e50599a9c19d25cd1e2d3a658a61b494 (patch)
tree175a01ba84fa9cfec5051ac37c640ddfeb16ed92 /src/gui/math3d
parent14419b0a2b63c774e11dec10967495b19540bbb3 (diff)
Introduce QMatrix4x4::isAffine()
- a convenience method thats checks if the matrix has no projective coefficients. Change-Id: Ieea8ac2e4237b471a683ad5010672b1e89a0c953 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/math3d')
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp12
-rw-r--r--src/gui/math3d/qmatrix4x4.h7
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index c8a036918c..2fa31b5b14 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -290,6 +290,18 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
*/
/*!
+ \fn bool QMatrix4x4::isAffine() const
+ \since 5.5
+
+ Returns \c true if this matrix is affine matrix; false otherwise.
+
+ An affine matrix is a 4x4 matrix with row 3 equal to (0, 0, 0, 1),
+ e.g. no projective coefficients.
+
+ \sa isIdentity()
+*/
+
+/*!
\fn bool QMatrix4x4::isIdentity() const
Returns \c true if this matrix is the identity; false otherwise.
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 31a4dbf1ca..74329b7cdd 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -77,6 +77,8 @@ public:
inline void setRow(int index, const QVector4D& value);
#endif
+ inline bool isAffine() const;
+
inline bool isIdentity() const;
inline void setToIdentity();
@@ -302,6 +304,11 @@ inline void QMatrix4x4::setRow(int index, const QVector4D& value)
Q_GUI_EXPORT QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor);
+inline bool QMatrix4x4::isAffine() const
+{
+ return m[0][3] == 0.0f && m[1][3] == 0.0f && m[2][3] == 0.0f && m[3][3] == 1.0f;
+}
+
inline bool QMatrix4x4::isIdentity() const
{
if (flagBits == Identity)