Finding the points nearest to a given x?
You can compute the distance of chosen points. 
1) Search for the minimun distance X value (left and right). 
2) Search each points corresponding with X_MIN_LEFT and X_MIN_RIGHT. At the same time you can check the distance with Y and find the minimum Y distance. 
That's it.
I need to interpolate a linear function and I can't use numpy or scipy. 
I'm given this data points ((0,10), (1,4), (2,3), (3,5), (4,12)) and a point on `x = 2.8. the data points is polyline (linear between 2 coordinates)
of course I need to use the closest x-points from the data for 2.8. which is from (2,3) and (3,5) because 2.8 lies between the 2 and 3.
How do I make a function to find this closest points?