diff --git a/ugbase/common/math/math_vector_matrix/math_vector_functions.h b/ugbase/common/math/math_vector_matrix/math_vector_functions.h index 87bfee811..908cd2d0a 100644 --- a/ugbase/common/math/math_vector_matrix/math_vector_functions.h +++ b/ugbase/common/math/math_vector_matrix/math_vector_functions.h @@ -405,6 +405,12 @@ inline bool VecAbsIsLess(const vector_t& v1, const typename vector_t::value_type s); +/// checks if the given point is in the bounding box given by two other points +template +inline +bool +VecIsInBB(const vector_t& v, const vector_t& low, const vector_t& high); + }// end of namespace //////////////////////////////////////////////////////////////////////// diff --git a/ugbase/common/math/math_vector_matrix/math_vector_functions_common_impl.hpp b/ugbase/common/math/math_vector_matrix/math_vector_functions_common_impl.hpp index 5be0bfa8c..6749dfeee 100644 --- a/ugbase/common/math/math_vector_matrix/math_vector_functions_common_impl.hpp +++ b/ugbase/common/math/math_vector_matrix/math_vector_functions_common_impl.hpp @@ -694,6 +694,18 @@ VecAbsIsLess(const vector_t& v1, const typename vector_t::value_type s) return true; } +/// checks if the given point is in the bounding box given by two other points +template +inline +bool +VecIsInBB(const vector_t& v, const vector_t& low, const vector_t& high) +{ + for(typename vector_t::size_type i = 0; i < v.size(); ++i) + if (v[i] < low[i] || high[i] < v[i]) + return false; + return true; +} + }// end of namespace #endif /* __H__COMMON__MathVector_FUNCTIONS_COMMON_IMPL__ */