diff --git a/src/_impl/_bezier_smooth_impl.scad b/src/_impl/_bezier_smooth_impl.scad index 79dc9afc..39174df5 100644 --- a/src/_impl/_bezier_smooth_impl.scad +++ b/src/_impl/_bezier_smooth_impl.scad @@ -28,29 +28,28 @@ function _corner_ctrl_pts(round_d, p1, p2, p3) = function _bezier_corner(round_d, t_step, p1, p2, p3) = bezier_curve(t_step, _corner_ctrl_pts(round_d, p1, p2, p3)); -function _recursive_bezier_smooth(pts, round_d, t_step, leng, angle_threshold) = +function _bezier_smooth_corners(pts, round_d, t_step, leng, angle_threshold) = let(end_i = leng - 2) [ for(i = 0; i < end_i; i = i + 1) - each - angle_between(pts[i] - pts[i + 1], pts[i + 1] - pts[i + 2]) > angle_threshold ? - _bezier_corner(round_d, t_step, pts[i], pts[i + 1], pts[i + 2]) : - [pts[i + 1]] + each angle_between(pts[i] - pts[i + 1], pts[i + 1] - pts[i + 2]) > angle_threshold ? + _bezier_corner(round_d, t_step, pts[i], pts[i + 1], pts[i + 2]) : + [pts[i + 1]] ]; function _bezier_smooth_impl(path_pts, round_d, t_step, closed, angle_threshold) = let( pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)], leng = len(pts), - middle_pts = _recursive_bezier_smooth(pts, round_d, t_step, leng, angle_threshold), + middle_pts = _bezier_smooth_corners(pts, round_d, t_step, leng, angle_threshold), pth_pts = closed ? concat( - _recursive_bezier_smooth( + _bezier_smooth_corners( [pts[leng - 1], pts[0], pts[1]], round_d, t_step, 3, angle_threshold ), middle_pts, - _recursive_bezier_smooth( + _bezier_smooth_corners( [pts[leng - 2], pts[leng - 1], pts[0]], round_d, t_step, 3, angle_threshold )