[If the applet used to work for you and has now quit working, you may want to try one of the older versions of the applet: Java 1.1 version; Java 5 version]
The Voronoi Diagram has the property that for each site (clicked with the mouse) every point in the region around that site is closer to that site than to any of the other sites.
The Delaunay Triangulation is the geometric dual of the Voronoi Diagram. Alternately, it can be defined as a triangulation of the sites with the property that for each triangle of the triangulation, the circumcircle of that triangle is empty of all other sites.
These closely related data structures have been found to be among the most useful data structures of the field of Computational Geometry.
The actual data structure here is a Delaunay Triangulation. The Voronoi Diagram is built on-the-fly from the Delaunay Triangulation.
The Delaunay Triangulation is built within a large triangle whose vertices are well off-screen. That's why in the Delaunay Triangulation there are lines heading off-screen. This technique makes the code simpler since otherwise additional code would be needed to handle new sites that are outside the convex hull of the previous sites.
The algorithm: To insert a new site, we walk across the triangulation, starting from the most recently created triangle, until we find the triangle that contains the new site. This triangle and any adjacent triangles that contain this new site in their circumcircle are eliminated and the resulting empty spot is re-triangulated. The site-insertion part of this technique is commonly called the Bowyer-Watson Algorithm. The expected time to insert a new site is roughly O(n1/2) where n is the current number of sites.
The source code is free, but if you find the code useful I would appreciate hearing about how you are using it.
Revised: March 1997 (added the Show... regions).
Revised: August 2005 (updated the code and made the source code available)
Revised: December 2007 (cleaned up code, added ability to access to each Voronoi
cell, added More Colorful button)