Good question. On first, solution is to take library that can give you result in wanted format. You need
Delaunay triangulation not Delaunay diagram, what this library provides.
It is possible to obtain triangles from result library provide quite simple. If inner diagram point has n
edges (getLinked() method), than it is part of n
triangles. Other edges of triangles are calcualted by
sorting edges by angle. If point is outer (on convex hull) than angle between one pair of edges is larger
than 180deg and on that pair triangle doesn't exist.
Algorithm is like:
for each point p1:
neighbours = delaunay.getLinked(p1)
sort neighbours by angle to point p1
for i=0 to size(neighbours)
p2 = neighbours[i]
p3 = neighbours[(i+1) % size(neighbours)]
if (angle(p3, p1) - angle(p2, p1)) % 360deg > 180deg:
continue # Outer triangle
if p2 > p1 and p3 > p1:
continue # Already processed
print result triangle (p1, p2, p3)
Check (p2, p3 > p1) is to remove identical triangles, since each triangle is produced three times.