1 /// @ref gtc_round
2 /// @file glm/gtc/round.hpp
3 ///
4 /// @see core (dependence)
5 /// @see gtc_round (dependence)
6 ///
7 /// @defgroup gtc_round GLM_GTC_round
8 /// @ingroup gtc
9 ///
10 /// @brief rounding value to specific boundings
11 ///
12 /// <glm/gtc/round.hpp> need to be included to use these functionalities.
13 
14 #pragma once
15 
16 // Dependencies
17 #include "../detail/setup.hpp"
18 #include "../detail/precision.hpp"
19 #include "../detail/_vectorize.hpp"
20 #include "../vector_relational.hpp"
21 #include "../common.hpp"
22 #include <limits>
23 
24 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
25 #	pragma message("GLM: GLM_GTC_integer extension included")
26 #endif
27 
28 namespace glm
29 {
30 	/// @addtogroup gtc_round
31 	/// @{
32 
33 	/// Return true if the value is a power of two number.
34 	///
35 	/// @see gtc_round
36 	template <typename genIUType>
37 	GLM_FUNC_DECL bool isPowerOfTwo(genIUType Value);
38 
39 	/// Return true if the value is a power of two number.
40 	///
41 	/// @see gtc_round
42 	template <typename T, precision P, template <typename, precision> class vecType>
43 	GLM_FUNC_DECL vecType<bool, P> isPowerOfTwo(vecType<T, P> const & value);
44 
45 	/// Return the power of two number which value is just higher the input value,
46 	/// round up to a power of two.
47 	///
48 	/// @see gtc_round
49 	template <typename genIUType>
50 	GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType Value);
51 
52 	/// Return the power of two number which value is just higher the input value,
53 	/// round up to a power of two.
54 	///
55 	/// @see gtc_round
56 	template <typename T, precision P, template <typename, precision> class vecType>
57 	GLM_FUNC_DECL vecType<T, P> ceilPowerOfTwo(vecType<T, P> const & value);
58 
59 	/// Return the power of two number which value is just lower the input value,
60 	/// round down to a power of two.
61 	///
62 	/// @see gtc_round
63 	template <typename genIUType>
64 	GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType Value);
65 
66 	/// Return the power of two number which value is just lower the input value,
67 	/// round down to a power of two.
68 	///
69 	/// @see gtc_round
70 	template <typename T, precision P, template <typename, precision> class vecType>
71 	GLM_FUNC_DECL vecType<T, P> floorPowerOfTwo(vecType<T, P> const & value);
72 
73 	/// Return the power of two number which value is the closet to the input value.
74 	///
75 	/// @see gtc_round
76 	template <typename genIUType>
77 	GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType Value);
78 
79 	/// Return the power of two number which value is the closet to the input value.
80 	///
81 	/// @see gtc_round
82 	template <typename T, precision P, template <typename, precision> class vecType>
83 	GLM_FUNC_DECL vecType<T, P> roundPowerOfTwo(vecType<T, P> const & value);
84 
85 	/// Return true if the 'Value' is a multiple of 'Multiple'.
86 	///
87 	/// @see gtc_round
88 	template <typename genIUType>
89 	GLM_FUNC_DECL bool isMultiple(genIUType Value, genIUType Multiple);
90 
91 	/// Return true if the 'Value' is a multiple of 'Multiple'.
92 	///
93 	/// @see gtc_round
94 	template <typename T, precision P, template <typename, precision> class vecType>
95 	GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, T Multiple);
96 
97 	/// Return true if the 'Value' is a multiple of 'Multiple'.
98 	///
99 	/// @see gtc_round
100 	template <typename T, precision P, template <typename, precision> class vecType>
101 	GLM_FUNC_DECL vecType<bool, P> isMultiple(vecType<T, P> const & Value, vecType<T, P> const & Multiple);
102 
103 	/// Higher multiple number of Source.
104 	///
105 	/// @tparam genType Floating-point or integer scalar or vector types.
106 	/// @param Source
107 	/// @param Multiple Must be a null or positive value
108 	///
109 	/// @see gtc_round
110 	template <typename genType>
111 	GLM_FUNC_DECL genType ceilMultiple(genType Source, genType Multiple);
112 
113 	/// Higher multiple number of Source.
114 	///
115 	/// @tparam genType Floating-point or integer scalar or vector types.
116 	/// @param Source
117 	/// @param Multiple Must be a null or positive value
118 	///
119 	/// @see gtc_round
120 	template <typename T, precision P, template <typename, precision> class vecType>
121 	GLM_FUNC_DECL vecType<T, P> ceilMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple);
122 
123 	/// Lower multiple number of Source.
124 	///
125 	/// @tparam genType Floating-point or integer scalar or vector types.
126 	/// @param Source
127 	/// @param Multiple Must be a null or positive value
128 	///
129 	/// @see gtc_round
130 	template <typename genType>
131 	GLM_FUNC_DECL genType floorMultiple(
132 		genType Source,
133 		genType Multiple);
134 
135 	/// Lower multiple number of Source.
136 	///
137 	/// @tparam genType Floating-point or integer scalar or vector types.
138 	/// @param Source
139 	/// @param Multiple Must be a null or positive value
140 	///
141 	/// @see gtc_round
142 	template <typename T, precision P, template <typename, precision> class vecType>
143 	GLM_FUNC_DECL vecType<T, P> floorMultiple(
144 		vecType<T, P> const & Source,
145 		vecType<T, P> const & Multiple);
146 
147 	/// Lower multiple number of Source.
148 	///
149 	/// @tparam genType Floating-point or integer scalar or vector types.
150 	/// @param Source
151 	/// @param Multiple Must be a null or positive value
152 	///
153 	/// @see gtc_round
154 	template <typename genType>
155 	GLM_FUNC_DECL genType roundMultiple(
156 		genType Source,
157 		genType Multiple);
158 
159 	/// Lower multiple number of Source.
160 	///
161 	/// @tparam genType Floating-point or integer scalar or vector types.
162 	/// @param Source
163 	/// @param Multiple Must be a null or positive value
164 	///
165 	/// @see gtc_round
166 	template <typename T, precision P, template <typename, precision> class vecType>
167 	GLM_FUNC_DECL vecType<T, P> roundMultiple(
168 		vecType<T, P> const & Source,
169 		vecType<T, P> const & Multiple);
170 
171 	/// @}
172 } //namespace glm
173 
174 #include "round.inl"
175