diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 85b900a5..5be880fe 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -32,6 +32,30 @@ namespace psemek::geom return x0 * (T(1) - t) + x1 * t; } + namespace detail + { + + template + auto lerpn_impl(P &, P const &) + {} + + template + auto lerpn_impl(P & res, P const & o, P const & p, T const & t, Args const & ... args) + { + res += t * (p - o); + lerpn_impl(res, o, args...); + } + + } + + template + auto lerpn(P const & p, T const &, Args const & ... args) + { + P res = p; + detail::lerpn_impl(res, p, args...); + return res; + } + // roots of ax^2 + bx + c = 0 // in increasing order template