round.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. #pragma once
  14. // Dependencies
  15. #include "../detail/setup.hpp"
  16. #include "../detail/qualifier.hpp"
  17. #include "../detail/_vectorize.hpp"
  18. #include "../vector_relational.hpp"
  19. #include "../common.hpp"
  20. #include <limits>
  21. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  22. # pragma message("GLM: GLM_GTC_round extension included")
  23. #endif
  24. namespace glm
  25. {
  26. /// @addtogroup gtc_round
  27. /// @{
  28. /// Return the power of two number which value is just higher the input value,
  29. /// round up to a power of two.
  30. ///
  31. /// @see gtc_round
  32. template<typename genIUType>
  33. GLM_FUNC_DECL genIUType ceilPowerOfTwo(genIUType v);
  34. /// Return the power of two number which value is just higher the input value,
  35. /// round up to a power of two.
  36. ///
  37. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  38. /// @tparam T Floating-point or integer scalar types
  39. /// @tparam Q Value from qualifier enum
  40. ///
  41. /// @see gtc_round
  42. template<length_t L, typename T, qualifier Q>
  43. GLM_FUNC_DECL vec<L, T, Q> ceilPowerOfTwo(vec<L, T, Q> const& v);
  44. /// Return the power of two number which value is just lower the input value,
  45. /// round down to a power of two.
  46. ///
  47. /// @see gtc_round
  48. template<typename genIUType>
  49. GLM_FUNC_DECL genIUType floorPowerOfTwo(genIUType v);
  50. /// Return the power of two number which value is just lower the input value,
  51. /// round down to a power of two.
  52. ///
  53. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  54. /// @tparam T Floating-point or integer scalar types
  55. /// @tparam Q Value from qualifier enum
  56. ///
  57. /// @see gtc_round
  58. template<length_t L, typename T, qualifier Q>
  59. GLM_FUNC_DECL vec<L, T, Q> floorPowerOfTwo(vec<L, T, Q> const& v);
  60. /// Return the power of two number which value is the closet to the input value.
  61. ///
  62. /// @see gtc_round
  63. template<typename genIUType>
  64. GLM_FUNC_DECL genIUType roundPowerOfTwo(genIUType v);
  65. /// Return the power of two number which value is the closet to the input value.
  66. ///
  67. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  68. /// @tparam T Floating-point or integer scalar types
  69. /// @tparam Q Value from qualifier enum
  70. ///
  71. /// @see gtc_round
  72. template<length_t L, typename T, qualifier Q>
  73. GLM_FUNC_DECL vec<L, T, Q> roundPowerOfTwo(vec<L, T, Q> const& v);
  74. /// Higher multiple number of Source.
  75. ///
  76. /// @tparam genType Floating-point or integer scalar or vector types.
  77. ///
  78. /// @param v Source value to which is applied the function
  79. /// @param Multiple Must be a null or positive value
  80. ///
  81. /// @see gtc_round
  82. template<typename genType>
  83. GLM_FUNC_DECL genType ceilMultiple(genType v, genType Multiple);
  84. /// Higher multiple number of Source.
  85. ///
  86. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  87. /// @tparam T Floating-point or integer scalar types
  88. /// @tparam Q Value from qualifier enum
  89. ///
  90. /// @param v Source values to which is applied the function
  91. /// @param Multiple Must be a null or positive value
  92. ///
  93. /// @see gtc_round
  94. template<length_t L, typename T, qualifier Q>
  95. GLM_FUNC_DECL vec<L, T, Q> ceilMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  96. /// Lower multiple number of Source.
  97. ///
  98. /// @tparam genType Floating-point or integer scalar or vector types.
  99. ///
  100. /// @param v Source value to which is applied the function
  101. /// @param Multiple Must be a null or positive value
  102. ///
  103. /// @see gtc_round
  104. template<typename genType>
  105. GLM_FUNC_DECL genType floorMultiple(genType v, genType Multiple);
  106. /// Lower multiple number of Source.
  107. ///
  108. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  109. /// @tparam T Floating-point or integer scalar types
  110. /// @tparam Q Value from qualifier enum
  111. ///
  112. /// @param v Source values to which is applied the function
  113. /// @param Multiple Must be a null or positive value
  114. ///
  115. /// @see gtc_round
  116. template<length_t L, typename T, qualifier Q>
  117. GLM_FUNC_DECL vec<L, T, Q> floorMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  118. /// Lower multiple number of Source.
  119. ///
  120. /// @tparam genType Floating-point or integer scalar or vector types.
  121. ///
  122. /// @param v Source value to which is applied the function
  123. /// @param Multiple Must be a null or positive value
  124. ///
  125. /// @see gtc_round
  126. template<typename genType>
  127. GLM_FUNC_DECL genType roundMultiple(genType v, genType Multiple);
  128. /// Lower multiple number of Source.
  129. ///
  130. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  131. /// @tparam T Floating-point or integer scalar types
  132. /// @tparam Q Value from qualifier enum
  133. ///
  134. /// @param v Source values to which is applied the function
  135. /// @param Multiple Must be a null or positive value
  136. ///
  137. /// @see gtc_round
  138. template<length_t L, typename T, qualifier Q>
  139. GLM_FUNC_DECL vec<L, T, Q> roundMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  140. /// @}
  141. } //namespace glm
  142. #include "round.inl"