Skip to content

Commit

Permalink
An auxiliary function to check if a point is in a bounding box.
Browse files Browse the repository at this point in the history
  • Loading branch information
LogashenkoDL committed Sep 5, 2024
1 parent f1ae533 commit 617b0ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ugbase/common/math/math_vector_matrix/math_vector_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename vector_t>
inline
bool
VecIsInBB(const vector_t& v, const vector_t& low, const vector_t& high);

}// end of namespace

////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename vector_t>
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__ */
Expand Down

0 comments on commit 617b0ff

Please sign in to comment.