From 7ff95df5e6791d2dd039df0fe936deafd3c0eba1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 6 Dec 2011 12:22:43 +0000 Subject: [PATCH] Fixed ticket #153, vector and matrix queries --- doc/src/data.xml | 46 +++++++++++++++++++++++++++++++++++ glm/gtx/matrix_query.inl | 6 ++--- glm/gtx/vector_query.hpp | 16 ------------ glm/gtx/vector_query.inl | 31 +++-------------------- readme.txt | 3 ++- test/gtx/gtx_matrix_query.cpp | 21 ++++++++++++++++ test/gtx/gtx_vector_query.cpp | 46 ++++++++++++++++++++++++++++++----- 7 files changed, 115 insertions(+), 54 deletions(-) diff --git a/doc/src/data.xml b/doc/src/data.xml index e0d61a29..99b48b52 100644 --- a/doc/src/data.xml +++ b/doc/src/data.xml @@ -4,6 +4,7 @@
+ @@ -72,6 +73,7 @@
+ @@ -166,6 +168,50 @@ + + + GLM 0.9.3 is making progress which is illustrated by the release of this first alpha. + + + + Improved doxygen documentation + + + Added new swizzle operators for C++11 compilers + + + Added new swizzle operators declared as functions + + + Added GLSL 4.20 length for vector and matrix types + + + Added GLSL core noise functions + + + Promoted GLM_GTC_noise extension: simplex, perlin, periodic noise functions + + + Promoted GLM_GTC_random extension: linear, gaussian and various random number generation distribution + + + Added GLM_GTX_constants: provides usefull constants + + + Fixed half based type contructors + + + + + + + GLM 0.9.3.B (zip) + GLM 0.9.3.B (7z) + Submit a bug report + GLM 0.9.3 Manual + GLM 0.9.3 API + + GLM 0.9.3 is making progress which is illustrated by the release of this first alpha. diff --git a/glm/gtx/matrix_query.inl b/glm/gtx/matrix_query.inl index 3200ee14..647c9677 100644 --- a/glm/gtx/matrix_query.inl +++ b/glm/gtx/matrix_query.inl @@ -58,13 +58,13 @@ namespace glm ) { bool result = true; - for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i) + for(typename genType::size_type i = typename genType::size_type(0); result && i < genType::col_size(); ++i) { - for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j) + for(typename genType::size_type j = typename genType::size_type(0); result && j < i ; ++j) result = abs(m[i][j]) <= epsilon; if(result) result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon; - for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j) + for(typename genType::size_type j = i + typename genType::size_type(1); result && j < genType::row_size(); ++j) result = abs(m[i][j]) <= epsilon; } return result; diff --git a/glm/gtx/vector_query.hpp b/glm/gtx/vector_query.hpp index dace1770..e200a2ab 100644 --- a/glm/gtx/vector_query.hpp +++ b/glm/gtx/vector_query.hpp @@ -60,14 +60,6 @@ namespace glm genType const & v1, typename genType::value_type const & epsilon/* = std::numeric_limits::epsilon()*/); - //! Check whether two vectors are opposites. - //! From GLM_GTX_vector_query extensions. - template - bool areOpposite( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon/* = std::numeric_limits::epsilon()*/); - //! Check whether two vectors are orthogonals. //! From GLM_GTX_vector_query extensions. template @@ -112,14 +104,6 @@ namespace glm genType const & v1, typename genType::value_type const & epsilon/* = std::numeric_limits::epsilon()*/); - //! Check whether two vectors are similar. - //! From GLM_GTX_vector_query extensions. - template - bool areSimilar( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon/* = std::numeric_limits::epsilon()*/); - /// @} }// namespace glm diff --git a/glm/gtx/vector_query.inl b/glm/gtx/vector_query.inl index 01834696..dc92896d 100644 --- a/glm/gtx/vector_query.inl +++ b/glm/gtx/vector_query.inl @@ -19,7 +19,7 @@ namespace glm ( detail::tvec2 const & v0, detail::tvec2 const & v1, - T const & epsilon + typename detail::tvec2::value_type const & epsilon ) { return length(cross(detail::tvec3(v0, T(0)), detail::tvec3(v1, T(0)))) < epsilon; @@ -30,7 +30,7 @@ namespace glm ( detail::tvec3 const & v0, detail::tvec3 const & v1, - T const & epsilon + typename detail::tvec3::value_type const & epsilon ) { return length(cross(v0, v1)) < epsilon; @@ -41,24 +41,12 @@ namespace glm ( detail::tvec4 const & v0, detail::tvec4 const & v1, - T const & epsilon + typename detail::tvec4::value_type const & epsilon ) { return length(cross(detail::tvec3(v0), detail::tvec3(v1))) < epsilon; } - template - GLM_FUNC_QUALIFIER bool areOpposite - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - assert(isNormalized(v0) && isNormalized(v1)); - return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon); - } - template GLM_FUNC_QUALIFIER bool areOrthogonal ( @@ -173,17 +161,4 @@ namespace glm return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); } - template - GLM_FUNC_QUALIFIER bool areSimilar - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - bool similar = true; - for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++) - similar = (abs(v0[i] - v1[i]) <= epsilon); - return similar; - } }//namespace glm diff --git a/readme.txt b/readme.txt index 34475b87..80c4c8dc 100644 --- a/readme.txt +++ b/readme.txt @@ -37,11 +37,12 @@ More informations in GLM manual: http://glm.g-truc.net/glm-0.9.3.pdf ================================================================================ -GLM 0.9.3.B: 2011-XX-XX +GLM 0.9.3.B: 2011-12-06 -------------------------------------------------------------------------------- - Added support for Chrone Native Client - Added epsilon constant - Removed value_size function from vector types +- Fixed roundEven on GCC ================================================================================ GLM 0.9.2.8: 2011-12-XX diff --git a/test/gtx/gtx_matrix_query.cpp b/test/gtx/gtx_matrix_query.cpp index d68eb454..ecf286a8 100644 --- a/test/gtx/gtx_matrix_query.cpp +++ b/test/gtx/gtx_matrix_query.cpp @@ -20,6 +20,26 @@ int test_isNull() return Error; } +int test_isIdentity() +{ + int Error(0); + + { + bool TestA = glm::isIdentity(glm::mat2(1), 0.00001f); + Error += TestA ? 0 : 1; + } + { + bool TestA = glm::isIdentity(glm::mat3(1), 0.00001f); + Error += TestA ? 0 : 1; + } + { + bool TestA = glm::isIdentity(glm::mat4(1), 0.00001f); + Error += TestA ? 0 : 1; + } + + return Error; +} + int test_isNormalized() { int Error(0); @@ -45,6 +65,7 @@ int main() int Error(0); Error += test_isNull(); + Error += test_isIdentity(); Error += test_isNormalized(); Error += test_isOrthogonal(); diff --git a/test/gtx/gtx_vector_query.cpp b/test/gtx/gtx_vector_query.cpp index 181083b7..17b9e53c 100644 --- a/test/gtx/gtx_vector_query.cpp +++ b/test/gtx/gtx_vector_query.cpp @@ -10,11 +10,33 @@ #include #include -int test_isNull() +int test_areCollinear() +{ + int Error(0); + + { + bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f); + Error += TestA ? 0 : 1; + } + + { + bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f); + Error += TestA ? 0 : 1; + } + + { + bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f); + Error += TestA ? 0 : 1; + } + + return Error; +} + +int test_areOrthogonal() { int Error(0); - bool TestA = glm::isNull(glm::vec4(0), 0.00001f); + bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f); Error += TestA ? 0 : 1; return Error; @@ -30,11 +52,21 @@ int test_isNormalized() return Error; } -int test_areOrthogonal() +int test_isNull() { int Error(0); - bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f); + bool TestA = glm::isNull(glm::vec4(0), 0.00001f); + Error += TestA ? 0 : 1; + + return Error; +} + +int test_areOrthonormal() +{ + int Error(0); + + bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f); Error += TestA ? 0 : 1; return Error; @@ -44,9 +76,11 @@ int main() { int Error(0); - Error += test_isNull(); - Error += test_isNormalized(); + Error += test_areCollinear(); Error += test_areOrthogonal(); + Error += test_isNormalized(); + Error += test_isNull(); + Error += test_areOrthonormal(); return Error; }