summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/math3d
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/math3d')
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index ecf8fbfefe..c4cad91006 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -83,6 +83,9 @@ private slots:
void fromAxisAndAngle_data();
void fromAxisAndAngle();
+ void fromRotationMatrix_data();
+ void fromRotationMatrix();
+
void slerp_data();
void slerp();
@@ -725,6 +728,25 @@ void tst_QQuaternion::fromAxisAndAngle()
QVERIFY(qFuzzyCompare(answer.scalar(), result.scalar()));
}
+// Test quaternion convertion to and from rotation matrix.
+void tst_QQuaternion::fromRotationMatrix_data()
+{
+ fromAxisAndAngle_data();
+}
+void tst_QQuaternion::fromRotationMatrix()
+{
+ QFETCH(float, x1);
+ QFETCH(float, y1);
+ QFETCH(float, z1);
+ QFETCH(float, angle);
+
+ QQuaternion result = QQuaternion::fromAxisAndAngle(QVector3D(x1, y1, z1), angle);
+ QMatrix3x3 rot3x3 = result.toRotationMatrix();
+ QQuaternion answer = QQuaternion::fromRotationMatrix(rot3x3);
+
+ QVERIFY(qFuzzyCompare(answer, result) || qFuzzyCompare(-answer, result));
+}
+
// Test spherical interpolation of quaternions.
void tst_QQuaternion::slerp_data()
{