Renamed equalEpsilon function into epsilonEqual and added tests

This commit is contained in:
Christophe Riccio
2012-11-05 19:43:23 +01:00
parent 9d9a625493
commit 415c970188
5 changed files with 47 additions and 47 deletions

View File

@@ -19,25 +19,25 @@ int test_quat_angle()
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
}
{
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 += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
}
{
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 += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
}
return Error;
@@ -52,10 +52,10 @@ int test_quat_angleAxis()
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;
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
@@ -69,10 +69,10 @@ int test_quat_mix()
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;
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
@@ -95,19 +95,19 @@ int test_quat_normalize()
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 2));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(1, 2, 3));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
return Error;

View File

@@ -25,8 +25,8 @@ int test_linearRand()
ResultDouble += glm::linearRand(-1.0, 1.0);
}
Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f);
Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001);
Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f);
Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001);
assert(!Error);
}
@@ -49,8 +49,8 @@ int test_circularRand()
ResultDouble += glm::length(glm::circularRand(Radius));
}
Error += glm::equalEpsilon(ResultFloat, float(Max), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
assert(!Error);
}
@@ -80,12 +80,12 @@ int test_sphericalRand()
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
}
Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
assert(!Error);
}