From 63662124d5ee8aebe24174b4ddfe7fe89f2de17f Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 29 Jun 2022 12:12:27 +0300 Subject: [PATCH] Add geom::half_open_contains --- libs/geom/include/psemek/geom/contains.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/geom/include/psemek/geom/contains.hpp b/libs/geom/include/psemek/geom/contains.hpp index 3fb65f00..579e1fe1 100644 --- a/libs/geom/include/psemek/geom/contains.hpp +++ b/libs/geom/include/psemek/geom/contains.hpp @@ -24,6 +24,21 @@ namespace psemek::geom return true; } + template + bool half_open_contains(interval const & i, T const & x) + { + return (i.min <= x) && (x < i.max); + } + + template + bool half_open_contains(box const & b, point const & p) + { + for (std::size_t i = 0; i < N; ++i) + if (!half_open_contains(b[i], p[i])) + return false; + return true; + } + template bool contains(simplex, 2> const & t, point const & p) {