extended_min_max.hpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  16. # ifndef GLM_ENABLE_EXPERIMENTAL
  17. # pragma message("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.")
  18. # else
  19. # pragma message("GLM: GLM_GTX_extented_min_max extension included")
  20. # endif
  21. #endif
  22. namespace glm
  23. {
  24. /// @addtogroup gtx_extended_min_max
  25. /// @{
  26. /// Return the minimum component-wise values of 3 inputs
  27. /// @see gtx_extented_min_max
  28. template<typename T>
  29. GLM_FUNC_DECL T min(
  30. T const& x,
  31. T const& y,
  32. T const& z);
  33. /// Return the minimum component-wise values of 3 inputs
  34. /// @see gtx_extented_min_max
  35. template<typename T, template<typename> class C>
  36. GLM_FUNC_DECL C<T> min(
  37. C<T> const& x,
  38. typename C<T>::T const& y,
  39. typename C<T>::T const& z);
  40. /// Return the minimum component-wise values of 3 inputs
  41. /// @see gtx_extented_min_max
  42. template<typename T, template<typename> class C>
  43. GLM_FUNC_DECL C<T> min(
  44. C<T> const& x,
  45. C<T> const& y,
  46. C<T> const& z);
  47. /// Return the minimum component-wise values of 4 inputs
  48. /// @see gtx_extented_min_max
  49. template<typename T>
  50. GLM_FUNC_DECL T min(
  51. T const& x,
  52. T const& y,
  53. T const& z,
  54. T const& w);
  55. /// Return the minimum component-wise values of 4 inputs
  56. /// @see gtx_extented_min_max
  57. template<typename T, template<typename> class C>
  58. GLM_FUNC_DECL C<T> min(
  59. C<T> const& x,
  60. typename C<T>::T const& y,
  61. typename C<T>::T const& z,
  62. typename C<T>::T const& w);
  63. /// Return the minimum component-wise values of 4 inputs
  64. /// @see gtx_extented_min_max
  65. template<typename T, template<typename> class C>
  66. GLM_FUNC_DECL C<T> min(
  67. C<T> const& x,
  68. C<T> const& y,
  69. C<T> const& z,
  70. C<T> const& w);
  71. /// Return the maximum component-wise values of 3 inputs
  72. /// @see gtx_extented_min_max
  73. template<typename T>
  74. GLM_FUNC_DECL T max(
  75. T const& x,
  76. T const& y,
  77. T const& z);
  78. /// Return the maximum component-wise values of 3 inputs
  79. /// @see gtx_extented_min_max
  80. template<typename T, template<typename> class C>
  81. GLM_FUNC_DECL C<T> max(
  82. C<T> const& x,
  83. typename C<T>::T const& y,
  84. typename C<T>::T const& z);
  85. /// Return the maximum component-wise values of 3 inputs
  86. /// @see gtx_extented_min_max
  87. template<typename T, template<typename> class C>
  88. GLM_FUNC_DECL C<T> max(
  89. C<T> const& x,
  90. C<T> const& y,
  91. C<T> const& z);
  92. /// Return the maximum component-wise values of 4 inputs
  93. /// @see gtx_extented_min_max
  94. template<typename T>
  95. GLM_FUNC_DECL T max(
  96. T const& x,
  97. T const& y,
  98. T const& z,
  99. T const& w);
  100. /// Return the maximum component-wise values of 4 inputs
  101. /// @see gtx_extented_min_max
  102. template<typename T, template<typename> class C>
  103. GLM_FUNC_DECL C<T> max(
  104. C<T> const& x,
  105. typename C<T>::T const& y,
  106. typename C<T>::T const& z,
  107. typename C<T>::T const& w);
  108. /// Return the maximum component-wise values of 4 inputs
  109. /// @see gtx_extented_min_max
  110. template<typename T, template<typename> class C>
  111. GLM_FUNC_DECL C<T> max(
  112. C<T> const& x,
  113. C<T> const& y,
  114. C<T> const& z,
  115. C<T> const& w);
  116. /// 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.
  117. ///
  118. /// @tparam genType Floating-point or integer; scalar or vector types.
  119. ///
  120. /// @see gtx_extented_min_max
  121. template<typename genType>
  122. GLM_FUNC_DECL genType fmin(genType x, genType y);
  123. /// 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.
  124. ///
  125. /// @tparam genType Floating-point; scalar or vector types.
  126. ///
  127. /// @see gtx_extented_min_max
  128. /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a>
  129. template<typename genType>
  130. GLM_FUNC_DECL genType fmax(genType x, genType y);
  131. /// 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.
  132. ///
  133. /// @tparam genType Floating-point scalar or vector types.
  134. ///
  135. /// @see gtx_extented_min_max
  136. template<typename genType>
  137. GLM_FUNC_DECL genType fclamp(genType x, genType minVal, genType maxVal);
  138. /// 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.
  139. ///
  140. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  141. /// @tparam T Floating-point scalar types
  142. /// @tparam Q Value from qualifier enum
  143. ///
  144. /// @see gtx_extented_min_max
  145. template<length_t L, typename T, qualifier Q>
  146. GLM_FUNC_DECL vec<L, T, Q> fclamp(vec<L, T, Q> const& x, T minVal, T maxVal);
  147. /// 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.
  148. ///
  149. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  150. /// @tparam T Floating-point scalar types
  151. /// @tparam Q Value from qualifier enum
  152. ///
  153. /// @see gtx_extented_min_max
  154. template<length_t L, typename T, qualifier Q>
  155. 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);
  156. /// @}
  157. }//namespace glm
  158. #include "extended_min_max.inl"