From 197d78454989fae9df839f2ca0c407464c622355 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 00:27:52 +0100 Subject: [PATCH 1/6] Fixed quat mix build --- glm/gtc/quaternion.hpp | 7 ++++++- glm/gtc/quaternion.inl | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index f6238ccd..949f08f7 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -74,6 +74,11 @@ namespace detail detail::tquat operator- ( detail::tquat const & q); + template + detail::tquat operator+ ( + detail::tquat const & q, + detail::tquat const & p); + template detail::tquat operator* ( detail::tquat const & q, @@ -154,7 +159,7 @@ namespace quaternion ///< GLM_GTC_quaternion extension: Quaternion types and fun detail::tquat mix( detail::tquat const & x, detail::tquat const & y, - typename detail::tquat::value_type const & a); + T const & a); //! Returns the q conjugate. //! From GLM_GTC_quaternion extension. diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 27a5c541..e262c663 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -156,6 +156,20 @@ namespace detail{ return detail::tquat(-q.w, -q.x, -q.y, -q.z); } + template + GLM_FUNC_QUALIFIER detail::tquat operator+ + ( + detail::tquat const & q, + detail::tquat const & p + ) + { + return detail::tquat( + q.w + p.w, + q.x + p.x, + q.y + p.y, + q.z + p.z); + } + template GLM_FUNC_QUALIFIER detail::tquat operator* ( From f87def17de5dbd74a82057f64bbd77f0717ae90d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 00:31:58 +0100 Subject: [PATCH 2/6] Fixed tests --- glm/gtc/quaternion.inl | 14 -------------- test/gtc/gtc_quaternion.cpp | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index df92920a..e262c663 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -147,20 +147,6 @@ namespace detail{ ////////////////////////////////////////////////////////////// // tquat external operators - template - GLM_FUNC_QUALIFIER detail::tquat operator* - ( - detail::tquat const & q, - detail::tquat const & p - ) - { - return detail::tquat( - q.w + p.w, - q.x + p.x, - q.y + p.y, - q.z + p.z); - } - template GLM_FUNC_QUALIFIER detail::tquat operator- ( diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 689cfe27..00ed0503 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -27,7 +27,7 @@ int test_quat_slerp() glm::quat B(90.0f, glm::vec3(0, 0, 1)); glm::quat C = glm::mix(A, B, 0.5f); - Error += C != glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1; + Error += C == glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1; return Error; } From 2305e6b2f07027201ab5d10bdebb3f90f30c3731 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 00:36:59 +0100 Subject: [PATCH 3/6] Removed test messages for dev left behind... --- glm/core/setup.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 329a8e22..01075f3c 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -135,13 +135,10 @@ // G++ #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) # if defined (__llvm__) -# pragma message("LLVM") # define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_LLVM # elif defined (__clang__) -# pragma message("CLANG") # define GLM_COMPILER_GCC_EXTRA GLM_COMPILER_GCC_CLANG # else -# pragma message("GCC") # define GLM_COMPILER_GCC_EXTRA 0 # endif # From 6128d643eb1eea90deb861ed2f93a33dfdf337bc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 00:46:05 +0100 Subject: [PATCH 4/6] Added missing types declarations --- glm/gtc/half_float.hpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/glm/gtc/half_float.hpp b/glm/gtc/half_float.hpp index ab3a1daa..31396ee9 100644 --- a/glm/gtc/half_float.hpp +++ b/glm/gtc/half_float.hpp @@ -343,7 +343,7 @@ namespace half_float ///< GLM_GTC_half_float extension: Add support for half pre /// 2 * 2 matrix of half-precision floating-point numbers. /// From GLM_GTC_half_float extension. typedef detail::tmat2x2 hmat2; - + /// 3 * 3 matrix of half-precision floating-point numbers. /// From GLM_GTC_half_float extension. typedef detail::tmat3x3 hmat3; @@ -352,6 +352,42 @@ namespace half_float ///< GLM_GTC_half_float extension: Add support for half pre /// From GLM_GTC_half_float extension. typedef detail::tmat4x4 hmat4; + /// 2 * 2 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat2x2 hmat2x2; + + /// 2 * 3 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat2x3 hmat2x3; + + /// 2 * 4 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat2x4 hmat2x4; + + /// 3 * 2 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat3x2 hmat3x2; + + /// 3 * 3 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat3x3 hmat3x3; + + /// 3 * 4 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat3x4 hmat3x4; + + /// 4 * 2 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat4x2 hmat4x2; + + /// 4 * 3 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat4x3 hmat4x3; + + /// 4 * 4 matrix of half-precision floating-point numbers. + /// From GLM_GTC_half_float extension. + typedef detail::tmat4x4 hmat4x4; + /// @} }// namespace half_float From e4a52432ff624952664af05d62ea46ff62e02464 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 10:26:38 +0100 Subject: [PATCH 5/6] Fixed ticket #103: doc typo --- doc/gtxModules.doxy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/gtxModules.doxy b/doc/gtxModules.doxy index 8df24c9c..d585cf8b 100644 --- a/doc/gtxModules.doxy +++ b/doc/gtxModules.doxy @@ -452,7 +452,7 @@ **/ /*! - \defgroup gtx_vector_access GLM_GTX_vector_angle: Vector access + \defgroup gtx_vector_access GLM_GTX_vector_access: Vector access \ingroup gtx \brief Function to set values to vectors From c9b7b712fb39eb8e99e3ac99ea08f289e36c1ba9 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 27 May 2011 16:34:20 +0100 Subject: [PATCH 6/6] Fixed angle implementation --- glm/gtx/quaternion.inl | 2 +- test/gtc/gtc_quaternion.cpp | 9 +++++---- test/gtx/gtx_quaternion.cpp | 30 ++++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index aaf07171..ec713c8d 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -149,7 +149,7 @@ namespace quaternion detail::tquat const & x ) { - return acos(x.w) * T(2); + return glm::degrees(acos(x.w) * T(2)); } template diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 00ed0503..7bd07c07 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -23,11 +23,12 @@ int test_quat_slerp() { int Error = 0; - glm::quat A(0.0f, glm::vec3(0, 0, 1)); - glm::quat B(90.0f, glm::vec3(0, 0, 1)); + glm::quat A(glm::vec3(0, 0, 1)); + glm::quat B(glm::vec3(0, 1, 0)); glm::quat C = glm::mix(A, B, 0.5f); - - Error += C == glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1; + glm::quat D(glm::normalize(glm::vec3(0, 1, 1))); + + Error += C == D ? 0 : 1; return Error; } diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index 241f572c..c498a0fb 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -11,31 +11,48 @@ #include #include +int test_quat_angleAxis() +{ + int Error = 0; + + glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); + glm::quat B = glm::angleAxis(90.0f, glm::vec3(0, 0, 1)); + glm::quat C = glm::mix(A, B, 0.5f); + glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + + Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1; + + return Error; +} + int test_quat_angle() { int Error = 0; { - glm::quat Q(45.0f, glm::vec3(0, 0, 1)); + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); glm::quat N = glm::normalize(Q); float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; } { - glm::quat Q(45.0f, glm::vec3(0, 0, 2)); + glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1))); glm::quat N = glm::normalize(Q); float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; } { - glm::quat Q(45.0f, glm::vec3(1, 2, 3)); + glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3))); glm::quat N = glm::normalize(Q); float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; } @@ -48,6 +65,7 @@ int main() int Error = 0; Error += test_quat_angle(); + Error += test_quat_angleAxis(); return Error; }