From 022bc4b9c7b78ef40c662fe706faa4e700a4f707 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Dec 2021 22:36:38 +0100 Subject: spline: fix deadzone when more than 2 points --- spline/spline.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'spline') diff --git a/spline/spline.cpp b/spline/spline.cpp index 92e03ade..9f92c074 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -148,7 +148,7 @@ void spline::update_interp_data() const { points_t list = points; ensure_valid(list); - const int sz = list.size(); + int sz = list.size(); if (list.isEmpty()) list.prepend({ max_input(), max_output() }); @@ -183,7 +183,16 @@ void spline::update_interp_data() const else { if (list[0].x() > 1e-6) - list.push_front({}); + { + double zero_pos = 0; + while (list.size() > 1 && list[0].y() <= 1e-6) + { + zero_pos = list[0].x(); + list.pop_front(); + } + list.push_front({zero_pos, 0}); + sz = list.size(); + } // now this is hella expensive due to `c_interp' for (int i = 0; i < sz; i++) -- cgit v1.2.3