summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/snippets/code/doc_src_qalgorithms.qdoc2
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp21
2 files changed, 18 insertions, 5 deletions
diff --git a/doc/src/snippets/code/doc_src_qalgorithms.qdoc b/doc/src/snippets/code/doc_src_qalgorithms.qdoc
index 69d943c89..e2126dd7b 100644
--- a/doc/src/snippets/code/doc_src_qalgorithms.qdoc
+++ b/doc/src/snippets/code/doc_src_qalgorithms.qdoc
@@ -302,7 +302,7 @@ list.clear();
QList<int> list;
list << 33 << 12 << 68 << 6 << 12;
qSort(list.begin(), list.end(), qLess<int>());
-// list: [ 68, 33, 12, 12, 6 ]
+// list: [ 6, 12, 12, 33, 68 ]
//! [24]
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index dc17eda50..8fc439be6 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1010,11 +1010,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
+ if (angle == 0.0f)
+ return *this;
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qreal a = angle * M_PI / 180.0f;
- qreal c = qCos(a);
- qreal s = qSin(a);
- qreal ic;
+ qreal c, s, ic;
+ if (angle == 90.0f || angle == -270.0f) {
+ s = 1.0f;
+ c = 0.0f;
+ } else if (angle == -90.0f || angle == 270.0f) {
+ s = -1.0f;
+ c = 0.0f;
+ } else if (angle == 180.0f || angle == -180.0f) {
+ s = 0.0f;
+ c = -1.0f;
+ } else {
+ qreal a = angle * M_PI / 180.0f;
+ c = qCos(a);
+ s = qSin(a);
+ }
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {