Mr Bezier goes to OpenScad

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.

Advertisements

4 Comments on “Mr Bezier goes to OpenScad”

  1. […] UPDATE: If you’re interested in more words on this design, you can take a look here: https://williamaadams.wordpress.com/2011/05/12/mr-bezier-goes-to-openscad/ […]

  2. Esn says:

    This is really great. I have a few questions, though:

    Can I use this for curvy 3D lines? Is there an example I can play around with, to see how it works?

    More specifically, I’m trying to create a curvy tunnel that would look something like this from the top of the z axis: http://imgur.com/a/sDS71 and like this from the top of the x axis: http://imgur.com/a/NYEa1 (the colors are unimportant).

    Also, when I preview some of the demo examples in the file, I get the message “DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.”

    Thank you!

  3. Esn says:

    Hi, did my previous message get through?

  4. Esn says:

    (guess not, I’ll try again)

    This is really great. I have a few questions, though:

    Can I use this for curvy 3D lines? Is there an example I can play around with, to see how it works?

    More specifically, I’m trying to create a curvy tunnel that would look something like this from the top of the z axis: imgur dot com/a/sDS71 and like this from the top of the x axis: imgur dot com/a/NYEa1 (the colors are unimportant).

    Also, when I preview some of the demo examples in the file, I get the message “DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.”

    Thank you!


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 )

Google+ photo

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

Connecting to %s