lundi 23 mars 2015

How is linear interpolation of data sets usually implemented?


Suppose if you are given a bunch of points in (x,y) values and you need to generate points by linearly interpolate between the 2 nearest values in the x axis, what is the fastest implementation to do so?


I searched around but I was unable to find a satisfactory answer, I feel its because I wasnt searching for the right words.


For example, if I was given (0,0) (0.5 , 1) (1, 0.5), then I want to get a value at 0.7; it would be (0.7-0.5)/(1-0.5) * (0.5-1) + 1; but what data structure would allow me to find the 2 nearest key values to interpolate in between? Is a simple linear search/ binary search if I have many key values the best I could do?





Aucun commentaire:

Enregistrer un commentaire