Bezier Library for OpenScad

by ckirby, published

Bezier Library for OpenScad by ckirby May 10, 2013
0 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps



BSD License
Bezier Library for OpenScad by ckirby is licensed under the BSD License license.

Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

6991Views 2443Downloads


See http://github.com/uplake/BezierScad

Updated 5/10/13--fixed triangle winding in centered BezWall; use polyhedron for variable-height BezArc.

I wanted a bezier library that could handle an arbitrary number of control points. When working on thingiverse.com/thing:77586, I also wanted to rotate extrude a "wall" defined by a bezier path and a width.

BezWall is the workhorse function. The "ctlPts" parameter accepts between 1-8 bezier control points.

The parameters "width" and "height" accept static values (e.g., 5) specifying the width and height of the wall. If height is 0, it will generate a 2d object you can extrude yourself.

The alternate parameters "widthCtls" and "heightCtls" accept an array of values that will be bezier-interpolated along the length of the wall.

If the "centered" parameter is "true", the wall is centered on the path defined by "ctlPts". Otherwise, one edge of the wall is defined by "ctlPts".

At the moment, there is no documentation! But there is a test file that runs through most of the available features.


I'd previously done some work writing coffeescript code to generate bezier interpolation functions that accept an arbitrary number of control points, and I'd written some coffeescript to generate openscad code. It occurred to me that I could use coffeescript to automate a lot of the tedium in writing openscad functions. So, the coffeescript file in this thing will generate openscad functions to handle bezier interpolation with a varying number of control points. The attached BezierScad.scad file can deal with up to 8 control points, but you can easily modify orderMax in the coffeescript file to have it generate functions that can deal with higher or lower orders.

The BezLine function is simpler than BezWall and offers a subset of the BezWall functionality.

BezLine takes an array of 1-8 control points and an array of 1-8 width values, which will be bezier interpolated as widths for the resulting line.

BezLine doesn't accept a "steps" parameter. Rather, it takes a "resolution" parameter of between 2-6. The resulting line will have (2**resolution) segments.

BezArc returns a shape similar to that generated by WilliamAAdams' BezQuadCurve function.

All Apps

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

i tried to combine a Bezier object with an cylinder object. when I tried to render I get the following error :
Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw64-master/mxe-w64/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
Geometries in cache: 57
Geometry cache size in bytes: 174936
CGAL Polyhedrons in cache: 1
CGAL cache size in bytes: 79744
Total rendering time: 0 hours, 0 minutes, 0 seconds
Top level object is a 3D object:
Simple: yes
Vertices: 60
Halfedges: 180
Edges: 90
Halffacets: 64
Facets: 32
Volumes: 2
Rendering finished.
What is going wrong ?

use ;

[30, 0],
[2, 3],
], width = [4], focalPoint = [0,0], steps = 30, height = 1);

Hi. First off, amazingly useful function, thank you for making it and sharing.

I have an annoying question, that you might be able to help with. How easy would it be to extend this to a Bezier Surface? I have had a look through the library, but my coding skills are not up to the job of both wrapping my head around the maths and making open scad play well with them.

Is this something you have looked into? If so, do you have any pointers that could help me on this?

What is the best way of describing a rotational shape using this module? I want to design a cone of a model rocket similar to the one at http://www.thingiverse.com/thing:127354http://www.thingiverse.com/thi.... I want to have a 90 degree angle at the apex, and a wall thickness of 1.5. But if I rotate_extrude() BezWall(..., width=1.5), there is a tiny hole in the apex, caused by the end of the BezWall not being perpendicular to the axis of rotate_extrude(). What is the best way to do this? So far I am using the following, which has the mentioned problem:
rotate_extrude() {
[9, 0], // base
[9, 30], // start with cylindrical shape
[9, 65-9], // 45 degrees in the apex
[0, 65], // apex
], height=0, width=1, steps = 40, showCtlR = false);
Also, a minor nitpick: naming the parameter "showCtlR" in BezWall() and "showCtls" in BezLine() sucks a bit :-)

Disposable Rocket
by kebes22

I am getting "Object isn't a valid 2-manifold!" when tying to export an stl based on the Bezarc function, Bezwall seems ok.
// same problem with version 2013.01 and 2014.03
use <bezierscad.scad>;
BezArc([[-10,-1],[-10, -6],[-1, -1],[-5, -10],[-1,-10]], [-1,-1], steps = 16, heightCtls = [1,2,10,2,1]);

This is great; offers a lot more control than other similar functions I've found. I'm using it to create a mold for a carbon fiber guitar.

I'm trying to figure out how I could take one of the simple BezWall functions and have it filled in. Rather than a wall with a bezier curve, I'm looking for a slab with a bezier curve edge (like this, but this function doesn't have enough control points): http://www.thingiverse.com/thing:8483http://www.thingiverse.com/thi...

This is my first dive into CAD, so there might be a way to do this that I'm not seeing.


Bezier Heart in OpenScad

Hi, I think you're looking for the BezArc function, which creates a solid around a focal point. You can also vary the height of the solid vary according to a bezier curve by passing in an array of "heightCtls", (e.g., heightCtls = [1,2,10,2,1]) instead of a static "height" value.

  [-10, 0],
  [-10, -6],
  [-1, -1],
  [-5, -10],
  [ 0,-10]
  ], focalPoint = [0, 0], steps = 16, height = 10);

awesome. Thanks. Sorry I couldn't sort it out from the examples you gave. Got a paypal account? I'd like to buy you a coffee.