| 1 | /// @ref ext_vector_common |
| 2 | /// @file glm/ext/vector_common.hpp |
| 3 | /// |
| 4 | /// @defgroup ext_vector_common GLM_EXT_vector_common |
| 5 | /// @ingroup ext |
| 6 | /// |
| 7 | /// Exposes min and max functions for 3 to 4 vector parameters. |
| 8 | /// |
| 9 | /// Include <glm/ext/vector_common.hpp> to use the features of this extension. |
| 10 | /// |
| 11 | /// @see core_common |
| 12 | /// @see ext_scalar_common |
| 13 | |
| 14 | #pragma once |
| 15 | |
| 16 | // Dependency: |
| 17 | #include "../ext/scalar_common.hpp" |
| 18 | #include "../common.hpp" |
| 19 | |
| 20 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
| 21 | # pragma message("GLM: GLM_EXT_vector_common extension included") |
| 22 | #endif |
| 23 | |
| 24 | namespace glm |
| 25 | { |
| 26 | /// @addtogroup ext_vector_common |
| 27 | /// @{ |
| 28 | |
| 29 | /// Return the minimum component-wise values of 3 inputs |
| 30 | /// |
| 31 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 32 | /// @tparam T Floating-point or integer scalar types |
| 33 | /// @tparam Q Value from qualifier enum |
| 34 | template<length_t L, typename T, qualifier Q> |
| 35 | GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c); |
| 36 | |
| 37 | /// Return the minimum component-wise values of 4 inputs |
| 38 | /// |
| 39 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 40 | /// @tparam T Floating-point or integer scalar types |
| 41 | /// @tparam Q Value from qualifier enum |
| 42 | template<length_t L, typename T, qualifier Q> |
| 43 | GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> min(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c, vec<L, T, Q> const& d); |
| 44 | |
| 45 | /// Return the maximum component-wise values of 3 inputs |
| 46 | /// |
| 47 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 48 | /// @tparam T Floating-point or integer scalar types |
| 49 | /// @tparam Q Value from qualifier enum |
| 50 | template<length_t L, typename T, qualifier Q> |
| 51 | GLM_FUNC_DECL 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); |
| 52 | |
| 53 | /// Return the maximum component-wise values of 4 inputs |
| 54 | /// |
| 55 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 56 | /// @tparam T Floating-point or integer scalar types |
| 57 | /// @tparam Q Value from qualifier enum |
| 58 | template<length_t L, typename T, qualifier Q> |
| 59 | GLM_FUNC_DECL 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); |
| 60 | |
| 61 | /// 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. |
| 62 | /// |
| 63 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 64 | /// @tparam T Floating-point scalar types |
| 65 | /// @tparam Q Value from qualifier enum |
| 66 | /// |
| 67 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a> |
| 68 | template<length_t L, typename T, qualifier Q> |
| 69 | GLM_FUNC_DECL vec<L, T, Q> fmin(vec<L, T, Q> const& x, T y); |
| 70 | |
| 71 | /// 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. |
| 72 | /// |
| 73 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 74 | /// @tparam T Floating-point scalar types |
| 75 | /// @tparam Q Value from qualifier enum |
| 76 | /// |
| 77 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a> |
| 78 | template<length_t L, typename T, qualifier Q> |
| 79 | GLM_FUNC_DECL vec<L, T, Q> fmin(vec<L, T, Q> const& x, vec<L, T, Q> const& y); |
| 80 | |
| 81 | /// 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. |
| 82 | /// |
| 83 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 84 | /// @tparam T Floating-point scalar types |
| 85 | /// @tparam Q Value from qualifier enum |
| 86 | /// |
| 87 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a> |
| 88 | template<length_t L, typename T, qualifier Q> |
| 89 | GLM_FUNC_DECL vec<L, T, Q> fmin(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c); |
| 90 | |
| 91 | /// 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. |
| 92 | /// |
| 93 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 94 | /// @tparam T Floating-point scalar types |
| 95 | /// @tparam Q Value from qualifier enum |
| 96 | /// |
| 97 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmin">std::fmin documentation</a> |
| 98 | template<length_t L, typename T, qualifier Q> |
| 99 | GLM_FUNC_DECL 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); |
| 100 | |
| 101 | /// 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. |
| 102 | /// |
| 103 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 104 | /// @tparam T Floating-point scalar types |
| 105 | /// @tparam Q Value from qualifier enum |
| 106 | /// |
| 107 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a> |
| 108 | template<length_t L, typename T, qualifier Q> |
| 109 | GLM_FUNC_DECL vec<L, T, Q> fmax(vec<L, T, Q> const& a, T b); |
| 110 | |
| 111 | /// 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. |
| 112 | /// |
| 113 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 114 | /// @tparam T Floating-point scalar types |
| 115 | /// @tparam Q Value from qualifier enum |
| 116 | /// |
| 117 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a> |
| 118 | template<length_t L, typename T, qualifier Q> |
| 119 | GLM_FUNC_DECL vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b); |
| 120 | |
| 121 | /// 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. |
| 122 | /// |
| 123 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 124 | /// @tparam T Floating-point scalar types |
| 125 | /// @tparam Q Value from qualifier enum |
| 126 | /// |
| 127 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a> |
| 128 | template<length_t L, typename T, qualifier Q> |
| 129 | GLM_FUNC_DECL vec<L, T, Q> fmax(vec<L, T, Q> const& a, vec<L, T, Q> const& b, vec<L, T, Q> const& c); |
| 130 | |
| 131 | /// 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. |
| 132 | /// |
| 133 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 134 | /// @tparam T Floating-point scalar types |
| 135 | /// @tparam Q Value from qualifier enum |
| 136 | /// |
| 137 | /// @see <a href="http://en.cppreference.com/w/cpp/numeric/math/fmax">std::fmax documentation</a> |
| 138 | template<length_t L, typename T, qualifier Q> |
| 139 | GLM_FUNC_DECL 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); |
| 140 | |
| 141 | /// 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. |
| 142 | /// |
| 143 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 144 | /// @tparam T Floating-point scalar types |
| 145 | /// @tparam Q Value from qualifier enum |
| 146 | /// |
| 147 | /// @see ext_vector_common |
| 148 | template<length_t L, typename T, qualifier Q> |
| 149 | GLM_FUNC_DECL vec<L, T, Q> fclamp(vec<L, T, Q> const& x, T minVal, T maxVal); |
| 150 | |
| 151 | /// 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. |
| 152 | /// |
| 153 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 154 | /// @tparam T Floating-point scalar types |
| 155 | /// @tparam Q Value from qualifier enum |
| 156 | /// |
| 157 | /// @see ext_vector_common |
| 158 | template<length_t L, typename T, qualifier Q> |
| 159 | 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); |
| 160 | |
| 161 | /// Simulate GL_CLAMP OpenGL wrap mode |
| 162 | /// |
| 163 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 164 | /// @tparam T Floating-point scalar types |
| 165 | /// @tparam Q Value from qualifier enum |
| 166 | /// |
| 167 | /// @see ext_vector_common extension. |
| 168 | template<length_t L, typename T, qualifier Q> |
| 169 | GLM_FUNC_DECL vec<L, T, Q> clamp(vec<L, T, Q> const& Texcoord); |
| 170 | |
| 171 | /// Simulate GL_REPEAT OpenGL wrap mode |
| 172 | /// |
| 173 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 174 | /// @tparam T Floating-point scalar types |
| 175 | /// @tparam Q Value from qualifier enum |
| 176 | /// |
| 177 | /// @see ext_vector_common extension. |
| 178 | template<length_t L, typename T, qualifier Q> |
| 179 | GLM_FUNC_DECL vec<L, T, Q> repeat(vec<L, T, Q> const& Texcoord); |
| 180 | |
| 181 | /// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode |
| 182 | /// |
| 183 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 184 | /// @tparam T Floating-point scalar types |
| 185 | /// @tparam Q Value from qualifier enum |
| 186 | /// |
| 187 | /// @see ext_vector_common extension. |
| 188 | template<length_t L, typename T, qualifier Q> |
| 189 | GLM_FUNC_DECL vec<L, T, Q> mirrorClamp(vec<L, T, Q> const& Texcoord); |
| 190 | |
| 191 | /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode |
| 192 | /// |
| 193 | /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector |
| 194 | /// @tparam T Floating-point scalar types |
| 195 | /// @tparam Q Value from qualifier enum |
| 196 | /// |
| 197 | /// @see ext_vector_common extension. |
| 198 | template<length_t L, typename T, qualifier Q> |
| 199 | GLM_FUNC_DECL vec<L, T, Q> mirrorRepeat(vec<L, T, Q> const& Texcoord); |
| 200 | |
| 201 | /// Returns a value equal to the nearest integer to x. |
| 202 | /// The fraction 0.5 will round in a direction chosen by the |
| 203 | /// implementation, presumably the direction that is fastest. |
| 204 | /// |
| 205 | /// @param x The values of the argument must be greater or equal to zero. |
| 206 | /// @tparam T floating point scalar types. |
| 207 | /// |
| 208 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a> |
| 209 | /// @see ext_vector_common extension. |
| 210 | template<length_t L, typename T, qualifier Q> |
| 211 | GLM_FUNC_DECL vec<L, int, Q> iround(vec<L, T, Q> const& x); |
| 212 | |
| 213 | /// Returns a value equal to the nearest integer to x. |
| 214 | /// The fraction 0.5 will round in a direction chosen by the |
| 215 | /// implementation, presumably the direction that is fastest. |
| 216 | /// |
| 217 | /// @param x The values of the argument must be greater or equal to zero. |
| 218 | /// @tparam T floating point scalar types. |
| 219 | /// |
| 220 | /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a> |
| 221 | /// @see ext_vector_common extension. |
| 222 | template<length_t L, typename T, qualifier Q> |
| 223 | GLM_FUNC_DECL vec<L, uint, Q> uround(vec<L, T, Q> const& x); |
| 224 | |
| 225 | /// @} |
| 226 | }//namespace glm |
| 227 | |
| 228 | #include "vector_common.inl" |