master
ブランチ master
VulkanExample / dep / include / glm / ext / scalar_relational.inl
1.1 KB、40行 生 Blame 履歴
1#include "../common.hpp"
2#include "../ext/scalar_int_sized.hpp"
3#include "../ext/scalar_uint_sized.hpp"
4#include "../detail/type_float.hpp"
5
6namespace glm
7{
8 template<typename genType>
9 GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool equal(genType const& x, genType const& y, genType const& epsilon)
10 {
11 return abs(x - y) <= epsilon;
12 }
13
14 template<typename genType>
15 GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool notEqual(genType const& x, genType const& y, genType const& epsilon)
16 {
17 return abs(x - y) > epsilon;
18 }
19
20 template<typename genType>
21 GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool equal(genType const& x, genType const& y, int MaxULPs)
22 {
23 detail::float_t<genType> const a(x);
24 detail::float_t<genType> const b(y);
25
26 // Different signs means they do not match.
27 if(a.negative() != b.negative())
28 return false;
29
30 // Find the difference in ULPs.
31 typename detail::float_t<genType>::int_type const DiffULPs = abs(a.i - b.i);
32 return DiffULPs <= MaxULPs;
33 }
34
35 template<typename genType>
36 GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool notEqual(genType const& x, genType const& y, int ULPs)
37 {
38 return !equal(x, y, ULPs);
39 }
40}//namespace glm