From 168ee430f4fdb064503a78f0754c4e6bf1a95507 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 21 Oct 2023 19:53:22 -0700 Subject: [PATCH] Quaternion self test fixed. The self-test expects a unit quaternion. The Quaternion vector<3> constructor uses the vector as-is, expecting it to be potentially the output from an existing Quaternion. MakeQuaternion is the right function for build a unit quaternion, so the self-test should actually use this. This error had been hidden due to building with NDEBUG, which ifdefs out the self-test. The code was probably changed during the refactoring process. --- src/scmp/Quaternion.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scmp/Quaternion.cc b/src/scmp/Quaternion.cc index be442ec..f816795 100644 --- a/src/scmp/Quaternion.cc +++ b/src/scmp/Quaternion.cc @@ -75,13 +75,13 @@ QuaternionSelfTest() Vector3F yAxis {0.0, 1.0, 0.0}; float angle = M_PI / 2; - Quaternionf p = quaternionf(yAxis, angle); + Quaternionf p = MakeQuaternion(yAxis, angle); Quaternionf q; Vector3F vr {0.0, 0.0, 1.0}; - assert(p.isUnitQuaternion()); - std::cerr << p.rotate(v) << std::endl; - assert(p.rotate(v) == vr); + p.SetEpsilon(0.0001); + assert(p.IsUnitQuaternion()); + assert(p.Rotate(v) == vr); assert(p * q == p); #endif }