From e848af3f2adb04f01cf083ff2ef6970e15cab08a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 26 Aug 2013 11:46:47 +0000 Subject: [PATCH] math: fix an error in the quaternion code and update test suite. --- src/lol/math/vector.h | 4 ++-- test/unit/quat.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index c2b6e093..46f4fe0a 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -1006,13 +1006,13 @@ template struct Quat template inline T norm(Quat const &val) { - return sqlength(val); + return length(val); } template static inline Quat re(Quat const &val) { - return ~val / norm(val); + return ~val / sqlength(val); } template diff --git a/test/unit/quat.cpp b/test/unit/quat.cpp index 050b5f63..e6993561 100644 --- a/test/unit/quat.cpp +++ b/test/unit/quat.cpp @@ -67,14 +67,14 @@ LOLUNIT_FIXTURE(QuaternionTest) { quat a(2.f, -2.f, -8.f, 3.f); - LOLUNIT_ASSERT_EQUAL(norm(a), 81.f); + LOLUNIT_ASSERT_EQUAL(norm(a), 9.f); quat b = a * ~a; - quat c(norm(a), 0.f, 0.f, 0.f); + quat c(norm(a) * norm(a), 0.f, 0.f, 0.f); LOLUNIT_ASSERT_EQUAL(b, c); - quat d(2.f, 3.f, -4.f, -1.f); + quat d(2.f, 5.f, -4.f, -2.f); LOLUNIT_ASSERT_EQUAL(norm(a * d), norm(a) * norm(d)); }