Sliced ext relational extensions

This commit is contained in:
Christophe Riccio 2018-08-01 12:10:27 +02:00
parent a71d553435
commit 428a468d13
11 changed files with 328 additions and 87 deletions

View File

@ -0,0 +1,103 @@
/// @ref ext_matrix_relational
/// @file glm/ext/matrix_relational.hpp
///
/// @see core (dependence)
///
/// @defgroup ext_vector_relational GLM_EXT_matrix_relational
/// @ingroup ext
///
/// Include <glm/ext/matrix_relational.hpp> to use the features of this extension.
///
/// Comparison functions for a user defined epsilon values.
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_EXT_matrix_relational extension included")
#endif
namespace glm
{
/// @addtogroup ext_matrix_relational
/// @{
/// Perform a component-wise equal-to comparison of two matrices.
/// Return a boolean vector which components value is True if this expression is satisfied per column of the matrices.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_matrix_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_matrix_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, T epsilon);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_matrix_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, vec<C, T, Q> const& epsilon);
/// Perform a component-wise not-equal-to comparison of two matrices.
/// Return a boolean vector which components value is True if this expression is satisfied per column of the matrices.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_matrix_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is not satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_matrix_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, T epsilon);
/// Returns the component-wise comparison of |x - y| >= epsilon.
/// True if this expression is not satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, vec<C, T, Q> const& epsilon);
/// @}
}//namespace glm
#include "matrix_relational.inl"

View File

@ -0,0 +1,88 @@
/// @ref ext_vector_relational
/// @file glm/ext/vector_relational.inl
// Dependency:
#include "../vector_relational.hpp"
#include "../common.hpp"
#include "../detail/type_vec.hpp"
namespace glm
{
template<typename genType>
GLM_FUNC_QUALIFIER bool equal(genType const& x, genType const& y, genType const& epsilon)
{
return abs(x - y) <= epsilon;
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T epsilon)
{
return equal(x, y, vec<L, T, Q>(epsilon));
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& epsilon)
{
return lessThanEqual(abs(x - y), epsilon);
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> equal(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b)
{
return equal(a, b, static_cast<T>(0));
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> equal(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, T epsilon)
{
return equal(a, b, vec<C, T, Q>(epsilon));
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> equal(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& epsilon)
{
vec<C, bool, Q> Result;
for(length_t i = 0, n = C; i < n; ++i)
Result[i] = all(equal(a[i], b[i], epsilon[i]));
return Result;
}
template<typename genType>
GLM_FUNC_QUALIFIER bool notEqual(genType const& x, genType const& y, genType const& epsilon)
{
return abs(x - y) > epsilon;
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T epsilon)
{
return notEqual(x, y, vec<L, T, Q>(epsilon));
}
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& epsilon)
{
return greaterThan(abs(x - y), epsilon);
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y)
{
return notEqual(x, y, static_cast<T>(0));
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, T epsilon)
{
return notEqual(x, y, vec<C, T, Q>(epsilon));
}
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& a, mat<C, R, T, Q> const& b, vec<C, T, Q> const& epsilon)
{
vec<C, bool, Q> Result;
for(length_t i = 0, n = C; i < n; ++i)
Result[i] = any(notEqual(a[i], b[i], epsilon[i]));
return Result;
}
}//namespace glm

View File

@ -0,0 +1,46 @@
/// @ref ext_scalar_relational
/// @file glm/ext/scalar_relational.hpp
///
/// @see core (dependence)
///
/// @defgroup ext_vector_relational GLM_EXT_scalar_relational
/// @ingroup ext
///
/// Include <glm/ext/scalar_relational.hpp> to use the features of this extension.
///
/// Comparison functions for a user defined epsilon values.
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/qualifier.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_EXT_scalar_relational extension included")
#endif
namespace glm
{
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @tparam genType Floating-point or integer scalar types
///
/// @see ext_vector_relational
template<typename genType>
GLM_FUNC_DECL bool equal(genType const& x, genType const& y, genType const& epsilon);
/// Returns the component-wise comparison of |x - y| >= epsilon.
/// True if this expression is not satisfied.
///
/// @tparam genType Floating-point or integer scalar types
///
/// @see ext_vector_relational
template<typename genType>
GLM_FUNC_DECL bool notEqual(genType const& x, genType const& y, genType const& epsilon);
/// @}
}//namespace glm
#include "scalar_relational.inl"

View File

@ -0,0 +1,20 @@
/// @ref ext_scalar_relational
/// @file glm/ext/scalar_relational.inl
// Dependency:
#include "../common.hpp"
namespace glm
{
template<typename genType>
GLM_FUNC_QUALIFIER bool equal(genType const& x, genType const& y, genType const& epsilon)
{
return abs(x - y) <= epsilon;
}
template<typename genType>
GLM_FUNC_QUALIFIER bool notEqual(genType const& x, genType const& y, genType const& epsilon)
{
return abs(x - y) > epsilon;
}
}//namespace glm

View File

@ -25,42 +25,6 @@ namespace glm
/// @addtogroup ext_vector_relational
/// @{
/// Returns the component-wise comparison of |x - y| <= 0.0.
/// True if this expression is satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, T epsilon);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> equal(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, vec<C, T, Q> const& epsilon);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is satisfied.
///
@ -92,42 +56,6 @@ namespace glm
template<typename genType>
GLM_FUNC_DECL bool equal(genType const& x, genType const& y, genType const& epsilon);
/// Returns the component-wise comparison of |x - y| <= 0.0.
/// True if this expression is not satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
/// Returns the component-wise comparison of |x - y| < epsilon.
/// True if this expression is not satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, T epsilon);
/// Returns the component-wise comparison of |x - y| >= epsilon.
/// True if this expression is not satisfied.
///
/// @tparam C Integer between 1 and 4 included that qualify the number of columns of the matrix
/// @tparam R Integer between 1 and 4 included that qualify the number of rows of the matrix
/// @tparam T Floating-point or integer scalar types
/// @tparam Q Value from qualifier enum
///
/// @see ext_vector_relational
template<length_t C, length_t R, typename T, qualifier Q>
GLM_FUNC_DECL vec<C, bool, Q> notEqual(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, vec<C, T, Q> const& epsilon);
/// Returns the component-wise comparison of |x - y| >= epsilon.
/// True if this expression is not satisfied.
///

View File

@ -30,8 +30,10 @@
+ [2.15. GLM\_FORCE\_DEFAULT\_ALIGNED_GENTYPES: Force GLM to use aligned types by default](#section2_15)
+ [2.16. GLM_\FORCE\_PLATFORM\_UNKNOWN: Force GLM to no detect the build platform](#section2_16)
+ [3. Stable extensions](#section3)
+ [3.1. GLM_EXT_vec1](#section3_1)
+ [3.2. GLM_EXT_vector_relational](#section3_2)
+ [3.1. GLM_EXT_matrix_relational](#section3_1)
+ [3.2. GLM_EXT_scalar_relational](#section3_2)
+ [3.3. GLM_EXT_vec1](#section3_3)
+ [3.4. GLM_EXT_vector_relational](#section3_4)
+ [4. Recommended extensions](#section4)
+ [4.1. GLM_GTC_bitfield](#section4_1)
+ [4.2. GLM_GTC_color_space](#section4_2)

View File

@ -54,8 +54,8 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
### [GLM 0.9.9.1](https://github.com/g-truc/glm/commits/master) - 2018-0X-XX
#### Features:
- Added bitfieldDeinterleave to GTC_bitfield
- Added missing equal and notEqual with epsilon for quaternion types to EXT_vector_relational
- Added missing equal and notEqual with epsilon for matrix types to EXT_vector_relational
- Added missing equal and notEqual with epsilon for quaternion types to GTC_quaternion
- Added EXT_matrix_relational: equal and notEqual with epsilon for matrix types
- Added missing aligned matrix types to GTC_type_aligned
- Added C++17 detection
- Added Visual C++ language standard version detection

View File

@ -1,2 +1,4 @@
glmCreateTestGTC(ext_matrix_relational)
glmCreateTestGTC(ext_scalar_relational)
glmCreateTestGTC(ext_vec1)
glmCreateTestGTC(ext_vector_relational)

View File

@ -0,0 +1,32 @@
#include <glm/ext/matrix_relational.hpp>
#include <glm/mat4x3.hpp>
int test_equal()
{
int Error = 0;
Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1;
Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0;
return Error;
}
int test_notEqual()
{
int Error = 0;
Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1;
Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0;
return Error;
}
int main()
{
int Error = 0;
Error += test_equal();
Error += test_notEqual();
return Error;
}

View File

@ -0,0 +1,31 @@
#include <glm/ext/scalar_relational.hpp>
int test_equal()
{
int Error = 0;
Error += glm::equal(1.01f, 1.02f, 0.1f) ? 0 : 1;
Error += !glm::equal(1.01f, 1.02f, 0.001f) ? 0 : 1;
return Error;
}
int test_notEqual()
{
int Error = 0;
Error += glm::notEqual(1.01f, 1.02f, 0.001f) ? 0 : 1;
Error += !glm::notEqual(1.01f, 1.02f, 0.1f) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_equal();
Error += test_notEqual();
return Error;
}

View File

@ -1,22 +1,16 @@
#include <glm/ext/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/mat4x3.hpp>
int test_equal()
{
int Error = 0;
Error += glm::equal(1.01f, 1.02f, 0.1f) ? 0 : 1;
Error += glm::all(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), 0.1f)) ? 0 : 1;
Error += glm::all(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.1f))) ? 0 : 1;
Error += !glm::equal(1.01f, 1.02f, 0.001f) ? 0 : 1;
Error += !glm::any(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), 0.001f)) ? 0 : 1;
Error += !glm::any(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.001f))) ? 0 : 1;
Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1;
Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0;
return Error;
}
@ -24,17 +18,12 @@ int test_notEqual()
{
int Error = 0;
Error += glm::notEqual(1.01f, 1.02f, 0.001f) ? 0 : 1;
Error += glm::all(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), 0.001f)) ? 0 : 1;
Error += glm::all(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.001f))) ? 0 : 1;
Error += !glm::notEqual(1.01f, 1.02f, 0.1f) ? 0 : 1;
Error += !glm::any(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), 0.1f)) ? 0 : 1;
Error += !glm::any(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.1f))) ? 0 : 1;
Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1;
Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0;
return Error;
}