vector_common.inl 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "../detail/_vectorize.hpp"
  2. namespace glm
  3. {
  4. template<length_t L, typename T, qualifier Q>
  5. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& z)
  6. {
  7. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'min' only accept floating-point or integer inputs");
  8. return glm::min(glm::min(x, y), z);
  9. }
  10. template<length_t L, typename T, qualifier Q>
  11. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& z, vec<L, T, Q> const& w)
  12. {
  13. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'min' only accept floating-point or integer inputs");
  14. return glm::min(glm::min(x, y), glm::min(z, w));
  15. }
  16. template<length_t L, typename T, qualifier Q>
  17. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> max(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& z)
  18. {
  19. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'max' only accept floating-point or integer inputs");
  20. return glm::max(glm::max(x, y), z);
  21. }
  22. template<length_t L, typename T, qualifier Q>
  23. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, T, Q> max(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, T, Q> const& z, vec<L, T, Q> const& w)
  24. {
  25. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'max' only accept floating-point or integer inputs");
  26. return glm::max(glm::max(x, y), glm::max(z, w));
  27. }
  28. template<length_t L, typename T, qualifier Q>
  29. GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, T b)
  30. {
  31. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmin' only accept floating-point inputs");
  32. return detail::functor2<vec, L, T, Q>::call(fmin, a, vec<L, T, Q>(b));
  33. }
  34. template<length_t L, typename T, qualifier Q>
  35. GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
  36. {
  37. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmin' only accept floating-point inputs");
  38. return detail::functor2<vec, L, T, Q>::call(fmin, a, b);
  39. }
  40. template<length_t L, typename T, qualifier Q>
  41. GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c)
  42. {
  43. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmin' only accept floating-point inputs");
  44. return fmin(fmin(a, b), c);
  45. }
  46. template<length_t L, typename T, qualifier Q>
  47. GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c, vec<L, T, Q> const& d)
  48. {
  49. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmin' only accept floating-point inputs");
  50. return fmin(fmin(a, b), fmin(c, d));
  51. }
  52. template<length_t L, typename T, qualifier Q>
  53. GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, T b)
  54. {
  55. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmax' only accept floating-point inputs");
  56. return detail::functor2<vec, L, T, Q>::call(fmax, a, vec<L, T, Q>(b));
  57. }
  58. template<length_t L, typename T, qualifier Q>
  59. GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
  60. {
  61. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmax' only accept floating-point inputs");
  62. return detail::functor2<vec, L, T, Q>::call(fmax, a, b);
  63. }
  64. template<length_t L, typename T, qualifier Q>
  65. GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c)
  66. {
  67. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmax' only accept floating-point inputs");
  68. return fmax(fmax(a, b), c);
  69. }
  70. template<length_t L, typename T, qualifier Q>
  71. GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c, vec<L, T, Q> const& d)
  72. {
  73. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fmax' only accept floating-point inputs");
  74. return fmax(fmax(a, b), fmax(c, d));
  75. }
  76. }//namespace glm