This is a fairly remedial question. I have been looking at the documentation for the JTS DelaunayTriangulationBuilder and I am at a loss as to how to do what seems like it should be a simple thing. I wish to take a series of points, triangulate them, and then interpolate the Z value of a random point within that mesh. It’s non-obvious from a cursory reading how to do this. Any ideas?
Share
After you’ve loaded up the triangulation object, call
getSubdivision()on it to get the triangulation. It uses a quad-edge data structure, which you’ll need later. (It’s easier to understand if you know what a half-edge or winged-edge representation is.) The resultingQuadEdgeSubdivisionhas a methodlocatethat, given a coordinate, returns one of the edges of the enclosing triangle (as a quad-edge). Get its origin vertex withorig()and its destination vertex withdest(). Get another edge withoNext()Its destination vertex is the third vertex (also dPrev().origin() is the same vertex). Now that you have the three vertices, represent your test point as aVertexand callinterpolateZValue.For example:
You’re right, though. It’s not obvious how to do this from reading their API.