4

So I have some irregularly spaced data that I want to interpolate onto a regular grid. (I want to do exactly this but in Java) Here's a picture:

Scattered Data for Interpolation

Basically I have the x and y coordinates of each point and a z value associated with each point and I want to interpolate between them and fill in the center of my image.

What is the best way to do this using Java? Is there a built in 2D interpolation library I can use or should I try a "roll my own" approach?

This post and this one also seem to be trying to do about what I am but their answers don't quite apply.

Someone else with the same problem but no solution.

Note: I am using JavaFX-2 so if I could somehow use their Interpolator class that'd be great.

.
.
EDIT: If anyone stumbles upon this and wants to know what I ended up using, it was a Delaunay Triangulation implementation from BGU:
Main Site
Code API

Community
  • 1
  • 1
River
  • 8,585
  • 14
  • 54
  • 67
  • Do I understand your question right?: You have a set of points (x, y, z) and you want to to create an area around this points where the fillcolor depends of the z value and should interpolated between the points? – Vertex Jul 09 '14 at 20:58
  • @Vertex Yep, sounds about right – River Jul 09 '14 at 21:00

1 Answers1

2

If linear interpolation is sufficient, I suggest you to use a 3d mesh with Gouraud Shading for drawing:

  1. Convert the 2d point cloud to a mesh (you can google for existing algorithms)
  2. Mapping the z value of each point to the vertex' color
  3. Using Gouraud Shading to enable linear interpolation between the vertex colors
  4. Creating a camera on top to the mesh and using a othonormal projection (to avoid perspective)

You say that you can use JavaFX. JavaFX supports 3d scenes and you can build your own meshes. But looking into the JavaDoc of TriangleMesh, I can't find any method to set the vertex color I found only a method to set the (x,y,z) and (u,v) (texture coordinates) coordinates.

Vertex
  • 2,682
  • 3
  • 29
  • 43
  • It looks like that's only available in JavaFX 8. I only have JavaFX 2 =/ – River Jul 09 '14 at 21:24
  • 1
    There are other 3d frameworks for Java like [jMonkEyengine](http://jmonkeyengine.org/). See [Custom Mesh Shapes](http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:custom_meshes#examplevertex_colors) for setting vertex colors. – Vertex Jul 09 '14 at 21:33
  • I'm really hoping to find an easy way to do this using standard Java libraries – River Jul 09 '14 at 21:50