From d5495a52cef11e4a0b0250fc7b7aef2ea7e18a79 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 29 Nov 2020 12:24:52 +0300 Subject: [PATCH] Add geom::sign function --- libs/geom/include/psemek/geom/math.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 5be880fe..1ef70b72 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -8,6 +8,17 @@ namespace psemek::geom { + template + T sign(T const & x) + { + if (x > 0) + return 1; + else if (x < 0) + return -1; + else + return 0; + } + template auto sqr(T const & x) {