From the course: Learning Algorithmic Design with Grasshopper

Exploring Voronoi diagram basics

From the course: Learning Algorithmic Design with Grasshopper

Start my 1-month free trial

Exploring Voronoi diagram basics

- [Instructor] In the last video we laid out the broad strokes of our algorithm. And in this video I'd like to just start at the beginning and start fleshing out some of the components that we'll need for each step. So we're going to look at this first step of making a 2D Voronoi pattern. Now, in Grasshopper I've got the file Voronoi-algorithm-end.gh open. And in Rhino I just have a blank file. Now, I happen to be going off of the template small object centimeters, but could use whatever units that you're comfortable with. So if you want to use inches, that's just fine. So let's pull up this Voronoi diagram component. And in Grasshopper, that is under the Mesh tab under the Triangulation sub menu. You'll see here there's a few different components that are labeled Voronoi. And the one we want is just called Voronoi. Take a look at some of the inputs here. So this component takes a set of points as a list, an optional radius, an optional boundary, and an optional base plane. So really the only thing that we're required to input here is a set of points. So just for an example, I'll go ahead and pull up a point component. Let's connect that here. And then jump over to Rhino and make us a few points. So typing in the points command into the command line, let's just make a set of more or less randomly placed points. And that's one thing you want to take into consideration when you're making a Voronoi diagram. We wouldn't want our points in a very regular grid, because then the diagram that would generate would just be a grid. So we want things to be sort of randomly spaced as much as we can. Jumping back to Grasshopper. I'll right click and say Set Multiple Points. And then in Rhino just click and drag to select all those points. Okay, now I can see what I'm getting out of the Voronoi component are these curves, this sort of webbed or cellular structure here. And that's based off of where each of these points are. And if I grab one of these I can slide it around and we can see how that pattern updates. So that's pretty fun to play with. Taking a look at some of these other inputs here, we could add in a radius. And for that let's pull in a number slider. And I'll just give it a range from maybe one to, oh I don't know, let's say 75. And let's plug that in to the radius input. And I can see with a very small radius like one I'm just getting circles. But as I bump that up those circles start to bump into one another. And where they overlap I get a straight line. So that's kind of where this Voronoi diagram gets its characteristic cell structure is it's starting with a circle kind of radiating out and seeing where it intersects with other circles based on where adjacent points are. And again, I can adjust these and the pattern's going to update. I'm not actually going to use a radius for this algorithm. So I'm going to go ahead and delete that slider. But just for sake of illustration that's how the radius input works. What I do want to look at is this boundary input. I'd like to set up a boundary that would represent the outer bounds of our structure that we're making. And so for that let's pull in a Rectangle component. And you can see there's a few different options here for rectangle components. The one I want is just called Rectangle. And lets us just specify an x size and a y size on a base plane, and an optional radius. So let's set up some sliders for the x size and the y size. Let's give ourselves a range here of maybe 10 at the low end and going up to, let's say 100. And I'll give myself two decimal places just in case we wanted fractional units. Plug that into the x. Click on that slider, hold down Alt and slide down to duplicate. And plug in the y. So now I can see here I've got a rectangle, I can adjust that size. But I still need to plug it in to my Voronoi component. So I'm going to take that rectangle output, plug it into the boundary input of that Voronoi diagram. And I can see I get a change here. So now that rectangle's kind of cropping out my Voronoi diagram. So those are some basic principles of the Voronoi diagram component. In the next couple videos we'll look at fine tuning to get our pattern exactly how we want it. As a last step here I'm just going to right click on this points component and internalize that data, just so that we don't have to worry about saving it out in Rhino. I'm actually going to go ahead and delete those points that I made. So now all that information is saved inside of Grasshopper.

Contents