From b8f30c5ad3c4cf5964f1363b227c8203b5272a88 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 15 Nov 2012 15:37:28 +0100 Subject: [PATCH] Fixed bug #11, added missing quat based epsilonEqual and epsilonNotEqual definitions --- glm/gtc/epsilon.inl | 30 ++++++++++++++++++++++++++++++ test/gtc/gtc_epsilon.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/glm/gtc/epsilon.inl b/glm/gtc/epsilon.inl index 85f7b171..754d1413 100644 --- a/glm/gtc/epsilon.inl +++ b/glm/gtc/epsilon.inl @@ -254,6 +254,21 @@ namespace glm abs(x.w - y.w) >= epsilon.w); } + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonEqual + ( + detail::tquat const & x, + detail::tquat const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) < epsilon, + abs(x.y - y.y) < epsilon, + abs(x.z - y.z) < epsilon, + abs(x.w - y.w) < epsilon); + } + template GLM_FUNC_QUALIFIER detail::tvec4 epsilonEqual ( @@ -269,6 +284,21 @@ namespace glm abs(x.w - y.w) < epsilon.w); } + template + GLM_FUNC_QUALIFIER detail::tvec4 epsilonNotEqual + ( + detail::tquat const & x, + detail::tquat const & y, + valType const & epsilon + ) + { + return detail::tvec4( + abs(x.x - y.x) >= epsilon, + abs(x.y - y.y) >= epsilon, + abs(x.z - y.z) >= epsilon, + abs(x.w - y.w) >= epsilon); + } + template GLM_FUNC_QUALIFIER detail::tvec4 epsilonNotEqual ( diff --git a/test/gtc/gtc_epsilon.cpp b/test/gtc/gtc_epsilon.cpp index 8ff810a6..85388f17 100644 --- a/test/gtc/gtc_epsilon.cpp +++ b/test/gtc/gtc_epsilon.cpp @@ -12,6 +12,32 @@ #include #include +int test_defined() +{ + glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2()); + glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3()); + glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4()); + glm::epsilonEqual(glm::quat(), glm::quat(), glm::quat()); + + glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2()); + glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3()); + glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4()); + glm::epsilonNotEqual(glm::quat(), glm::quat(), glm::quat()); + + + glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f); + glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f); + glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f); + glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f); + + glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f); + glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f); + glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f); + glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f); + + return 0; +} + template int test_equal() { @@ -54,6 +80,7 @@ int main() { int Error(0); + Error += test_defined(); Error += test_equal(); Error += test_equal(); Error += test_equal();