equal
deleted
inserted
replaced
83 QMatrix provides the isIdentity() function which returns true if |
83 QMatrix provides the isIdentity() function which returns true if |
84 the matrix is the identity matrix, and the isInvertible() function |
84 the matrix is the identity matrix, and the isInvertible() function |
85 which returns true if the matrix is non-singular (i.e. AB = BA = |
85 which returns true if the matrix is non-singular (i.e. AB = BA = |
86 I). The inverted() function returns an inverted copy of \e this |
86 I). The inverted() function returns an inverted copy of \e this |
87 matrix if it is invertible (otherwise it returns the identity |
87 matrix if it is invertible (otherwise it returns the identity |
88 matrix). In addition, QMatrix provides the det() function |
88 matrix). In addition, QMatrix provides the determinant() function |
89 returning the matrix's determinant. |
89 returning the matrix's determinant. |
90 |
90 |
91 Finally, the QMatrix class supports matrix multiplication, and |
91 Finally, the QMatrix class supports matrix multiplication, and |
92 objects of the class can be streamed as well as compared. |
92 objects of the class can be streamed as well as compared. |
93 |
93 |
957 |
957 |
958 \sa inverted() |
958 \sa inverted() |
959 */ |
959 */ |
960 |
960 |
961 /*! |
961 /*! |
|
962 \obsolete |
962 \fn qreal QMatrix::det() const |
963 \fn qreal QMatrix::det() const |
|
964 |
|
965 Returns the matrix's determinant. |
|
966 |
|
967 \sa determinant() |
|
968 */ |
|
969 |
|
970 /*! |
|
971 \since 4.6 |
|
972 \fn qreal QMatrix::determinant() const |
963 |
973 |
964 Returns the matrix's determinant. |
974 Returns the matrix's determinant. |
965 */ |
975 */ |
966 |
976 |
967 /*! |
977 /*! |
983 \sa isInvertible() |
993 \sa isInvertible() |
984 */ |
994 */ |
985 |
995 |
986 QMatrix QMatrix::inverted(bool *invertible) const |
996 QMatrix QMatrix::inverted(bool *invertible) const |
987 { |
997 { |
988 qreal determinant = det(); |
998 qreal dtr = determinant(); |
989 if (determinant == 0.0) { |
999 if (dtr == 0.0) { |
990 if (invertible) |
1000 if (invertible) |
991 *invertible = false; // singular matrix |
1001 *invertible = false; // singular matrix |
992 return QMatrix(true); |
1002 return QMatrix(true); |
993 } |
1003 } |
994 else { // invertible matrix |
1004 else { // invertible matrix |
995 if (invertible) |
1005 if (invertible) |
996 *invertible = true; |
1006 *invertible = true; |
997 qreal dinv = 1.0/determinant; |
1007 qreal dinv = 1.0/dtr; |
998 return QMatrix((_m22*dinv), (-_m12*dinv), |
1008 return QMatrix((_m22*dinv), (-_m12*dinv), |
999 (-_m21*dinv), (_m11*dinv), |
1009 (-_m21*dinv), (_m11*dinv), |
1000 ((_m21*_dy - _m22*_dx)*dinv), |
1010 ((_m21*_dy - _m22*_dx)*dinv), |
1001 ((_m12*_dx - _m11*_dy)*dinv), |
1011 ((_m12*_dx - _m11*_dy)*dinv), |
1002 true); |
1012 true); |