Continuing the madness... I was getting laughed at in my Design 101 class, so the only way I thought of to silence the other kids was to come out with my SuperShapes!
After having done the previous SuperEllipse work, it was just a matter of time before the formulas came knocking at my door wanting to be implemented.
This thing implements the SuperFormula (muwaaahhhaahaaahaaa)!!
What the heck is that? Best thing is to take a look at the pretty pictures at this web site: paulbourke.net/geometry/supershape3d/
If you're really a math nutter, then take a look at the math as well. It's actually not that complicated. The complication here is just turning the formula into something that can be dealt with by OpenScad. In particular, making sure the thing turns out to be 2-manifold, so that you can actually generate .stl files and print the results, therein lies the rub.
The supershape.scad files contains two rotines of interest:
RenderSuperShape2D() - This takes the definition of a single supershape, and renders the curve of that supershape in 2D, using wireframe. With this single routine, you can go to the wiki entry for Superfomula (http://en.wikipedia.org/wiki/Superformula) and plug in the various numbers, and see pretty pictures.
RenderSuperShape() - This takes two supershape definitions (one modulates the other), and renders real pretty pictures. You can look at the Paul Bourke site to get very interesting parameters to plug into that one.
Another source of parameters might be POVRay files.
That's enough for a Friday post I think.
But wait, there's more...
You also get the procedural texture mapping checkerboard pattern, thrown in for free. What is procedural texture mapping? Well, instead of using a bitmap to represent the different colors (or heights) on an object, you can just call a routine and ask it for the color at a particular position. No fus, no muss, no arrays to slow you down! At any rate, it's just a little hidden gem.
This code is public domain. I figure having such a nice routine freely available might encourage people to make some very interesting shapes.
Challenge: How the heck do you get OpenScad to display in wireframe, and with a fade on the other colors?
Added the tristar.stl file. This was an experiment in rendering the 2D shapes with faces, and not just wireframes, then using them with CSG operations. The result is of course a deadly weapon once rendered in hardened steel and sharpened.