Clutter Engine 0.0.1
Loading...
Searching...
No Matches
common.inl
1
2
3#include <cmath>
4#include "../gtc/epsilon.hpp"
6
7namespace glm{
8namespace detail
9{
10 template<length_t L, typename T, qualifier Q, bool isFloat = true>
12 {
13 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
14 {
15 return detail::functor2<vec, L, T, Q>::call(std::fmod, a, b);
16 }
17 };
18
19 template<length_t L, typename T, qualifier Q>
20 struct compute_fmod<L, T, Q, false>
21 {
22 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
23 {
24 return a % b;
25 }
26 };
27}//namespace detail
28
29 template<typename T>
30 GLM_FUNC_QUALIFIER bool isdenormal(T const& x)
31 {
32 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isdenormal' only accept floating-point inputs");
33
34# if GLM_HAS_CXX11_STL
35 return std::fpclassify(x) == FP_SUBNORMAL;
36# else
37 return epsilonNotEqual(x, static_cast<T>(0), epsilon<T>()) && std::fabs(x) < std::numeric_limits<T>::min();
38# endif
39 }
40
41 template<typename T, qualifier Q>
42 GLM_FUNC_QUALIFIER typename vec<1, T, Q>::bool_type isdenormal
43 (
44 vec<1, T, Q> const& x
45 )
46 {
47 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isdenormal' only accept floating-point inputs");
48
49 return typename vec<1, T, Q>::bool_type(
50 isdenormal(x.x));
51 }
52
53 template<typename T, qualifier Q>
54 GLM_FUNC_QUALIFIER typename vec<2, T, Q>::bool_type isdenormal
55 (
56 vec<2, T, Q> const& x
57 )
58 {
59 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isdenormal' only accept floating-point inputs");
60
61 return typename vec<2, T, Q>::bool_type(
62 isdenormal(x.x),
63 isdenormal(x.y));
64 }
65
66 template<typename T, qualifier Q>
67 GLM_FUNC_QUALIFIER typename vec<3, T, Q>::bool_type isdenormal
68 (
69 vec<3, T, Q> const& x
70 )
71 {
72 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isdenormal' only accept floating-point inputs");
73
74 return typename vec<3, T, Q>::bool_type(
75 isdenormal(x.x),
76 isdenormal(x.y),
77 isdenormal(x.z));
78 }
79
80 template<typename T, qualifier Q>
81 GLM_FUNC_QUALIFIER typename vec<4, T, Q>::bool_type isdenormal
82 (
83 vec<4, T, Q> const& x
84 )
85 {
86 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isdenormal' only accept floating-point inputs");
87
88 return typename vec<4, T, Q>::bool_type(
89 isdenormal(x.x),
90 isdenormal(x.y),
91 isdenormal(x.z),
92 isdenormal(x.w));
93 }
94
95 // fmod
96 template<typename genType>
97 GLM_FUNC_QUALIFIER genType fmod(genType x, genType y)
98 {
99 return fmod(vec<1, genType>(x), y).x;
100 }
101
102 template<length_t L, typename T, qualifier Q>
103 GLM_FUNC_QUALIFIER vec<L, T, Q> fmod(vec<L, T, Q> const& x, T y)
104 {
105 return detail::compute_fmod<L, T, Q, std::numeric_limits<T>::is_iec559>::call(x, vec<L, T, Q>(y));
106 }
107
108 template<length_t L, typename T, qualifier Q>
109 GLM_FUNC_QUALIFIER vec<L, T, Q> fmod(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
110 {
111 return detail::compute_fmod<L, T, Q, std::numeric_limits<T>::is_iec559>::call(x, y);
112 }
113
114 template <length_t L, typename T, qualifier Q>
115 GLM_FUNC_QUALIFIER vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
116 {
117 return greaterThan(Value, Min) && lessThan(Value, Max);
118 }
119
120 template <length_t L, typename T, qualifier Q>
121 GLM_FUNC_QUALIFIER vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
122 {
123 return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max);
124 }
125}//namespace glm
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec< L, bool, Q > greaterThanEqual(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:31
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 > lessThan(vec< L, T, Q > const &x, vec< L, T, Q > const &y)
Definition func_vector_relational.inl:4
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon()
Return the epsilon constant for floating point types.
Definition scalar_constants.inl:6
GLM_FUNC_DECL vec< L, bool, Q > epsilonNotEqual(vec< L, T, Q > const &x, vec< L, T, Q > const &y, T const &epsilon)
Definition epsilon.inl:56
GLM_FUNC_DECL vec< L, T, Q > fmod(vec< L, T, Q > const &v)
GLM_FUNC_DECL vec< L, bool, Q > openBounded(vec< L, T, Q > const &Value, vec< L, T, Q > const &Min, vec< L, T, Q > const &Max)
Definition common.inl:115
GLM_FUNC_DECL genType::bool_type isdenormal(genType const &x)
GLM_FUNC_DECL vec< L, bool, Q > closeBounded(vec< L, T, Q > const &Value, vec< L, T, Q > const &Min, vec< L, T, Q > const &Max)
Definition common.inl:121
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21
Definition common.inl:12
Definition _vectorize.hpp:46
Definition qualifier.hpp:35