From 31f85aab6e81826bf73c05f38cb5e5c397c83305 Mon Sep 17 00:00:00 2001 From: tetrisplusplus Date: Mon, 23 Jan 2023 21:41:27 +0900 Subject: [PATCH] Improved performace. --- glm/gtx/matrix_query.inl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/glm/gtx/matrix_query.inl b/glm/gtx/matrix_query.inl index ab7bf943..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 = areOrthonormal(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 = areOrthonormal(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; }