summaryrefslogtreecommitdiff
path: root/ucoo/math/test/test_math.cc
diff options
context:
space:
mode:
authorNicolas Schodet2015-12-23 10:52:43 +0100
committerNicolas Schodet2019-10-07 00:44:57 +0200
commitbd32e6457b51e4f3e94d6cd5af450695e97a36ef (patch)
tree09834a707674ebc135105900cd031cdd896346f2 /ucoo/math/test/test_math.cc
parent5a0c96b930c0dc9b14caea2557779e9a7bad8dfe (diff)
ucoo/math: add quaternion multiplication
Diffstat (limited to 'ucoo/math/test/test_math.cc')
-rw-r--r--ucoo/math/test/test_math.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/ucoo/math/test/test_math.cc b/ucoo/math/test/test_math.cc
index 4fb3f16..65be6e2 100644
--- a/ucoo/math/test/test_math.cc
+++ b/ucoo/math/test/test_math.cc
@@ -222,6 +222,20 @@ test_group_quaternion (ucoo::TestSuite &tsuite, const char *tname)
test_fail_break_unless (test, almost_eq_vect<T> (r, 1, 0, 0));
} while (0);
do {
+ ucoo::Test test (tsuite, "multiplication");
+ ucoo::Quaternion<T> q1 (ucoo::YawPitchRoll<T> (M_PI_2, 0, 0));
+ ucoo::Quaternion<T> q2 (ucoo::YawPitchRoll<T> (0, M_PI_2, 0));
+ ucoo::Quaternion<T> q3 (ucoo::YawPitchRoll<T> (0, 0, M_PI_2));
+ ucoo::Quaternion<T> q = q1 * q2 * q3;
+ ucoo::vect3d<T> r;
+ r = q.rotate (x);
+ test_fail_break_unless (test, almost_eq_vect<T> (r, 0, 0, -1));
+ r = q.rotate (y);
+ test_fail_break_unless (test, almost_eq_vect<T> (r, 0, 1, 0));
+ r = q.rotate (z);
+ test_fail_break_unless (test, almost_eq_vect<T> (r, 1, 0, 0));
+ } while (0);
+ do {
ucoo::Test test (tsuite, "yaw-pitch-roll to quaternion and back");
ucoo::YawPitchRoll<T> yprs[] = {
{ M_PI_4, 0, 0 },