From 2a3596895f71637037acabcd8a888a4a5aade986 Mon Sep 17 00:00:00 2001 From: Dmitry Frolov Date: Tue, 1 May 2018 10:44:20 +0700 Subject: [PATCH 1/2] Remove excess point at the end of the bezier_curve() output --- src/bezier_curve.scad | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bezier_curve.scad b/src/bezier_curve.scad index 9f09cb62..38f41639 100644 --- a/src/bezier_curve.scad +++ b/src/bezier_curve.scad @@ -54,9 +54,8 @@ function _bezier_curve_point(t, points) = function bezier_curve(t_step, points) = let( - pts = concat([ - for(t = [0: t_step: 1]) - _bezier_curve_point(t, points) - ], [_bezier_curve_point(1, points)]) + pts = [ for(t = [0: t_step: 1]) + _bezier_curve_point(t, points) + ] ) - len(points[0]) == 3 ? pts : [for(pt = pts) __to2d(pt)]; \ No newline at end of file + len(points[0]) == 3 ? pts : [for(pt = pts) __to2d(pt)]; From 736b63a0aa78cc66b996a64e12ccde0c53dafe7f Mon Sep 17 00:00:00 2001 From: Dmitry Frolov Date: Tue, 1 May 2018 22:56:43 +0700 Subject: [PATCH 2/2] Add the point at the end for fractional number of segments --- src/bezier_curve.scad | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bezier_curve.scad b/src/bezier_curve.scad index 38f41639..1d52d962 100644 --- a/src/bezier_curve.scad +++ b/src/bezier_curve.scad @@ -54,8 +54,9 @@ function _bezier_curve_point(t, points) = function bezier_curve(t_step, points) = let( - pts = [ for(t = [0: t_step: 1]) - _bezier_curve_point(t, points) - ] + pts = concat([ + for(t = [0: ceil(1 / t_step) - 1]) + _bezier_curve_point(t * t_step, points) + ], [_bezier_curve_point(1, points)]) ) len(points[0]) == 3 ? pts : [for(pt = pts) __to2d(pt)];