From 5d02489db8bfb565e6551b3fd6604cb3bb80068a Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 30 Apr 2017 15:47:58 +0800 Subject: [PATCH] passing points is not necessary --- src/polyline3d.scad | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/polyline3d.scad b/src/polyline3d.scad index fd834dae..05a143e7 100644 --- a/src/polyline3d.scad +++ b/src/polyline3d.scad @@ -12,9 +12,11 @@ **/ module polyline3d(points, thickness, startingStyle = "CAP_CIRCLE", endingStyle = "CAP_CIRCLE") { + leng_pts = len(points); + module line_segment(index) { styles = index == 1 ? [startingStyle, "CAP_BUTT"] : ( - index == len(points) - 1 ? ["CAP_SPHERE", endingStyle] : [ + index == leng_pts - 1 ? ["CAP_SPHERE", endingStyle] : [ "CAP_SPHERE", "CAP_BUTT" ] ); @@ -23,12 +25,12 @@ module polyline3d(points, thickness, startingStyle = "CAP_CIRCLE", endingStyle = p1Style = styles[0], p2Style = styles[1]); } - module polyline3d_inner(points, index) { - if(index < len(points)) { + module polyline3d_inner(index) { + if(index < leng_pts) { line_segment(index); - polyline3d_inner(points, index + 1); + polyline3d_inner(index + 1); } } - polyline3d_inner(points, 1); + polyline3d_inner(1); } \ No newline at end of file