3 #include "utilities/mapping_iterator_adapter.h" 18 auto linear_interp(
double x, U a, U b) {
19 return a + x * (b - a);
24 auto operator()(
double x, U a, U b)
const {
25 return linear_interp(x, a, b);
33 auto cosine_interp(
double x, U a, U b) {
34 return linear_interp(std::cos(M_PI * x) * 0.5 + 0.5, b, a);
39 auto operator()(
double x, U a, U b)
const {
40 return cosine_interp(x, a, b);
44 template <
typename T,
typename U,
typename Func>
45 auto interp(
double a, T x1, T x2, U y1, U y2, Func&& func) {
46 return func((a - x1) / (x2 - x1), y1, y2);
51 template <
typename It,
typename Func>
52 auto interp(It b, It e,
double a, Func&& func) {
54 throw std::runtime_error{
"Can't interpolate empty range."};
58 std::lower_bound(b, e, a, [&](
const auto& i,
const auto& j) {
72 const auto a1 = *(it - 1);
75 return interp(a, a1.x, a2.x, a1.y, a2.y, std::forward<Func>(func));
Definition: cosine_interp.h:22
Definition: capsule_base.h:9
Definition: cosine_interp.h:37