diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 9a10d075..ea820d1c 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -118,4 +118,16 @@ namespace psemek::geom return std::atan2(y, x); } + template + T idiv(T x, T m) + { + return (x >= 0) ? (x / m) : -((- x + m - 1) / m); + } + + template + T imod(T x, T m) + { + return x - m * idiv(x, m); + } + }