Browse Source

math: fix an error in the quaternion code and update test suite.

undefined
Sam Hocevar 11 years ago
parent
commit
e848af3f2a
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      src/lol/math/vector.h
  2. +3
    -3
      test/unit/quat.cpp

+ 2
- 2
src/lol/math/vector.h View File

@@ -1006,13 +1006,13 @@ template <typename T> struct Quat
template<typename T> template<typename T>
inline T norm(Quat<T> const &val) inline T norm(Quat<T> const &val)
{ {
return sqlength(val);
return length(val);
} }


template<typename T> template<typename T>
static inline Quat<T> re(Quat<T> const &val) static inline Quat<T> re(Quat<T> const &val)
{ {
return ~val / norm(val);
return ~val / sqlength(val);
} }


template<typename T> template<typename T>


+ 3
- 3
test/unit/quat.cpp View File

@@ -67,14 +67,14 @@ LOLUNIT_FIXTURE(QuaternionTest)
{ {
quat a(2.f, -2.f, -8.f, 3.f); 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 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); 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)); LOLUNIT_ASSERT_EQUAL(norm(a * d), norm(a) * norm(d));
} }


Loading…
Cancel
Save