Added missing equal and notEqual with epsilon for quaternion types
This commit is contained in:
parent
01f9ab5b6d
commit
8f0b7c1373
@ -379,6 +379,14 @@ namespace glm
|
|||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_DECL vec<4, bool, Q> equal(tquat<T, Q> const& x, tquat<T, Q> const& y);
|
GLM_FUNC_DECL vec<4, bool, Q> equal(tquat<T, Q> const& x, tquat<T, Q> const& y);
|
||||||
|
|
||||||
|
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||||
|
///
|
||||||
|
/// @tparam T Floating-point scalar types.
|
||||||
|
///
|
||||||
|
/// @see gtc_quaternion
|
||||||
|
template<typename T, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<4, bool, Q> equal(tquat<T, Q> const& x, tquat<T, Q> const& y, T epsilon);
|
||||||
|
|
||||||
/// Returns the component-wise comparison of result x != y.
|
/// Returns the component-wise comparison of result x != y.
|
||||||
///
|
///
|
||||||
/// @tparam T Floating-point scalar types.
|
/// @tparam T Floating-point scalar types.
|
||||||
@ -387,6 +395,15 @@ namespace glm
|
|||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_DECL vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y);
|
GLM_FUNC_DECL vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y);
|
||||||
|
|
||||||
|
/// Returns the component-wise comparison of |x - y| >= epsilon.
|
||||||
|
///
|
||||||
|
/// @tparam T Floating-point scalar types.
|
||||||
|
///
|
||||||
|
/// @see gtc_quaternion
|
||||||
|
template<typename T, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y, T epsilon);
|
||||||
|
|
||||||
|
|
||||||
/// Returns true if x holds a NaN (not a number)
|
/// Returns true if x holds a NaN (not a number)
|
||||||
/// representation in the underlying implementation's set of
|
/// representation in the underlying implementation's set of
|
||||||
/// floating point representations. Returns false otherwise,
|
/// floating point representations. Returns false otherwise,
|
||||||
|
@ -773,6 +773,13 @@ namespace detail
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<4, bool, Q> equal(tquat<T, Q> const& x, tquat<T, Q> const& y, T epsilon)
|
||||||
|
{
|
||||||
|
vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||||
|
return lessThan(abs(v), vec<4, T, Q>(epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y)
|
GLM_FUNC_QUALIFIER vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y)
|
||||||
{
|
{
|
||||||
@ -782,6 +789,13 @@ namespace detail
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<4, bool, Q> notEqual(tquat<T, Q> const& x, tquat<T, Q> const& y, T epsilon)
|
||||||
|
{
|
||||||
|
vec<4, T, Q> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||||
|
return greaterThanEqual(abs(v), vec<4, T, Q>(epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER vec<4, bool, Q> isnan(tquat<T, Q> const& q)
|
GLM_FUNC_QUALIFIER vec<4, bool, Q> isnan(tquat<T, Q> const& q)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
|
|||||||
- Added missing vec1 based constructors
|
- Added missing vec1 based constructors
|
||||||
- Redesigned constexpr support which excludes both SIMD and constexpr #783
|
- Redesigned constexpr support which excludes both SIMD and constexpr #783
|
||||||
- Added detection of Visual C++ 2017 toolsets
|
- Added detection of Visual C++ 2017 toolsets
|
||||||
|
- Added missing equal and notEqual with epsilon for quaternion types
|
||||||
|
|
||||||
#### Fixes:
|
#### Fixes:
|
||||||
- Fixed build problems due to printf and std::clock_t #778
|
- Fixed build problems due to printf and std::clock_t #778
|
||||||
|
@ -317,6 +317,55 @@ static int test_constexpr()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace glm;
|
||||||
|
|
||||||
|
/*
|
||||||
|
template<template<length_t C, length_t R, typename T, qualifier Q> class matType>
|
||||||
|
struct init_mat
|
||||||
|
{
|
||||||
|
static matType<C, R, T, Q> identity()
|
||||||
|
{
|
||||||
|
return matType<C, R, T, Q>(1, 0, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
template<typename T, qualifier Q>
|
||||||
|
struct init_quat
|
||||||
|
{
|
||||||
|
static tquat<T, Q> identity()
|
||||||
|
{
|
||||||
|
return tquat<T, Q>(1, 0, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename genType>
|
||||||
|
struct init
|
||||||
|
{
|
||||||
|
static genType identity()
|
||||||
|
{
|
||||||
|
return init_quat<typename genType::value_type, highp>::identity();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename genType>
|
||||||
|
inline genType identity()
|
||||||
|
{
|
||||||
|
return init<genType>::identity();
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_identity()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::quat const Q = identity<glm::quat>();
|
||||||
|
|
||||||
|
Error += glm::all(glm::equal(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 0 : 1;
|
||||||
|
Error += glm::any(glm::notEqual(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 1 : 0;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
@ -334,6 +383,7 @@ int main()
|
|||||||
Error += test_quat_slerp();
|
Error += test_quat_slerp();
|
||||||
Error += test_size();
|
Error += test_size();
|
||||||
Error += test_constexpr();
|
Error += test_constexpr();
|
||||||
|
Error += test_identity();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user