Arduino Interpolation library question

Hello!

I’ve been trying to understand how to use this library with no success:

just to test the library i was simply trying to travel from point y to point y for a start. with no results.

#include "InterpolationLib.h"

const int numValues = 10;
double xValues = 0;
double yValues = 100;
float  xValue = 0;

void setup(){
  Serial.begin(9600);
}

void loop(){
Interpolation::Step(xValues, yValues, numValues, xValue, 0.0);
Serial.println(xValue);
delay(100);
}

i clearly don’t understand how the function works since i’m getting a compiling error. Can someone point me out how to perform this simple task?

I understand how i could simply increment xValues with xValues++ until it targets yValues, but i would like to take advantage of the diferent curves this library offers.

here is the example on the library, notice xValue and xValues are diferent things(took me a while…)

/***************************************************
Copyright (c) 2019 Luis Llamas
(www.luisllamas.es)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
 ****************************************************/
 
#include "InterpolationLib.h"

const int numValues = 10;
double xValues[10] = {   5,  12,  30,  50,  60,  70,  74,  84,  92, 100 };
double yValues[10] = { 150, 200, 200, 200, 180, 100, 100, 150, 220, 320 };

void setup()
{
	while (!Serial) { ; }
	Serial.begin(115200);

	for (float xValue = 0; xValue <= 110; xValue += .25)
	{
	    Serial.print(Interpolation::Step(xValues, yValues, numValues, xValue, 0.0));
		Serial.print(',');
		Serial.print(Interpolation::Step(xValues, yValues, numValues, xValue, 0.5));
		Serial.print(',');
		Serial.print(Interpolation::Step(xValues, yValues, numValues, xValue, 1.0));
		Serial.print(',');
		Serial.print(Interpolation::SmoothStep(xValues, yValues, numValues, xValue));
		Serial.print(',');
		Serial.print(Interpolation::Linear(xValues, yValues, numValues, xValue, false));
		Serial.print(',');
		Serial.print(Interpolation::Linear(xValues, yValues, numValues, xValue, true));
		Serial.print(',');
		Serial.print(Interpolation::CatmullSpline(xValues, yValues, numValues, xValue));
		Serial.print(',');
		Serial.println(Interpolation::ConstrainedSpline(xValues, yValues, numValues, xValue));
	}
}

void loop()
{
}

Thanks in advance!

If you are getting a compilation error, please cut and paste it here. Does the library have documentation that you can read? Example sketches that you can try?

are you familiar with map()?

aarg:
If you are getting a compilation error, please cut and paste it here. Does the library have documentation that you can read? Example sketches that you can try?

here is the error

collect2.exe: error: ld returned 1 exit status

I'm not getting a compiling error if i run the example code of the library, that one runs fine.
I think i'm just making some idiotic mistake somewhere since i'm not understanding how the library works.
There is not much documentation on the library...just the example i posted above and two others that don't relate to my needs. Also, i think no one posted here about this library until now.
A more illustrative example would be nicer.

gcjr:
are you familiar with map()?

Yes, i'm familiar with map(). How does it relate to it?

Thank you for your time and attention!

doesn't map() interpolate integer values over integer ranges?

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

sorry for my untechnical language, English is not my first language also, as you guys might have already noticed i'm nowhere near an experienced coder :slight_smile:

OK here it goes, in my understanding map() simply "scales" one value into another by linearly expanding or diminishing a value by a scaling factor.

I was hopping this library would, knowing point "a" and point "b", calculate a "trajectory"(a new value every time it's called) between this two points based on the different library algorithms (Linear, Smooth, Catmull spline and Constrained spline).

Maybe i got it completely wrong

ok. you want more than linear piece-wise interpolation.

post your errors