POLAR 3D EDU PROJECT: FRACTAL TREE IN THE FOREST

RECURSION

Good programming languages (like BlocksCAD) support recursive programming. Instead of looping a single set of commands, a recursive module uses replicas of itself as a part of the module definition. Once a module is called, the values of variables are local to that instance of the module. The result is the ability to create complex objects that can’t be made with simple loop instructions.

In celebration of this capability, we’ll create a famous recursive structure, a fractal tree. Fractals are complex structures in which any part of the structure is a replica of the structure as a whole. An entire branch of mathematics (chaos and complexity theory) is devoted to the exploration of these structures.

Consider a tree, for example, branches are similar to each other, but their size changes as smaller branches grow out of larger ones.

A similar pattern is found in ferns where the whole structure is similar to the smaller parts that make up the plant.

I became so engaged by these structures that I wrote a couple of books on the topic back in the 1980’s: Discovering Apple Logo : An Invitation to the Art and Pattern of Nature, Addison Wesley, 1983.

The language I wrote about, Logo, supported recursion so it was a natural choice. Of course, in those days, the graphics were low resolution 2D images on an Apple II computer ― a far cry from what we can do with BlocksCAD and a 3D printer today.

BUILDING OUR TREE

As our tree is being built, the size and length of branches will change, just as they do with real trees. We start by creating a set of global variables used in our structure.

Next we define a recursive module called tree. This module uses three local variables ― the starting branch length and width and the depth (number of levels) of the tree. These three variables will have their local values changed during use of the module. All other variables will keep their global values.

There are two things to notice in this module. First, you’ll see that we don’t use the Centered option for the cylinder. This makes it easy to get all the branches connected. Second, the cylinder is tapered from its previous radius at the bottom to the new one at the top ― just like the branches of many real trees.
Once this module has been created, we can create our final instructions.

When this BlocksCAD program is run, it produces the following tree. I changed the rendering color by clicking on the Render window box with the color swatch and choosing green as the new color since it looks more tree-like. Of course the color of your printed object will be chosen by the filament you use.

Here’s our printed tree.

This tree also looks like a stalk of broccoli. You should do some research to see why this is.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s