From a8ed6214be768c33f0fa417a18f916798b236d39 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Wed, 4 Mar 2020 22:26:23 -0500 Subject: [PATCH] Fixed bug in path_to_bezier and added example to smooth_path. --- beziers.scad | 4 ++-- rounding.scad | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/beziers.scad b/beziers.scad index 3375402..e8272e4 100644 --- a/beziers.scad +++ b/beziers.scad @@ -332,9 +332,9 @@ function bezier_polyline(bezier, splinesteps=16, N=3) = let( // closed = set to true for a closed path. Default: false function path_to_bezier(path, tangent, closed=false) = assert(is_path(path,dim=undef),"Input path is not a valid path") - assert(is_undef(tangent) || is_path(tanget,dim=len(path[0])),"Tangent must be a path of the same dimension as the input path") + assert(is_undef(tangent) || is_path(tangent,dim=len(path[0])),"Tangent must be a path of the same dimension as the input path") let( - tangent = is_def(tangent)? tangent : path_tangents(path, closed=closed), + tangent = is_def(tangent)? [for(t=tangent) unit(t)] : path_tangents(path, closed=closed), lastpt = len(path) - (closed?0:1) ) [for(i=[0:lastpt-1]) each [path[i], path[i]+tangent[i], select(path,i+1)-select(tangent,i+1)], diff --git a/rounding.scad b/rounding.scad index 5015b24..bcec54b 100644 --- a/rounding.scad +++ b/rounding.scad @@ -425,6 +425,8 @@ function _rounding_offsets(edgespec,z_dir=1) = // stroke(smooth_path(square(4)), width=0.1); // Example(2D): Closing the path changes the end tangents // polygon(smooth_path(square(4), closed=true)); +// Example(2D): You can specify your own tangent values to alter the shape of the curve +// polygon(smooth_path(square(4),tangent=[[-2,-1], [-2,1], [1,2], [2,-1]],closed=true)); // Example(FlatSpin): Works on 3d paths as well // path = [[0,0,0],[3,3,2],[6,0,1],[9,9,0]]; // trace_polyline(smooth_path(path),size=.3);