ed Bevan
ed Bevan

Reputation: 73

Fitting a surface to collection of 3D data points in java

Hi I have a cloud of XYZ data points. I want to estimate a surface which best fits these points, so that later on I can input an XY pair and get back the Z value where this XY pair lies on the surface.

Is there an existing Java library that will estimate a surface for me?

If not, can anyone recommend me stuff to read which will describe the methods for calculating this?

If possible, I want to be able to weight the points (Some points are less reliable and so should have less effect on the finished surface).

Upvotes: 3

Views: 2273

Answers (1)

Hannesh
Hannesh

Reputation: 7478

This kind of problem is best solved with linear least squares. However I wouldn't try reading the wikipedia article, it seems to be written for mathematicians.

The idea is to change the problem into a linear optimization one. In your case i'd try to fit a 2D polynomial. This is an equation in the form:

z(x, y) = A + Bx + Cy + Dx^2 + Exy + Ey^2 + Fx^3 + Gx^2y + Hxy^2 + Iy^3 + ...

You get the idea. For a given dataset, the task is reduced to finding the parameters A through I that best fit the data points. This kind of problem is easily solved by linear least squares.

Have a look at this code for fitting ellipses to 3D data points. With some effort you can adapt that to fit polynomials in the form I described above.

Good luck!

Upvotes: 2

Related Questions