Renamed equalEpsilon function into epsilonEqual and added tests
This commit is contained in:
parent
a350a26e3b
commit
9d9a625493
@ -57,7 +57,7 @@ namespace glm
|
|||||||
/// Returns the component-wise compare of |x - y| < epsilon.
|
/// Returns the component-wise compare of |x - y| < epsilon.
|
||||||
/// @see gtc_epsilon
|
/// @see gtc_epsilon
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU>
|
||||||
bool equalEpsilon(
|
bool epsilonEqual(
|
||||||
genTypeT const & x,
|
genTypeT const & x,
|
||||||
genTypeT const & y,
|
genTypeT const & y,
|
||||||
genTypeU const & epsilon);
|
genTypeU const & epsilon);
|
||||||
@ -65,7 +65,7 @@ namespace glm
|
|||||||
/// Returns the component-wise compare of |x - y| >= epsilon.
|
/// Returns the component-wise compare of |x - y| >= epsilon.
|
||||||
/// @see gtc_epsilon
|
/// @see gtc_epsilon
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU>
|
||||||
bool notEqualEpsilon(
|
bool epsilonNotEqual(
|
||||||
genTypeT const & x,
|
genTypeT const & x,
|
||||||
genTypeT const & y,
|
genTypeT const & y,
|
||||||
genTypeU const & epsilon);
|
genTypeU const & epsilon);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool equalEpsilon
|
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||||
(
|
(
|
||||||
genType const & x,
|
genType const & x,
|
||||||
genType const & y,
|
genType const & y,
|
||||||
@ -40,7 +40,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool notEqualEpsilon
|
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||||
(
|
(
|
||||||
genType const & x,
|
genType const & x,
|
||||||
genType const & y,
|
genType const & y,
|
||||||
@ -51,7 +51,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
@ -63,7 +63,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
@ -76,7 +76,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
@ -91,7 +91,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
@ -104,7 +104,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
@ -118,7 +118,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
@ -133,7 +133,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
@ -146,7 +146,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
@ -160,7 +160,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
@ -175,7 +175,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||||
(
|
(
|
||||||
detail::tquat<valType> const & x,
|
detail::tquat<valType> const & x,
|
||||||
detail::tquat<valType> const & y,
|
detail::tquat<valType> const & y,
|
||||||
@ -190,7 +190,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
@ -203,7 +203,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
@ -217,7 +217,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
@ -232,7 +232,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||||
(
|
(
|
||||||
detail::tquat<valType> const & x,
|
detail::tquat<valType> const & x,
|
||||||
detail::tquat<valType> const & y,
|
detail::tquat<valType> const & y,
|
||||||
|
@ -33,7 +33,7 @@ namespace glm
|
|||||||
valType const Angle(glm::degrees(acos(dot(x, y))));
|
valType const Angle(glm::degrees(acos(dot(x, y))));
|
||||||
#endif
|
#endif
|
||||||
detail::tvec2<valType> const TransformedVector(glm::rotate(x, Angle));
|
detail::tvec2<valType> const TransformedVector(glm::rotate(x, Angle));
|
||||||
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
if(all(epsilonEqual(y, TransformedVector, valType(0.01))))
|
||||||
return Angle;
|
return Angle;
|
||||||
else
|
else
|
||||||
return -Angle;
|
return -Angle;
|
||||||
|
@ -34,12 +34,12 @@ GLM is a header only library, there is nothing to build, just include it.
|
|||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
More informations in GLM manual:
|
More informations in GLM manual:
|
||||||
http://glm.g-truc.net/glm-0.9.3.pdf
|
http://glm.g-truc.net/glm-0.9.4.pdf
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.4.0: 2012-10-13
|
GLM 0.9.4.0: 2012-11-07
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
- Added Intel Composer support
|
- Added Intel Composer Compiler support
|
||||||
- Promoted GTC_espilon extension
|
- Promoted GTC_espilon extension
|
||||||
- Promoted GTC_ulp extension
|
- Promoted GTC_ulp extension
|
||||||
- Removed GLM website from the source repository
|
- Removed GLM website from the source repository
|
||||||
|
@ -14,7 +14,7 @@ int main()
|
|||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,55 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/half_float.hpp>
|
||||||
#include <glm/gtc/epsilon.hpp>
|
#include <glm/gtc/epsilon.hpp>
|
||||||
|
#include <glm/gtc/constants.hpp>
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
int test_equal()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
T A = glm::epsilon<T>();
|
||||||
|
T B = glm::epsilon<T>();
|
||||||
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T A(0);
|
||||||
|
T B = T(0) + glm::epsilon<T>();
|
||||||
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T A(0);
|
||||||
|
T B = T(0) - glm::epsilon<T>();
|
||||||
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T A = T(0) + glm::epsilon<T>();
|
||||||
|
T B = T(0);
|
||||||
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T A = T(0) - glm::epsilon<T>();
|
||||||
|
T B = T(0);
|
||||||
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
|
Error += test_equal<glm::half>();
|
||||||
|
Error += test_equal<float>();
|
||||||
|
Error += test_equal<double>();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ int test_quat_fastMix()
|
|||||||
glm::quat C = glm::fastMix(A, B, 0.5f);
|
glm::quat C = glm::fastMix(A, B, 0.5f);
|
||||||
glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
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::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
@ -37,10 +37,10 @@ int test_quat_shortMix()
|
|||||||
glm::quat C = glm::shortMix(A, B, 0.5f);
|
glm::quat C = glm::shortMix(A, B, 0.5f);
|
||||||
glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
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::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
||||||
Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ int test_angle()
|
|||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
float AngleA = glm::angle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
|
float AngleA = glm::angle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1)));
|
||||||
Error += glm::equalEpsilon(AngleA, 45.f, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(AngleA, 45.f, 0.01f) ? 0 : 1;
|
||||||
float AngleB = glm::angle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)));
|
float AngleB = glm::angle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)));
|
||||||
Error += glm::equalEpsilon(AngleB, 45.f, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(AngleB, 45.f, 0.01f) ? 0 : 1;
|
||||||
float AngleC = glm::angle(glm::vec4(1, 0, 0, 0), glm::normalize(glm::vec4(1, 1, 0, 0)));
|
float AngleC = glm::angle(glm::vec4(1, 0, 0, 0), glm::normalize(glm::vec4(1, 1, 0, 0)));
|
||||||
Error += glm::equalEpsilon(AngleC, 45.f, 0.01f) ? 0 : 1;
|
Error += glm::epsilonEqual(AngleC, 45.f, 0.01f) ? 0 : 1;
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user