Add geom::lerpn - n-ary baricentric interpolation
This commit is contained in:
parent
c6fe38989c
commit
75b847ec23
1 changed files with 24 additions and 0 deletions
|
|
@ -32,6 +32,30 @@ namespace psemek::geom
|
|||
return x0 * (T(1) - t) + x1 * t;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename P>
|
||||
auto lerpn_impl(P &, P const &)
|
||||
{}
|
||||
|
||||
template <typename P, typename T, typename ... Args>
|
||||
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 <typename P, typename T, typename ... Args>
|
||||
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 <typename T>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue