123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- /// @ref gtx_extended_min_max
- namespace glm
- {
- template<typename T>
- GLM_FUNC_QUALIFIER T min(
- T const& x,
- T const& y,
- T const& z)
- {
- return glm::min(glm::min(x, y), z);
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> min
- (
- C<T> const& x,
- typename C<T>::T const& y,
- typename C<T>::T const& z
- )
- {
- return glm::min(glm::min(x, y), z);
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> min
- (
- C<T> const& x,
- C<T> const& y,
- C<T> const& z
- )
- {
- return glm::min(glm::min(x, y), z);
- }
- template<typename T>
- GLM_FUNC_QUALIFIER T min
- (
- T const& x,
- T const& y,
- T const& z,
- T const& w
- )
- {
- return glm::min(glm::min(x, y), glm::min(z, w));
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> min
- (
- C<T> const& x,
- typename C<T>::T const& y,
- typename C<T>::T const& z,
- typename C<T>::T const& w
- )
- {
- return glm::min(glm::min(x, y), glm::min(z, w));
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> min
- (
- C<T> const& x,
- C<T> const& y,
- C<T> const& z,
- C<T> const& w
- )
- {
- return glm::min(glm::min(x, y), glm::min(z, w));
- }
- template<typename T>
- GLM_FUNC_QUALIFIER T max(
- T const& x,
- T const& y,
- T const& z)
- {
- return glm::max(glm::max(x, y), z);
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> max
- (
- C<T> const& x,
- typename C<T>::T const& y,
- typename C<T>::T const& z
- )
- {
- return glm::max(glm::max(x, y), z);
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> max
- (
- C<T> const& x,
- C<T> const& y,
- C<T> const& z
- )
- {
- return glm::max(glm::max(x, y), z);
- }
- template<typename T>
- GLM_FUNC_QUALIFIER T max
- (
- T const& x,
- T const& y,
- T const& z,
- T const& w
- )
- {
- return glm::max(glm::max(x, y), glm::max(z, w));
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> max
- (
- C<T> const& x,
- typename C<T>::T const& y,
- typename C<T>::T const& z,
- typename C<T>::T const& w
- )
- {
- return glm::max(glm::max(x, y), glm::max(z, w));
- }
- template<typename T, template<typename> class C>
- GLM_FUNC_QUALIFIER C<T> max
- (
- C<T> const& x,
- C<T> const& y,
- C<T> const& z,
- C<T> const& w
- )
- {
- return glm::max(glm::max(x, y), glm::max(z, w));
- }
- // fmin
- # if GLM_HAS_CXX11_STL
- using std::fmin;
- # else
- template<typename genType>
- GLM_FUNC_QUALIFIER genType fmin(genType x, genType y)
- {
- GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmin' only accept floating-point input");
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- return min(x, y);
- }
- # endif
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, T b)
- {
- return detail::functor2<vec, L, T, Q>::call(fmin, a, vec<L, T, Q>(b));
- }
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fmin(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
- {
- return detail::functor2<vec, L, T, Q>::call(fmin, a, b);
- }
- // fmax
- # if GLM_HAS_CXX11_STL
- using std::fmax;
- # else
- template<typename genType>
- GLM_FUNC_QUALIFIER genType fmax(genType x, genType y)
- {
- GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmax' only accept floating-point input");
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- return max(x, y);
- }
- # endif
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, T b)
- {
- return detail::functor2<vec, L, T, Q>::call(fmax, a, vec<L, T, Q>(b));
- }
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
- {
- return detail::functor2<vec, L, T, Q>::call(fmax, a, b);
- }
- // fclamp
- template<typename genType>
- GLM_FUNC_QUALIFIER genType fclamp(genType x, genType minVal, genType maxVal)
- {
- GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fclamp' only accept floating-point or integer inputs");
- return fmin(fmax(x, minVal), maxVal);
- }
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fclamp(vec<L, T, Q> const& x, T minVal, T maxVal)
- {
- return fmin(fmax(x, vec<L, T, Q>(minVal)), vec<L, T, Q>(maxVal));
- }
- template<length_t L, typename T, qualifier Q>
- GLM_FUNC_QUALIFIER vec<L, T, Q> fclamp(vec<L, T, Q> const& x, vec<L, T, Q> const& minVal, vec<L, T, Q> const& maxVal)
- {
- return fmin(fmax(x, minVal), maxVal);
- }
- }//namespace glm
|