File APIs for Java Developers Manipulate DOC, XLS, PPT, PDF and many others from your application. http://aspose.com/file-tools
Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login

# Getting values between variables?

Maria Sachhause
Greenhorn

Joined: Nov 30, 2005
Posts: 10
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)?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24149

27

"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:

Make sense?

subject: Getting values between variables?