From 451b4c1e6632c1a91192ad766c83057aa965a2d1 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 17 Aug 2021 12:45:41 +0300 Subject: [PATCH] Add geom::sin_over_x --- libs/geom/include/psemek/geom/math.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 573473b8..61f91c44 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -49,6 +49,14 @@ namespace psemek::geom return x0 * (T(1) - t) + x1 * t; } + template + T sin_over_x(T const & x) + { + if (std::abs(x) < std::numeric_limits::epsilon()) + return T{1}; + return std::sin(x) / x; + } + namespace detail {