Browse Source

- Added EXT_vector_relational: openBounded and closeBounded

Christophe Riccio 8 years ago
parent
commit
bfa6c9e192
3 changed files with 33 additions and 0 deletions
  1. 20 0
      glm/ext/vector_relational.hpp
  2. 12 0
      glm/ext/vector_relational.inl
  3. 1 0
      readme.md

+ 20 - 0
glm/ext/vector_relational.hpp

@@ -87,6 +87,26 @@ namespace glm
 	template<typename genType>
 	GLM_FUNC_DECL bool notEqual(genType const& x, genType const& y, genType const& epsilon);
 
+	/// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets.
+	///
+	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
+	/// @tparam T Floating-point or integer scalar types
+	/// @tparam Q Value from qualifier enum
+	///
+	/// @see ext_vector_relational
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_DECL vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
+
+	/// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets.
+	///
+	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
+	/// @tparam T Floating-point or integer scalar types
+	/// @tparam Q Value from qualifier enum
+	///
+	/// @see ext_vector_relational
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_DECL vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
+
 	/// @}
 }//namespace glm
 

+ 12 - 0
glm/ext/vector_relational.inl

@@ -43,4 +43,16 @@ namespace glm
 	{
 		return greaterThanEqual(abs(x - y), epsilon);
 	}
+
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_QUALIFIER vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
+	{
+		return greaterThan(Value, Min) && lessThan(Value, Max);
+	}
+
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_QUALIFIER vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
+	{
+		return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max);
+	}
 }//namespace glm

+ 1 - 0
readme.md

@@ -64,6 +64,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
 - Added quatLookAt to GTX_quaternion #659
 - Added fmin, fmax and fclamp to GTX_extended_min_max #372
 - Added EXT_vector_relational: extend equal and notEqual to take an epsilon argument
+- Added EXT_vector_relational: openBounded and closeBounded
 - Added EXT_vec1: *vec1 types
 - Added GTX_texture: levels function