mirror of
https://github.com/g-truc/glm.git
synced 2024-11-25 18:04:34 +00:00
Merge pull request #1137 from tetrisplusplus/fix_glm_gtx_matrix_query_isOrthogonal
fix: isOrthogonal for a zero matrix #1137
This commit is contained in:
commit
db0f79de12
@ -97,16 +97,22 @@ namespace glm
|
|||||||
GLM_FUNC_QUALIFIER bool isOrthogonal(mat<C, R, T, Q> const& m, T const& epsilon)
|
GLM_FUNC_QUALIFIER bool isOrthogonal(mat<C, R, T, Q> const& m, T const& epsilon)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for(length_t i(0); result && i < m.length() - 1; ++i)
|
for(length_t i(0); result && i < m.length(); ++i)
|
||||||
for(length_t j(i + 1); result && j < m.length(); ++j)
|
{
|
||||||
result = areOrthogonal(m[i], m[j], epsilon);
|
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)
|
if(result)
|
||||||
{
|
{
|
||||||
mat<C, R, T, Q> tmp = transpose(m);
|
mat<C, R, T, Q> tmp = transpose(m);
|
||||||
for(length_t i(0); result && i < m.length() - 1 ; ++i)
|
for(length_t i(0); result && i < m.length(); ++i)
|
||||||
for(length_t j(i + 1); result && j < m.length(); ++j)
|
{
|
||||||
result = areOrthogonal(tmp[i], tmp[j], epsilon);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,14 @@ int test_isOrthogonal()
|
|||||||
{
|
{
|
||||||
int Error(0);
|
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;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user