Monday, September 07, 2009

How to: Draw the Voronoi Diagram

DSC05073

As has been written here before, Voronoi diagrams, as a geometric model are fascinating because they can be used to describe almost literally everything: from cell phone networks to radiolaria, at every scale: from quantum foam to cosmic foam. Even the regular lattices and solids, cubes, tetrahedra, and the ways in which they combine, can all be seen as special cases of three dimensional Voronoi. It's hard not to get mystical about it, but it's really just the contemporary equivalent of the endless ideal gridded space of modernism or the renaissance, just more exotic and malleable. Geometry is Culture.

Drawing Voronoi diagrams by hand has renewed my interest in the stuff. There are lots of scripts out there for making instant vector crystal foam in just about any modeling or CAD platform, but it's more interesting for me right now to slow it down, take it step by step, and really try to understand the geometries involved. More a heuristic than an algorithm, executing it demands and reinforces the kind of zoned out close attention that almost becomes the whole point of drawing in the first place. The artifact that you get at the end it is just an unexpected bonus: the physical record left by the process of thinking out loud on paper. Below is a rough pseudocode (thanks, mike!) for building it up from a set of points.

VORONOI HOWTO
(1) Input Sites (2) Connect Nearest Neighbors (shortest line wins) (3) Find Center Points
(4) Draw Perpendicular Bisectors (5) Trace Cells (6) voila


(1) The input points, step one, are called sites, labeled here A, B, C, etc.

(2) The next step is to connect the sites to all of their nearest neighbors without making a line that crosses another. This is known technically as the Delauney Triangulation, and it's maybe the most difficult part. One way to do it might be by brute force - connect every site to every other site, make a true all-to-all rhizomatic meshwork, and then start deleting lines that are too long. This is how a machine might attack the problem, but it becomes too hard for a human to execute when the number of sites jumps into the double digits. Another algorithmic method is to start with a test triangle of sites and draw their circumcircle, the circle that hits all three sites, rejecting the triangle if the circle contains another site within it.


Image via wikipedia

This also takes too long, and circumcircles are hard to draw, so I found a method that's faster, and still mostly accurate. Since no lines on the Delauney triangulation can cross, just eyeball it until you run into a condition as in the above, where you have to decide if FD or AE is correct, the shorter line always wins. This is obvious in the example, but sometimes this needs some careful measuring in the field.

(3) Step three is to find and mark the centerpoint of every line on the Delauney graph.

(4) The fourth step is to draw the perpendicular bisector for each Delauney line. This is where careful accuracy, in finding the centerpoints, and in drawing a tight 90 degree angle, pays off. If everything has been done correctly, there will always be three lines converging at a point, unless the input sites are on a perfectly regular rectangular grid. Drawing the last line of the three and watching it land exactly where it's supposed to is extremely satisfying. Watching it miss can mean going back all the way to step two and flipping the Delauney graph for the triangle. Some mistakes are instructive, reminding you to take your time and think about the moves, but some are more interesting, for being completely inexplicable. A few places in these drawings, I've run into conditions that should work out, but just don't: evidence of some hidden monster in the process, a flaw in the heuristic, or a breakdown of the pseudocode.

(5) The fifth step is to retrace the outline of each Voronoi cell from the perpendicular bisectors. There will be one cell for every site, and at the end, each cell is just the set of all surface area points that are closer to its site than any of the other sites, as illustrated in the last panel: A' -> A, B' -> B, etc.

(6) Sit back and congratulate yourself while contemplating your hard earned tangle of fat distorted honeycomb.

DSC05123a

I've found in practice that it's best to use different colors for the input sites, the Delauney lines, and the bisectors, unless driving yourself completely crosseyed mad is something you have the time and inclination to do. Blue and red mechanical pencil leads are pretty easy to get. I made this drawing to practice, using a pepper grinder above the drafting table to get random input sites:

Artisanal Voronoi 1 SM

The wall drawing below was made for the Current Gallery's Abandon Ship show. It measures about 3' x 5'. The input sites here were the roughly patched holes and marks left by all the previous exhibits and shows in the space's three year existence as a gallery. Before that, the building was a chocolate factory. This piece will be demolished along with the rest of the show when (if) plans move ahead to build a hotel on the site. I was very glad to get the chance to do a wall drawing, having just visited again, for the second time, Sol LeWitt's ephemeral 'Drawing Series—Composite, Part I–IV, #1–24, A+B' at Dia Beacon. These pieces foreground the disconnect and shifts between the different types of time at play here: the almost instantaneous time of conception, the time spent to absorb the system, process the clues, unlock and understand the method, and the implied slow time spent to execute the drawing itself: a person, on a scaffold, pulling graphite repeatedly across painted gypsum. I wonder if the assistants were well paid.

DSC06027a

The five hours or so it took to carry out the Current Gallery piece were well spent: not an all nighter, but a late nighter. Friends brought food and beer, with other people coming and going, cutting holes in the building's floor, plastering the backside with xeroxed drawings, and making Seussian maggots crawl from the walls and ceiling.

[[Edit: If anyone else has tried this, put some pics of it on the web and post a link in the comments]]

[[[Edit 2: for more, see also: Analog Voronoi Grid Distortion with Magnets]]]

54 comments:

  1. Anonymous4:17 AM

    Gave this a try last night, strangely satisfying in a 'i don't know what i'm doing but its kind fun way' Thanks for the process.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. @anonymous - post pics!

    @jack - draw it and post pics!

    ReplyDelete
  4. Awesome! Thanks for the explanation of the Delaunay triangulation, apart from the Voronoi drawings! I'm not a native English speaker and my math knowledge is limited. I was looking for this in a recent project, but settled for a solution without the Delaunay principle, because I just didn't know it was called that way :) http://tinyurl.com/nq7swr

    Feel like doing it again but correct this time, thanks!

    ReplyDelete
  5. Anonymous9:16 AM

    explain again, how does this help me get a job?

    ReplyDelete
  6. Anonymous10:41 AM

    What about application? I could imagine a case where you had hundreds or thousands of data points. What if you randomly sampled a small number, say 10, and did a Voronoi with just those. Would the results allow you to put every data point into a managable number of classes?

    But if you did this twice or more, wouldn't you come up with different classifications each time?

    ReplyDelete
  7. Something between hand drawing it and running a program: letting Photoshop radial grads and the 'lighten' blend mode do the heavy lifting.

    http://www.digitalartform.com/archives/2009/06/simulating_voro.html

    ReplyDelete
  8. Anonymous5:13 PM

    Have you tried looking into any "plane sweep" algorithms to make these? They're a lot more efficient, possibly harder to understand. Google "Fortune's plane sweep algorithm." Yeah, these are pretty cool. Nicely done!

    ReplyDelete
  9. Hi Anonymous - Yep, I did look at Fortune's Algorithm, it's pretty interesting. I didn't think it would be useful for hand drawing, because it requires a lot of testing and refining to find the lines. More suited to a machine than a person. Humans are still better at 'reckoning' than computers.

    ReplyDelete
  10. Where can i find a software that would automatically generate the voronoi diagram for a given set of points? I tried the link, but i need something where i can define the control points accurately. maybe something that works with AutoCAD? I'm doing it manually but after seeing how fast it can be done automatically i really want to find a software!

    ReplyDelete
  11. Anonymous9:56 AM

    Great help tnx!!

    ReplyDelete
  12. thanks thanks thanks so much for a very lucid explanation!!

    ReplyDelete
  13. Very informative and trustworthy blog. Please keep updating with great posts like this one. I

    have booked marked your site and am about to email it to a few friends of mine that I know

    would enjoy reading.




    luna gold
    cheap luna gold
    luna gold
    buy luna gold
    luna gold
    cheap luna gold
    buy luna gold
    luna gold
    luna gold
    shaiya money
    cheap shaiya money
    shaiya money
    buy shaiya money
    shaiya money
    cheap shaiya money
    buy shaiya money
    shaiya money
    shaiya money

    ReplyDelete
  14. Anonymous5:51 AM

    I just want to emphasize the good work on this , has excellent views and a clear vision of what you are looking for
    earn diploma at home | online english course

    ReplyDelete
  15. I used the following algorithm to draw the voronoi diagram. First of all, for each set of three points, I calculate the orthocentre of the three points. That is, I calculate the point which is equidistant from all three points. Then, for each orthocentre x, I check all the points in P, to make sure that the three points used to find x are the three closest points of P to x. If they are not, I reject x from consideration. It is not needed to draw the voronoi diagram

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. In my opinion you have good drawing skills, the Voronoi diagrams are pretty complex geometric models.

    ReplyDelete
  18. This is a nice tutorial and looks really fun to make. this I have to try. Thanks a lot.

    ReplyDelete
  19. Nice post :)At first look this is a bit complicated but is it really? :)

    ReplyDelete
  20. Tina asked, and though I doubt she'll ever read it with all the spam cluttering the comments, if you are after software for Voronoi diagrams, Delaunay triangulations, or convex hull, the standard thing is qhull (http://www.qhull.org).

    It's free, open source, and it's what Matlab and Mathematica use to do these kind of calculations.

    Interesting to note that the most often used computerized way of doing Voronois and Delaunays projects the points onto a paraboloid in a space of one more dimension, and then finds the convex hull of the projected points: not something that will work by hand too good...

    ReplyDelete
  21. Re: where you have to decide if FD or AE is correct, the shorter line always wins.: this is false. For a counterexample, let ADF be an acute isosceles triangle whose base DF is less than its height, and place E outside the triangle very close to the midpoint of DF.

    You're repeating an error original made by Shamos, though, so you're in good company.

    ReplyDelete
  22. I recently came across your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed,Yes, it’s all about little adjustments along the way. That’s how truly great products become truly great products. And of course, the process always continues as people have different wants/needs.

    Cna Certification

    ReplyDelete
  23. Discover Louis Vuitton collections online: luggage, handbags, wallets, shoes ...

    ReplyDelete
  24. This is a vey interesting post. I knew people could draw this diagrams so easily. Now I can do too, cool.

    ReplyDelete
  25. Anonymous10:41 AM

    You can also use the Filter by Time tool on the left column to narrow the search results by time and see stories published within the last hour, day, or week. Choose “Past Day” in the news search result page for the query “obama,” you’ll see only results published within the last day.
    Thank youNike Air Max 90
    Wholesale Nike Shoes
    Christian Louboutin Boots
    Sexy High Heels
    Christian Louboutin High heels
    Yves Saint Laurent High heels
    Tory Burch High heels
    Christian Louboutin High Heel

    ReplyDelete
  26. A vast selection of reproduction WW2 German uniforms, Waffen SS Camouflage, Winter reversible parka coats, smocks and service shirts,tunics, overcoats.

    ReplyDelete
  27. Anonymous5:08 AM

    Happy to see this article as it is just what I have looking for and I am looking forward to another great article from you. As a fashion girl or lady, you must choose a right hair straightener from
    ghd uk to make you more attractive. You may be interested in chi us.
    Welcome to chi hair.
    You can choose Nike Shoes from Air Max Shoes

    ReplyDelete
  28. Anonymous4:10 AM

    We all know that online shopping is a convenient option for buying high end electronics items within one's budget.|p90x workout|leisure furniture|sexy halloween costumes china It allows us to get great deals on a wide range of electronics like cell phones for sale,Video Camera, Camcorder, replacement laptop battery wholesale, Portable MP3 players,Home theatre, audio system etc. Many of these online electronics store,sexy lingerie wholesale|p90x diet|leather sexy lingerie|outdoor sofa provide cheap and discount products. Through online china electronics wholesale store shopping, we can enjoy a great shopping experience for our desired electronics from the comforts of our home.workout routines|p90x diet|Leather corset|leisure furniture There are lots of advantages of purchasing electronics items online like discounts, freebies etc. But we should consider a lot of things while we are shopping online.

    Our Online China Electronics Wholesale Store Supply High Quality Audio Video players Wholesale,Chalean Extreme|halloween costumes manufacturers|outdoor sofa Digital Photo Frames, Our Audio Video Players for Sale is Low Price,P90X|halloween costumes manufacturers|patio furniture So You Can Save Huge on Your Purchases, And You Can Enjoy a Pleasant Audio-Visual Trip!

    ReplyDelete
  29. Anonymous4:13 AM

    The ensemble drama about young adults growing up in Beverly Hills is a blend of romantic drama and subject matter that crosses all cultural boundaries.
    Stargate SG-1 Season 1-10
    The Shield Season 1-7
    Without A Trace Season 1-5
    24 Season 1-8 DVD

    ReplyDelete
  30. Anonymous5:39 AM

    The Christian Louboutin Heels can help you become sexy and elegant. christian louboutin 2011 sandals are regarded since the symbolic representation of attractive and elegant.christian louboutin wedgesIt is especially suitable for the women who wear the christian louboutin evening shoes at the first time. These christian louboutin pumps combine top quality, reasonable price and fashional design, which is your best choice Artist who promoted his collection of luxury christian louboutin classic
    in earlier 90s. No 1 can disregard the existence in the style world, World-famous red-colored soles and christian louboutin peep toe are shaped features. However, you can by no means overlook the beautiful. You do not even need to go inside environment, as well as your slim,christian louboutin thong sandalsgorgeous and graceful legs may be effortlessly discovered in people's eyes.!Welcome to our christian louboutin store.

    ReplyDelete
  31. Quite helpful material, thank you for this post.

    ReplyDelete
  32. Thanks for your article, very useful information.

    ReplyDelete
  33. Very helpful info. Thanks
    how to become a dentist

    ReplyDelete
  34. Timmy5:48 AM

    Nice, thanks for explaining the diagram
    how to become a physical therapist

    ReplyDelete
  35. At last i got the explaination of this diagram. THANK YOU
    Rich dad poor dad seminar

    ReplyDelete
  36. Montatna5:55 AM

    great, very simple to understand
    Mississauga Dance Classes

    ReplyDelete
  37. Dr.Jerkins5:56 AM

    Allright!! At last I found it!! Hooray
    Psychology Schools`

    ReplyDelete
  38. Grat explanation and fascinating how it relates to everything. thank you.

    how to get rid of acne fast

    ReplyDelete
  39. Great post thanks for the read!

    ReplyDelete
  40. Your Escort Agency offers exclusive and most beautiful London escort girls of various nationalities.

    ReplyDelete
  41. Anonymous9:02 AM

    I think that's great!
    Zoom Kobe VI

    ReplyDelete
  42. Using the best antivirus software be able to aid en route for decrease the quantity of guidance workers destitution. What is the best photo editing software

    ReplyDelete
  43. Anonymous12:31 AM

    I would like to appreciate the great work done by You pf changs coupons

    ReplyDelete
  44. Anonymous12:32 AM

    I would like to appreciate the great work done by You pf changs coupons

    ReplyDelete