David Eccles (gringer) bioinformatics at gringene.org
Wed Apr 1 06:49:01 EDT 2015

```I found a bezier curve library that looks somewhat reasonable, in that it
doesn't have any hard-coded values or iteration limitations:

Compare with this library, which suffers from "I need to write a different
function for different arguments" syndrome:

Is there any chance of adding at least the bezier functions to OpenSCAD:

/*
Bernstein Basis Functions

For Bezier curves, these functions give the weights per control point.

*/
function BEZ03(u) = pow((1-u), 3);
function BEZ13(u) = 3*u*(pow((1-u),2));
function BEZ23(u) = 3*(pow(u,2))*(1-u);
function BEZ33(u) = pow(u,3);

// Calculate a singe point along a cubic bezier curve
// Given a set of 4 control points, and a parameter 0 <= 'u' <= 1
// These functions will return the exact point on the curve
function PointOnBezCubic2D(p0, p1, p2, p3, u) = [
BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1]];

function PointOnBezCubic3D(p0, p1, p2, p3, u) = [
BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1],
BEZ03(u)*p0[2]+BEZ13(u)*p1[2]+BEZ23(u)*p2[2]+BEZ33(u)*p3[2]];

The modules need a bit of work, because they're generating duplicate
points at the focal location, instead of combining the triangles into a
single polygon.

```