summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-02-26 17:46:14 +0400
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-03-05 10:46:07 +0000
commita5d5353b59ab7eb41d37048064f46490f98a228a (patch)
tree4783dfbb5b98c6acf87d28985cdb2d1042bc083e /tests
parent6c973dee2cb1686ea32657fff7dced3e611b98ce (diff)
Introduce QQuaternion::dotProduct()
Change-Id: I14b9857ca0a43808b7d536fc258a6bb10f611211 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index ed93ff24b0..e358937a62 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -45,6 +45,9 @@ public:
private slots:
void create();
+ void dotProduct_data();
+ void dotProduct();
+
void length_data();
void length();
@@ -219,6 +222,58 @@ void tst_QQuaternion::create()
QCOMPARE(v10.w(), 34.0f);
}
+// Test the computation of dot product.
+void tst_QQuaternion::dotProduct_data()
+{
+ QTest::addColumn<float>("x1");
+ QTest::addColumn<float>("y1");
+ QTest::addColumn<float>("z1");
+ QTest::addColumn<float>("scalar1");
+ QTest::addColumn<float>("x2");
+ QTest::addColumn<float>("y2");
+ QTest::addColumn<float>("z2");
+ QTest::addColumn<float>("scalar2");
+ QTest::addColumn<float>("dot");
+
+ QTest::newRow("null")
+ << 0.0f << 0.0f << 0.0f << 0.0f
+ << 0.0f << 0.0f << 0.0f << 0.0f
+ << 0.0f;
+
+ QTest::newRow("identity")
+ << 0.0f << 0.0f << 0.0f << 1.0f
+ << 0.0f << 0.0f << 0.0f << 1.0f
+ << 1.0f;
+
+ QTest::newRow("unitvec")
+ << 1.0f << 0.0f << 0.0f << 0.0f
+ << 0.0f << 1.0f << 0.0f << 0.0f
+ << 0.0f;
+
+ QTest::newRow("complex")
+ << 1.0f << 2.0f << 3.0f << 4.0f
+ << 4.0f << 5.0f << 6.0f << 7.0f
+ << 60.0f;
+}
+void tst_QQuaternion::dotProduct()
+{
+ QFETCH(float, x1);
+ QFETCH(float, y1);
+ QFETCH(float, z1);
+ QFETCH(float, scalar1);
+ QFETCH(float, x2);
+ QFETCH(float, y2);
+ QFETCH(float, z2);
+ QFETCH(float, scalar2);
+ QFETCH(float, dot);
+
+ QQuaternion q1(scalar1, x1, y1, z1);
+ QQuaternion q2(scalar2, x2, y2, z2);
+
+ QCOMPARE(QQuaternion::dotProduct(q1, q2), dot);
+ QCOMPARE(QQuaternion::dotProduct(q2, q1), dot);
+}
+
// Test length computation for quaternions.
void tst_QQuaternion::length_data()
{