Mr Bezier goes to OpenScadPosted: May 12, 2011
I have been using OpenScad since November of 2010, when I first made this simple design: http://www.thingiverse.com/thing:4828 . It’s been a great ride with OpenScad so far. I wanted to learn a design tool that did not require me to climb a very steep learning curve like with Blender, or AutoCAD or SolidWorks.
Well, OpenScad has been a great tool in this regard thus far. I’ve been able to create all manner of thing, mostly functional. I have now gotten to the point where I’ve needed to create more intricate and elegant parts. No longer satisfied with blocky angular designs. I need some nice curves, and more than can be had from doing simple CSG with cyclinders and blocks.
So, I spent some time thinking about how to use Bezier curves in OpenScad. Ideally OpenScad would have some curves built into the system, but as far as I know, it does not. So, I created my own Bezier functions in OpenScad: http://www.thingiverse.com/thing:8443
I did this because I simply wanted to do some nice fillets on various designs, and you can only go so far by subtracting a cylinder from a square. With this function, I support cubic Bezier curves (start point, end point, two control points). It’s very nice for general purpose stuff, not just fillets.
That was a good start to Bezier curves in OpenScad. Then I went further, and added a couple more functions. The first one was to add Bezier ribbons (http://www.thingiverse.com/thing:8454). That is, you define two Bezier curves. The function will create a ‘ribbon’ between the two curves. This can be used for simple things like a ramp, or a handle to a cup, or what have you.
At the same time that I was creating the ribboning function, I realized that it would not be that hard to demonstrate how to use a Bezier curve to change colors on the image over the length of the curve. This lead to the creation of a secondary function that can return three values along the Bezier curve. This is handy when the control points are actually color values, and you want to smoothly interpolate between them.
This seemed to be going quite well, so I added one more function. This last one does a rotation of a Bezier strip.
This one looks the coolest of all so far. It demonstrates the Bezier curve, and the rotation, and the color gradient, and it all happens in just a couple lines of code. That’s a tremendously valuable tool to have in the modeling toolchest.
Now that I have this tool, I have started to use it to improve on designs. Here is a new version of the effector end of the PolyBot: http://www.thingiverse.com/thing:8456
This has been a good outcome so far. I was dreading having to do the work of modeling using a different tool, or importing meshes, which I then could not easily alter. Now that I have essentially built Bezier curves into OpenScad, I can stick with this tool longer.
I would like to explore creating Hermite curves, and then possibly dealing with C1/2 continuity of curve segments, but I’m happy with this for now.