Clutter Engine 0.0.1
Loading...
Searching...
No Matches
vector_relational.inl
Go to the documentation of this file.
2#include "../common.hpp"
3#include "../detail/qualifier.hpp"
4#include "../detail/type_float.hpp"
5
6namespace glm
7{
8 template<length_t L, typename T, qualifier Q>
9 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T Epsilon)
10 {
11 return equal(x, y, vec<L, T, Q>(Epsilon));
12 }
13
14 template<length_t L, typename T, qualifier Q>
15 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& Epsilon)
16 {
17 return lessThanEqual(abs(x - y), Epsilon);
18 }
19
20 template<length_t L, typename T, qualifier Q>
21 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, T Epsilon)
22 {
23 return notEqual(x, y, vec<L, T, Q>(Epsilon));
24 }
25
26 template<length_t L, typename T, qualifier Q>
27 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& Epsilon)
28 {
29 return greaterThan(abs(x - y), Epsilon);
30 }
31
32
33 template<length_t L, typename T, qualifier Q>
34 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, int MaxULPs)
35 {
36 return equal(x, y, vec<L, int, Q>(MaxULPs));
37 }
38
39 template<length_t L, typename T, qualifier Q>
40 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, int, Q> const& MaxULPs)
41 {
42 vec<L, bool, Q> Result(false);
43 for(length_t i = 0; i < L; ++i)
44 {
45 detail::float_t<T> const a(x[i]);
46 detail::float_t<T> const b(y[i]);
47
48 // Different signs means they do not match.
49 if(a.negative() != b.negative())
50 {
51 // Check for equality to make sure +0==-0
52 Result[i] = a.mantissa() == b.mantissa() && a.exponent() == b.exponent();
53 }
54 else
55 {
56 // Find the difference in ULPs.
57 typename detail::float_t<T>::int_type const DiffULPs = abs(a.i - b.i);
58 Result[i] = DiffULPs <= MaxULPs[i];
59 }
60 }
61 return Result;
62 }
63
64 template<length_t L, typename T, qualifier Q>
65 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, int MaxULPs)
66 {
67 return notEqual(x, y, vec<L, int, Q>(MaxULPs));
68 }
69
70 template<length_t L, typename T, qualifier Q>
71 GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, int, Q> const& MaxULPs)
72 {
73 return not_(equal(x, y, MaxULPs));
74 }
75}//namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR genType abs(genType x)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > not_(vec< L, bool, Q > const &v)
Definition func_vector_relational.inl:76
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > notEqual(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:49
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > greaterThan(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:22
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > lessThanEqual(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:13
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > equal(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:40
Core features
Definition common.hpp:21
Definition qualifier.hpp:35
Definition type_float.hpp:15