# Voronoi Diagram / Delaunay Triangulation

If you were running a Java-compatible Web browser then you would see a Voronoi Diagram / Delaunay Triangulation here.

• The mouse: Click the mouse in the drawing region to add new sites to the Voronoi Diagram or Delaunay Triangulation.
• The Voronoi Diagram and Delaunay Triangulation radio buttons: These toggle between the Voronoi Diagram and the Delaunay Triangulation. Your current set of sites remains the same for both diagrams.
• The Clear button: Press this to begin a new diagram with no sites.
• The Show... regions: If you move the mouse over one of these regions then the corresponding thing will be shown on the screen. For instance, if you move the mouse over Show Empty Circles then the empty circles for the current diagram will be displayed.

### What is it?

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 additional 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 retriangulated. 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.

### Source Code

The source code is free, but if you find the code useful I would appreciate hearing about how you are using it.

Because many browsers have not yet been updated to Java 5.0, the code that is currently running on this page is the Java 1.4 code.

Author: Paul Chew, chew@cs.cornell.edu

Revised: March 1997 (added the Show... regions).
Revised: August 2005 (updated the code and made the source code available)