extended_min_max.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /// @ref gtx_extended_min_max
  2. /// @file glm/gtx/extended_min_max.hpp
  3. ///
  4. /// @see core (dependence)
  5. ///
  6. /// @defgroup gtx_extended_min_max GLM_GTX_extented_min_max
  7. /// @ingroup gtx
  8. ///
  9. /// Include <glm/gtx/extented_min_max.hpp> to use the features of this extension.
  10. ///
  11. /// Min and max functions for 3 to 4 parameters.
  12. #pragma once
  13. // Dependency:
  14. #include "../glm.hpp"
  15. #ifndef GLM_ENABLE_EXPERIMENTAL
  16. # error "GLM: GLM_GTX_extented_min_max is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
  17. #endif
  18. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  19. # pragma message("GLM: GLM_GTX_extented_min_max extension included")
  20. #endif
  21. namespace glm
  22. {
  23. /// @addtogroup gtx_extended_min_max
  24. /// @{
  25. /// Return the minimum component-wise values of 3 inputs
  26. /// @see gtx_extented_min_max
  27. template<typename T>
  28. GLM_FUNC_DECL T min(
  29. T const& x,
  30. T const& y,
  31. T const& z);
  32. /// Return the minimum component-wise values of 3 inputs
  33. /// @see gtx_extented_min_max
  34. template<typename T, template<typename> class C>
  35. GLM_FUNC_DECL C<T> min(
  36. C<T> const& x,
  37. typename C<T>::T const& y,
  38. typename C<T>::T const& z);
  39. /// Return the minimum component-wise values of 3 inputs
  40. /// @see gtx_extented_min_max
  41. template<typename T, template<typename> class C>
  42. GLM_FUNC_DECL C<T> min(
  43. C<T> const& x,
  44. C<T> const& y,
  45. C<T> const& z);
  46. /// Return the minimum component-wise values of 4 inputs
  47. /// @see gtx_extented_min_max
  48. template<typename T>
  49. GLM_FUNC_DECL T min(
  50. T const& x,
  51. T const& y,
  52. T const& z,
  53. T const& w);
  54. /// Return the minimum component-wise values of 4 inputs
  55. /// @see gtx_extented_min_max
  56. template<typename T, template<typename> class C>
  57. GLM_FUNC_DECL C<T> min(
  58. C<T> const& x,
  59. typename C<T>::T const& y,
  60. typename C<T>::T const& z,
  61. typename C<T>::T const& w);
  62. /// Return the minimum component-wise values of 4 inputs
  63. /// @see gtx_extented_min_max
  64. template<typename T, template<typename> class C>
  65. GLM_FUNC_DECL C<T> min(
  66. C<T> const& x,
  67. C<T> const& y,
  68. C<T> const& z,
  69. C<T> const& w);
  70. /// Return the maximum component-wise values of 3 inputs
  71. /// @see gtx_extented_min_max
  72. template<typename T>
  73. GLM_FUNC_DECL T max(
  74. T const& x,
  75. T const& y,
  76. T const& z);
  77. /// Return the maximum component-wise values of 3 inputs
  78. /// @see gtx_extented_min_max
  79. template<typename T, template<typename> class C>
  80. GLM_FUNC_DECL C<T> max(
  81. C<T> const& x,
  82. typename C<T>::T const& y,
  83. typename C<T>::T const& z);
  84. /// Return the maximum component-wise values of 3 inputs
  85. /// @see gtx_extented_min_max
  86. template<typename T, template<typename> class C>
  87. GLM_FUNC_DECL C<T> max(
  88. C<T> const& x,
  89. C<T> const& y,
  90. C<T> const& z);
  91. /// Return the maximum component-wise values of 4 inputs
  92. /// @see gtx_extented_min_max
  93. template<typename T>
  94. GLM_FUNC_DECL T max(
  95. T const& x,
  96. T const& y,
  97. T const& z,
  98. T const& w);
  99. /// Return the maximum component-wise values of 4 inputs
  100. /// @see gtx_extented_min_max
  101. template<typename T, template<typename> class C>
  102. GLM_FUNC_DECL C<T> max(
  103. C<T> const& x,
  104. typename C<T>::T const& y,
  105. typename C<T>::T const& z,
  106. typename C<T>::T const& w);
  107. /// Return the maximum component-wise values of 4 inputs
  108. /// @see gtx_extented_min_max
  109. template<typename T, template<typename> class C>
  110. GLM_FUNC_DECL C<T> max(
  111. C<T> const& x,
  112. C<T> const& y,
  113. C<T> const& z,
  114. C<T> const& w);
  115. /// Returns y if y < x; otherwise, it returns x. If one of the two arguments is NaN, the value of the other argument is returned.
  116. ///
  117. /// @tparam genType Floating-point or integer; scalar or vector types.
  118. ///
  119. /// @see gtx_extented_min_max
  120. template<typename genType>
  121. GLM_FUNC_DECL genType fmin(genType x, genType y);
  122. /// Returns y if x < y; otherwise, it returns x. If one of the two arguments is NaN, the value of the other argument is returned.
  123. ///
  124. /// @tparam genType Floating-point; scalar or vector types.
  125. ///
  126. /// @see gtx_extented_min_max
  127. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a>
  128. template<typename genType>
  129. GLM_FUNC_DECL genType fmax(genType x, genType y);
  130. /// Returns min(max(x, minVal), maxVal) for each component in x. If one of the two arguments is NaN, the value of the other argument is returned.
  131. ///
  132. /// @tparam genType Floating-point scalar or vector types.
  133. ///
  134. /// @see gtx_extented_min_max
  135. template<typename genType>
  136. GLM_FUNC_DECL genType fclamp(genType x, genType minVal, genType maxVal);
  137. /// Returns min(max(x, minVal), maxVal) for each component in x. If one of the two arguments is NaN, the value of the other argument is returned.
  138. ///
  139. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  140. /// @tparam T Floating-point scalar types
  141. /// @tparam Q Value from qualifier enum
  142. ///
  143. /// @see gtx_extented_min_max
  144. template<length_t L, typename T, qualifier Q>
  145. GLM_FUNC_DECL vec<L, T, Q> fclamp(vec<L, T, Q> const& x, T minVal, T maxVal);
  146. /// Returns min(max(x, minVal), maxVal) for each component in x. If one of the two arguments is NaN, the value of the other argument is returned.
  147. ///
  148. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  149. /// @tparam T Floating-point scalar types
  150. /// @tparam Q Value from qualifier enum
  151. ///
  152. /// @see gtx_extented_min_max
  153. template<length_t L, typename T, qualifier Q>
  154. GLM_FUNC_DECL vec<L, T, Q> fclamp(vec<L, T, Q> const& x, vec<L, T, Q> const& minVal, vec<L, T, Q> const& maxVal);
  155. /// @}
  156. }//namespace glm
  157. #include "extended_min_max.inl"