From 32461e205e2033e16f83b0d9d7d8db0ddfefa1b1 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 4 Mar 2021 10:01:49 +0300 Subject: [PATCH] Add geom::clamp(point, box) --- libs/geom/include/psemek/geom/box.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/geom/include/psemek/geom/box.hpp b/libs/geom/include/psemek/geom/box.hpp index fb8149c0..c91bae2f 100644 --- a/libs/geom/include/psemek/geom/box.hpp +++ b/libs/geom/include/psemek/geom/box.hpp @@ -252,6 +252,14 @@ namespace psemek::geom return os; } + template + point clamp(point p, box const & b) + { + for (std::size_t i = 0; i < N; ++i) + p[i] = clamp(p[i], b[i]); + return p; + } + template box expand(box b, T const & d) {