Home ContactTwitterFlickr

[December 3, 2009]

Roll Over, Delaunay: Voronoi Library Goes Open-Source

Filed under: ActionScript — @ 12:28 am — Tags: ,

A few people have asked for the code for my Voronoi Toy. I haven’t made the entire program public yet, but I have released the underlying as3delaunay library, which I originally ported from Steven Fortune’s C implementation of his plane-sweep algorithm.

In addition to the Voronoi diagram and the Delaunay triangulation, the library also provides the convex hull, minimum and maximum spanning trees, and several other related geometric entities.

You can download the source and compile it, or just get the compiled swc from the downloads page.

So far I have had two users, JakeTastic (Voronoi shattering complete!) and Li (Faster Voronoi Noise); thanks to them both for jumping on, and to Jake also for finding the two bugs :-)

There’s no documentation yet, but there is a test suite which incorporates an example of using the library for nearest-site queries, and there’s also a mailing list, where I’ve archived Fortune’s paper and his C code, as well as a growing page of interesting links related to Voronoi/Delaunay.

The library is hosted on github, so YOU can conveniently modify, fix, or enhance it!

Roadmap for possible enhancements:
Generalize to support weighted Voronoi diagrams, both additive and multiplicative (This is described in Fortune’s paper)
Generalize to use an arbitrary polygon as a boundary
… what else?

[August 22, 2009]

Googling myself with Voronoi

Filed under: Uncategorized — @ 1:38 am — Tags: , ,

No, this isn’t about some hot new way of using Voronoi diagrams to google myself; I’ll leave that challenge to Mario.

I was looking over the search terms that had led people to my blog today, and decided to click on “Alan Shaw” Voronoi. Among all the recent stuff, I came across some papers and articles from my pre-Flash (and pre-C++) days:

Automatic construction of polyhedral surfaces from voxel representations (1988)
Generalized map makers problem: optimal flattening of polyhedral surfaces

Applications of Computer Graphics and Image Processing to 2D and 3D Modeling of the Functional Architecture of Visual Cortex
A Numerical Solution to the Generalized Mapmaker’s Problem: Flattening Nonconvex Polyhedral Surfaces

Now to reread them after twenty years and see if they were all bullshit.

We achieved reasonable performance on a Sun-2 microprocessor system (which is roughly comparable to a VAX-750).

Uh huh.

Here’a a video by mike40033:

[July 1, 2009]

Crystals, Evil Rangers, and Voronoi without an Engine

Filed under: ActionScript — @ 3:41 pm — Tags: , ,

In Flash we can HARNESS THE POWER OF BITMAPDATA (as it might be put in a conference session blurb) to grow Voronoi regions under differing conditions, without doing any algebra. Click on the image to launch the Voronoi Generator.


Disconnected!

Variations on Voronoi Diagrams, from Geometry in Action:

One way of getting Voronoi diagrams is by growing crystals. If you start a number of crystals, all growing at the same rate, and all starting at the same time, you get a number of growing circles. As these circles meet, straight line boundaries appear between them. Eventually, the entire plane will be filled up. Each crystal will exactly fill up the Voronoi region of its point of origin.

This is a little too simple. In reality, crystals start growing at different times. Even if they still grow at the same rate, if they start at different times, they will no longer meet in straight lines. Instead, they will meet in hyperbolic segments. The diagram you get is called the “additively weighted Voronoi diagram”. It’s defined just like the usual Voronoi diagram, but each site has a weight, and you measure distance to a site, you add its weight to the usual Euclidean distance.

Now suppose instead that all the crystals start at the same time, but grow at different rates. Now you get what’s called the “multiplicatively weighted Voronoi diagram”. Once again, each site is given a weight, but when you measure the distance to a site, you multiply by its weight. Now the boundaries between different regions are segments of circles.

This model still has some problems. For example, in a multiplicatively weighted Voronoi diagram, it’s possible for a region to be disconnected [ see picture above -- AS ]. Obviously, this can’t happen with real crystals. So there’s yat another version which treats existing crystals as obstacles, and lets fast-growing crystals grow around the slower ones. Now the boundaries between neighboring regions are sort of tear-shaped. This variation is called the “multiplicatively weighted crystal growth Voronoi diagram.”

There are several other variations. You can change the metric from the normal Euclidean distance to L1, or Lp, or Linfinity, or even stranger distance functions. You can weight the sites additively and mulitplicatively. You can change the sites from points to line segments or circles or polygons. You can generalize to higher dimensions. You can associate points with the farthest site, instead of their nearest site. And so on.

Different applications of Voronoi diagrams require different variations. For example, motion planning algorithms for circular robots often use the Voronoi diagram of the obstacles. If there is a path from one location to another, then there must be a path that follows the edges of the Voronoi diagram, since those edges are by definition as far from the obstacles as possible.

The “L1 metric” is called the Manhattan metric or city-block distance. “Manhattan metric” is a misnomer, though, because in Manhattan the east-west blocks are much longer than the north-south blocks.

The crystal-growth model is equivalent to the “evil forest ranger model,” in which instead of watching for forest fires, the rangers set fire to their lookouts, sometimes at different times, and the fires may spread at different rates. Voronoi diagrams indeed find application in crystallography and in forest-fire modelling.

And here is a post about a far-from-evil lookout.

[May 18, 2009]

Mona Voronita

Filed under: ActionScript — @ 9:39 pm — Tags: , ,

Click on the image to see 1000 Voronoi points in motion. Keyboard controls as in the Voronoi Toy.

If the popup won’t go away when you click the X, click in the movie and hit “s” to stop the moving points.



I couldn’t resist, Frank!

[May 12, 2009]

The Name of the Node: Image Fill with Spanning Trees

Filed under: ActionScript — @ 1:31 pm — Tags: , ,

I’ve rendered some images using the Voronoi Toy from my last post.

I’ve used my logo (as in 結點 “node”) as the input image, run Sakri Rosenstrom’s image segmentation algorithm on it, dropped 10,000 random points into the segments, and drawn the minimum spanning tree of each set of points, thus creating a sort of space-filling tree.

The idea for this kind of fill comes from Mario Klingemann’s presentation at FITC.

Click on each image for a larger version.

[May 11, 2009]

Relaxing in the Plane: A Voronoi Toy

Filed under: ActionScript — @ 8:43 pm — Tags: , ,

relax, v.
10. Chiefly Physics. To return towards a state of equilibrium. (OED)

Here’s the planar analog of my earlier post Distributing Points on the Sphere. This time I’ve ported Steve Fortune’s C implementation of his sweepline algorithm for Voronoi diagrams, and applied Lloyd’s algorithm to change the input values (the point locations) iteratively so the output function (the stress or energy) approaches a minimum. Lloyd’s algorithm works by repeatedly computing the Voronoi diagram and moving each point to the centroid of its region. Soon the points converge to an even distribution. You can see this in action by starting the app by clicking on the image, and then pressing the “r” key.

While I was at it I built out some more of the basic Voronoi-related geometric structures: the Delaunay triangulation, the convex hull, the onion, and the minimum spanning tree.

I’ve had fun playing with this app, changing the display options while moving, adding, or removing points. I hope you enjoy it.


(The app is built for Flash Player 10.)

[October 12, 2008]

Have you seen this man?

Filed under: ActionScript — @ 11:40 pm — Tags: , , ,

He supports an expansion of stem-cell research. He’s made nuclear nonproliferation a priority. He favors combating global warming with a “cap and trade” system. He supported a bill to expand the government’s eavesdropping authority and to protect telephone companies that cooperated with the program from being sued. He embraces the idea of continuing Bush’s faith-based initiative. He said he was picked last on a sports team as a boy. He said it taught him to work hard and persevere. His favorite childhood Halloween costume was a pirate.



Click on the image to open AstroMorpher in a new window (requires Flash Player 10).

The program uses Nicolas Barradeau’s Delaunay triangulation code.

Download the source archive, which can be imported as a project into Flex Builder 3, or just opened normally to read the code.

Work with Flash 10 in Flex Builder 3

Get Your Own Real Time Visitor Map!

Entire contents copyright © Alan Shaw 2005-2009. All rights reserved. You may not reprint or repost the contents of this site without the express written permission of the author.

26 queries. 0.455 seconds. Powered by WordPress version 2.8.4

Bad Behavior has blocked 492 access attempts in the last 7 days.