The VORONOI procedure computes the Voronoi polygon of a point within an irregular grid of points, given the Delaunay triangulation. The Voronoi polygon of a point contains the region closer to that point than to any other point.
For interior points, the polygon is constructed by connecting the midpoints of the lines connecting the point with its Delaunay neighbors. Polygons are traversed in a counterclockwise direction.
For exterior points, the set is described by the midpoints of the connecting lines, plus the circumcenters of the two triangles that connect the point to the two adjacent exterior points.
This routine is written in the IDL language. Its source code can be found in the file
voronoi.pro
in the
lib
subdirectory of the IDL distribution.
To draw the Voronoi polygons of each point of an irregular grid:
X = RANDOMU(seed, N) ; Create a random grid of N points
TRIANGULATE, X, Y, tr, CONN=C ; Triangulate it
VORONOI, X, Y, I, C, Xp, Yp & $ ; Get the ith polygon