From 8bbbbfcafda418b47cf463c72568a8a84c90207f Mon Sep 17 00:00:00 2001 From: thechosenone124 Date: Wed, 30 May 2018 23:36:37 -0700 Subject: [PATCH 1/3] Intermediate Function Is Improperly Done The formula for calculating the intermediate for a SQUAD interpolation is exp((log(next * invQuat) + log(prev * invQuat)) / static_cast(-4)) * curr; The current code uses addition instead of multiplication (based on http://web.mit.edu/2.998/www/QuaternionReport1.pdf) --- glm/gtx/quaternion.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index fde7a8fb..e2aa5102 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -45,7 +45,7 @@ namespace glm ) { tquat invQuat = inverse(curr); - return exp((log(next + invQuat) + log(prev + invQuat)) / static_cast(-4)) * curr; + return exp((log(next * invQuat) + log(prev * invQuat)) / static_cast(-4)) * curr; } template From aa1728cde2dfc7d0f658227808c0cdb81f72efab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 1 Jun 2018 02:27:55 +0200 Subject: [PATCH 2/3] Make to_string(dualquat) actually work. It segfaulted somewhere deep in strlen() due to a mismatch in printf() argument count. --- glm/gtx/string_cast.inl | 1 + test/gtx/gtx_string_cast.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index e237e8e5..09e4c5c6 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -467,6 +467,7 @@ namespace detail char const * LiteralStr = literal::is_iec559>::value(); std::string FormatStr(detail::format("%sdualquat((%s, {%s, %s, %s}), (%s, {%s, %s, %s}))", PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr)); return detail::format(FormatStr.c_str(), diff --git a/test/gtx/gtx_string_cast.cpp b/test/gtx/gtx_string_cast.cpp index 9cfa48f6..e77c246b 100644 --- a/test/gtx/gtx_string_cast.cpp +++ b/test/gtx/gtx_string_cast.cpp @@ -129,12 +129,24 @@ int test_string_cast_quaternion() } +int test_string_cast_dual_quaternion() +{ + int Error = 0; + + glm::dualquat Q0 = glm::dualquat({1.0f, 2.0f, 3.0f, 4.0f}, {5.0f, 6.0f, 7.0f, 8.0f}); + std::string S0 = glm::to_string(Q0); + Error += S0 != std::string("dualquat((1.000000, {2.000000, 3.000000, 4.000000}), (5.000000, {6.000000, 7.000000, 8.000000}))") ? 1 : 0; + + return Error; +} + int main() { int Error = 0; Error += test_string_cast_vector(); Error += test_string_cast_matrix(); Error += test_string_cast_quaternion(); + Error += test_string_cast_dual_quaternion(); return Error; } From 89420dd1f5fdb618be94a7ac46794d6d009c9f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 1 Jun 2018 12:01:25 +0200 Subject: [PATCH 3/3] Make the to_string(dualquat) test work under C++03. I forgot this is still a thing, sorry. --- test/gtx/gtx_string_cast.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gtx/gtx_string_cast.cpp b/test/gtx/gtx_string_cast.cpp index e77c246b..2b7bb125 100644 --- a/test/gtx/gtx_string_cast.cpp +++ b/test/gtx/gtx_string_cast.cpp @@ -133,7 +133,7 @@ int test_string_cast_dual_quaternion() { int Error = 0; - glm::dualquat Q0 = glm::dualquat({1.0f, 2.0f, 3.0f, 4.0f}, {5.0f, 6.0f, 7.0f, 8.0f}); + glm::dualquat Q0 = glm::dualquat(glm::quat(1.0f, 2.0f, 3.0f, 4.0f), glm::quat(5.0f, 6.0f, 7.0f, 8.0f)); std::string S0 = glm::to_string(Q0); Error += S0 != std::string("dualquat((1.000000, {2.000000, 3.000000, 4.000000}), (5.000000, {6.000000, 7.000000, 8.000000}))") ? 1 : 0;