From c1d9095327c2fb6a4c5419542bac4556477eb1ad Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 21 Oct 2020 22:23:57 +0300 Subject: [PATCH] Change geom::length behavior: always (max-min), even if empty --- libs/geom/include/psemek/geom/interval.hpp | 2 +- libs/geom/include/psemek/geom/orthographic.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/geom/include/psemek/geom/interval.hpp b/libs/geom/include/psemek/geom/interval.hpp index 461733d3..7e013ba6 100644 --- a/libs/geom/include/psemek/geom/interval.hpp +++ b/libs/geom/include/psemek/geom/interval.hpp @@ -91,7 +91,7 @@ namespace psemek::geom T length() const { - return empty() ? T{} : max - min; + return max - min; } T center() const diff --git a/libs/geom/include/psemek/geom/orthographic.hpp b/libs/geom/include/psemek/geom/orthographic.hpp index e9e303c4..b3cd224b 100644 --- a/libs/geom/include/psemek/geom/orthographic.hpp +++ b/libs/geom/include/psemek/geom/orthographic.hpp @@ -79,10 +79,10 @@ namespace psemek::geom auto m = matrix::zero(); for (std::size_t d = 0; d < D; ++d) - m[d][d] = T(2) / (r_[d].max - r_[d].min); + m[d][d] = T(2) / r_[d].length(); for (std::size_t d = 0; d < D; ++d) - m[d][D] = - (r_[d].max + r_[d].min) / (r_[d].max - r_[d].min); + m[d][D] = - (r_[d].max + r_[d].min) / r_[d].length(); m[D][D] = T(1);