Saturday, December 21, 2013

Visualizing a Fractal with a 3D Printer

I purchased a Printrbot Simple a few weeks ago with the hope to make something cool and unique with it.  I did use it to print some Christmas ornaments for my family, which was a good way to break it in.  I really wanted to model something myself and have it just appear in real life.  The 3D printer is a nifty bridge between art and engineering.

Specifically, I want to do two things with the device: create something no one has seen before, and experiment with different textures as a medium or a means to augment the qualities of an artistic piece.  I think it would be interesting to see someone take a two dimensional piece and apply texture to it, so that the piece takes on different qualities when seen from different angles.  That's sort of what I'm doing here, but something I'd like to explore further some day.

One thing that I've wanted to do for awhile is visualize the Mandelbrot fractal in three dimensions.  If you are not familiar with the Mandelbrot fractal, you can read about it here.  To summarize, it's a set of numbers on the complex plain such that when you continuously square and cube the numbers, it does not diverge into infinity.  This very simple equation leads to incredibly interesting and complex designs.  The more you zoom into a projection of this fractal, the more interesting it becomes:


I imagine that most people exploring the fractal for the first time experience it as a colorful space that you can zoom through in a simulated space ship.  I wanted to know what it would look like as a mountainous landscape, and I wanted to see it in real life.

I set out to generate a 3D model of what the fractal looks like, with the Z axis representing "the number of multiplicative iterations before the point on the complex plane assuredly escapes into infinity."  This is how the fractals are usually colorized.

The first step was to find a section on the complex plane to visualize.  This was the most fun part.  I just used a section from Wikipedia for now:



I started with code to visualize the fractal as an image.  I used a modified version of this script to generate my "reference image:"

The image intentionally looks like a spooky X ray of some amoeba.  It has to be black and white - we're only dealing with three dimensions here!

Now I had reached the hard part: translating this image into a solid mesh.  This is where existing software really helped me.  I used Blender, an free 3D modeling and animation suite.  Blender allows you to create meshes using Python scripts.  Perfect.  First I tried calculating the fractal right in Blender as I generated the mesh.  This proved to be an impractical way to tweak the parameters.  So I wrote a script to read back the image and create a mesh to visualize the image with the pixel brightness as the Z axis.  (Scripts can be found here)

Here is what my generated mesh looks like in Blender:


Interesting!  A few details: I first used a Gaussian blur on the reference image to make it less "spikey".  I also upped the contrast a bit on the reference photo so the outer designs were more visible.  Finally I didn't bother orienting my face normals in any direction, so I had to use Blender's Mesh->Normals->Recalculate Outside function.  This gave me a solid mesh I could export to an STL.

Here's the model on Thingiverse: http://www.thingiverse.com/thing:209974/

I imported the STL into RepetierHost (which took about 20 minutes) and calculated the G code with Slic3r (which took another 30 minutes).  This gave me time to warm up and calibrate my bot.

Here's the final outcome:






5 comments:

  1. 3D printing, commonly known as ‘Additive Manufacture’ is a form of rapid prototyping where models are made layer by layer without the use of moulds. I know something information, to know you can click here…. 3D printer materials

    ReplyDelete
  2. I am very enjoyed for this blog. I feel strongly about it and love very important information. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. I know something information, to know you can click here…. 3D printer and printers



    ReplyDelete
  3. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! Open RC

    ReplyDelete
  4. May be the interfacing or the presentation needs to change every once in a while, however this idea will never vanish. check over here

    ReplyDelete