summaryrefslogtreecommitdiffhomepage
path: root/spline
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-12-14 22:36:38 +0100
committerStanislaw Halik <sthalik@misaki.pl>2021-12-16 15:32:03 +0100
commit022bc4b9c7b78ef40c662fe706faa4e700a4f707 (patch)
tree03cd4effc1615c5feafb60fe9dbfacdcb96f8ae7 /spline
parentb6b50066c6c69d68955932f0cf251db72f3e16fc (diff)
spline: fix deadzone when more than 2 points
Diffstat (limited to 'spline')
-rw-r--r--spline/spline.cpp13
1 files changed, 11 insertions, 2 deletions
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++)