diff --git a/glm/gtx/matrix_query.inl b/glm/gtx/matrix_query.inl index b763c1ab..dc3ec845 100644 --- a/glm/gtx/matrix_query.inl +++ b/glm/gtx/matrix_query.inl @@ -97,16 +97,22 @@ namespace glm GLM_FUNC_QUALIFIER bool isOrthogonal(mat const& m, T const& epsilon) { bool result = true; - for(length_t i(0); result && i < m.length() - 1; ++i) - for(length_t j(i + 1); result && j < m.length(); ++j) - result = areOrthogonal(m[i], m[j], epsilon); + for(length_t i(0); result && i < m.length(); ++i) + { + result = isNormalized(m[i], epsilon); + for(length_t j(i + 1); result && j < m.length(); ++j) + result = abs(dot(m[i], m[j])) <= epsilon; + } if(result) { mat tmp = transpose(m); - for(length_t i(0); result && i < m.length() - 1 ; ++i) - for(length_t j(i + 1); result && j < m.length(); ++j) - result = areOrthogonal(tmp[i], tmp[j], epsilon); + for(length_t i(0); result && i < m.length(); ++i) + { + result = isNormalized(tmp[i], epsilon); + for(length_t j(i + 1); result && j < m.length(); ++j) + result = abs(dot(tmp[i], tmp[j])) <= epsilon; + } } return result; } diff --git a/test/gtx/gtx_matrix_query.cpp b/test/gtx/gtx_matrix_query.cpp index 0dda1f09..744d3e58 100644 --- a/test/gtx/gtx_matrix_query.cpp +++ b/test/gtx/gtx_matrix_query.cpp @@ -45,8 +45,14 @@ int test_isOrthogonal() { int Error(0); - bool TestA = glm::isOrthogonal(glm::mat4(1), 0.00001f); - Error += TestA ? 0 : 1; + { + bool TestA = glm::isOrthogonal(glm::mat4(1), 0.00001f); + Error += TestA ? 0 : 1; + } + { + bool TestA = glm::isOrthogonal(glm::mat4(0), 0.00001f); + Error += TestA ? 1 : 0; + } return Error; }