1. We start with a horizontal segment.
2. We divide the segment into three equally sized segments.
3. We remove the segment in the middle
4. Repeat from step (2) for the two remaining segments
This produces a set of segments that puzzled mathematicians for a while. I am more interested in the fractal properties of the whole construct. It shows how a simple rule operating at multiple scales can generate complex structures. This set is too primitive to be used for realistic content, but it is the seed of many techniques you will require to achieve that.
This is how you would code the Cantor set using our grammars:
This is the real world so we need to make sure it stops. An easy way would be to add another definition of "cantordust" for when the size is small enough. This definition would do nothing, thus stopping any further subdivision:
Here you can see the output:
Let's make it more interesting. First let's add depth to it. Instead of segments we will use 3D boxes:
This already looks like we were growing little towers. We can make the towers taller if there is enough room:
Let's add a random element. We will not split into three equal spaces anymore, instead we will pick a random value for each iteration:
For a microsecond this image can fool you into thinking you have seen a city. I think that is pretty cool if you consider it is only a few lines of grammar code.
Of course this is not a replacement for a city or buildings. The cantor grammars are probably the simplest you can have. You will need a lot of more code to produce somethings that can pass as a city. But odds are it will be mostly variations of the Cantor dust.
As a first step you could replace the leaves with another, more complex but less fractal generator.
ReplyDeleteI'll just say I love posts with "City" as a label/keyword :)
ReplyDeleteI would like to know more about the grammar of your L-system language and how it works. Could you write a post going more in depth on this? We have some tantalizing little hints here but more info would be greatly appreciated! Thank you for sharing your work with us. It has truly fascinated me for years.
ReplyDelete