Hello, I have a program where is lots of values(speed in one second) that are depending on angle of heading.
For example I have read ollowing values from a file:
int angle50 = 550; int angle75 = 435; int angle110 = 500; ...
So, the question and problem is how to get values between for example angle50 and angle75. So I mean what is for example value of the angle60. I can solve my problem with using lots of IF:s but code is getting quite long. I know it has something to do with interpolation... but with java? How to do that(simplies way)?
"Interpolation" is basically fitting a function to some data points, then using the values of that function to stand in for places where you don't have real data. You can do linear, quadratic, cubic, quartic... interpolation, where you fit polynomials of order 1, 2, 3, 4, etc, to the data. Generally, the higher the order of the function, the better the interpolation, but the more computation is takes.
Linear interpolation is just drawing a line between two points and taking new points along that line. Let's say you have this data
and you want to know the value of y at x=60. You compute the slope of the line through your data points:
Then use that to compute new points along the line: