Mapping with set values

Hi There,
I hope one of you fine people can help be with a problem.
I need to map a range a values, however my range is non linear. A few example values below.
23=8
22=15
21=19
20=20
19=22
18=23
About 4 years ago I had a similar issue with Arduino, and I found a function which you could input predetermined values, and it would map, based on the values you have inputted - almost like calibration.
Is there anything like this for processing?
Thanks all.

There is nothing out of the box. Since this is non-linear, it means you need to do the calibration yourself. First question: Are your values above discrete in nature? In other words, the values 8, 15, 19, 20,… are the only values or do you have values in between like if x=21.5 y=17? If your values are discrete, then you could load the values in a hashmap or any map container. If there are not discrete, then it really depends on the model you want to use to describe your calibration. For instance, do you want to simulate linearity between two points? Or do you want to fit a polynomial for your data set. There is no guess work here. The calibration is based on the sensor you are using.

Kf

Thanks for the reply Kf,

The project I’m working on is an interactive Crane Chart.
The figures represent x axis is the Crane Radius, and y axis is the Maximum Hook Height.
When I dynamically move the Crane boom image, then I want to read off the maximum hook height.
The map function obviously didn’t work as my data is non linear.
I could do it manually, but would have a heap of if statements.
The max radius is 23.2m, and the minimum radius, ie when the crane is fully up, is 5.14m.

Got it!
Seems I just needed a Lagrange Interpolation formula.
Its quite long, but it’s bang on very accurate.

Thanks for your time and help Kf.

float hookHeight;

float craneRadius = 10;

void setup() {
  size(200, 200);
}


void draw() {

  hookHeight = ((((((-1.8724306031028*pow(10, -9)*(craneRadius - 17)
    -  2.6499523675270*pow(10, -8)*(craneRadius- 23)
    -  1.6739713507900*pow(10, -7)*(craneRadius - 6)
    -  7.754545894024*pow(10, -8)*(craneRadius - 13)
    -  1.0139354993713*pow(10, -6)*(craneRadius - 19)
    - 0.0000151536)*(craneRadius - 7) - 0.0000605494)*(craneRadius - 21)
    -  0.00123214)*(craneRadius - 9) - 0.00432673)*(craneRadius - 15)
    -  0.0941427)*(craneRadius - 5.14) - 1.27907)*(craneRadius - 23.2) + 8.1;

  println(hookHeight);
}