master
ブランチ master
ShaderPlayground / deps / glm / glm / gtc / round.hpp
6.7 KB、202行 生 Blame 履歴
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/// Include <glm/gtc/round.hpp> to use the features of this extension.
11///
12/// Rounding value to specific boundings
13
14#pragma once
15
16// Dependencies
17#include "../detail/setup.hpp"
18#include "../detail/qualifier.hpp"
19#include "../detail/_vectorize.hpp"
20#include "../vector_relational.hpp"
21#include "../common.hpp"
22#include <limits>
23
24#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
25# pragma message("GLM: GLM_GTC_integer extension included")
26#endif
27
28namespace 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 v);
38
39 /// Return true if the value is a power of two number.
40 ///
41 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
42 /// @tparam T Floating-point or integer scalar types
43 /// @tparam Q Value from qualifier enum
44 ///
45 /// @see gtc_round
46 template<length_t L, typename T, qualifier Q>
47 GLM_FUNC_DECL vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& v);
48
49 /// Return the power of two number which value is just higher the input value,
50 /// round up to a power of two.
51 ///
52 /// @see gtc_round
53 template<typename genIUType>
54 GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType v);
55
56 /// Return the power of two number which value is just higher the input value,
57 /// round up to a power of two.
58 ///
59 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
60 /// @tparam T Floating-point or integer scalar types
61 /// @tparam Q Value from qualifier enum
62 ///
63 /// @see gtc_round
64 template<length_t L, typename T, qualifier Q>
65 GLM_FUNC_DECL vec<L, T, Q> ceilPowerOfTwo(vec<L, T, Q> const& v);
66
67 /// Return the power of two number which value is just lower the input value,
68 /// round down to a power of two.
69 ///
70 /// @see gtc_round
71 template<typename genIUType>
72 GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType v);
73
74 /// Return the power of two number which value is just lower the input value,
75 /// round down to a power of two.
76 ///
77 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
78 /// @tparam T Floating-point or integer scalar types
79 /// @tparam Q Value from qualifier enum
80 ///
81 /// @see gtc_round
82 template<length_t L, typename T, qualifier Q>
83 GLM_FUNC_DECL vec<L, T, Q> floorPowerOfTwo(vec<L, T, Q> const& v);
84
85 /// Return the power of two number which value is the closet to the input value.
86 ///
87 /// @see gtc_round
88 template<typename genIUType>
89 GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType v);
90
91 /// Return the power of two number which value is the closet to the input value.
92 ///
93 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
94 /// @tparam T Floating-point or integer scalar types
95 /// @tparam Q Value from qualifier enum
96 ///
97 /// @see gtc_round
98 template<length_t L, typename T, qualifier Q>
99 GLM_FUNC_DECL vec<L, T, Q> roundPowerOfTwo(vec<L, T, Q> const& v);
100
101 /// Return true if the 'Value' is a multiple of 'Multiple'.
102 ///
103 /// @see gtc_round
104 template<typename genIUType>
105 GLM_FUNC_DECL bool isMultiple(genIUType v, genIUType Multiple);
106
107 /// Return true if the 'Value' is a multiple of 'Multiple'.
108 ///
109 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
110 /// @tparam T Floating-point or integer scalar types
111 /// @tparam Q Value from qualifier enum
112 ///
113 /// @see gtc_round
114 template<length_t L, typename T, qualifier Q>
115 GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, T Multiple);
116
117 /// Return true if the 'Value' is a multiple of 'Multiple'.
118 ///
119 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
120 /// @tparam T Floating-point or integer scalar types
121 /// @tparam Q Value from qualifier enum
122 ///
123 /// @see gtc_round
124 template<length_t L, typename T, qualifier Q>
125 GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
126
127 /// Higher multiple number of Source.
128 ///
129 /// @tparam genType Floating-point or integer scalar or vector types.
130 ///
131 /// @param v Source value to which is applied the function
132 /// @param Multiple Must be a null or positive value
133 ///
134 /// @see gtc_round
135 template<typename genType>
136 GLM_FUNC_DECL genType ceilMultiple(genType v, genType Multiple);
137
138 /// Higher multiple number of Source.
139 ///
140 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
141 /// @tparam T Floating-point or integer scalar types
142 /// @tparam Q Value from qualifier enum
143 ///
144 /// @param v Source values to which is applied the function
145 /// @param Multiple Must be a null or positive value
146 ///
147 /// @see gtc_round
148 template<length_t L, typename T, qualifier Q>
149 GLM_FUNC_DECL vec<L, T, Q> ceilMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
150
151 /// Lower multiple number of Source.
152 ///
153 /// @tparam genType Floating-point or integer scalar or vector types.
154 ///
155 /// @param v Source value to which is applied the function
156 /// @param Multiple Must be a null or positive value
157 ///
158 /// @see gtc_round
159 template<typename genType>
160 GLM_FUNC_DECL genType floorMultiple(genType v, genType Multiple);
161
162 /// Lower multiple number of Source.
163 ///
164 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
165 /// @tparam T Floating-point or integer scalar types
166 /// @tparam Q Value from qualifier enum
167 ///
168 /// @param v Source values to which is applied the function
169 /// @param Multiple Must be a null or positive value
170 ///
171 /// @see gtc_round
172 template<length_t L, typename T, qualifier Q>
173 GLM_FUNC_DECL vec<L, T, Q> floorMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
174
175 /// Lower multiple number of Source.
176 ///
177 /// @tparam genType Floating-point or integer scalar or vector types.
178 ///
179 /// @param v Source value to which is applied the function
180 /// @param Multiple Must be a null or positive value
181 ///
182 /// @see gtc_round
183 template<typename genType>
184 GLM_FUNC_DECL genType roundMultiple(genType v, genType Multiple);
185
186 /// Lower multiple number of Source.
187 ///
188 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
189 /// @tparam T Floating-point or integer scalar types
190 /// @tparam Q Value from qualifier enum
191 ///
192 /// @param v Source values to which is applied the function
193 /// @param Multiple Must be a null or positive value
194 ///
195 /// @see gtc_round
196 template<length_t L, typename T, qualifier Q>
197 GLM_FUNC_DECL vec<L, T, Q> roundMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
198
199 /// @}
200} //namespace glm
201
202#include "round.inl"