From 874e6bfd3e60e1439ad7ab66d8feb5c829dc9862 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 21 Jun 2021 08:51:44 +0800 Subject: [PATCH] refactor --- src/bezier_surface.scad | 22 ++++++++-------------- src/surface/sf_splines.scad | 19 +++++++------------ 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/bezier_surface.scad b/src/bezier_surface.scad index 7c3ae023..d29bd3b7 100644 --- a/src/bezier_surface.scad +++ b/src/bezier_surface.scad @@ -9,6 +9,7 @@ **/ use ; +use ; function bezier_surface(t_step, ctrl_pts) = let( @@ -18,18 +19,11 @@ function bezier_surface(t_step, ctrl_pts) = bezier_curve(t_step, ctrl_pts[i]) ], leng_pts0 = len(pts[0]), - leng_pts = len(pts), - sf = [for(x = 0; x < leng_pts0; x = x + 1) - bezier_curve( - t_step, - [for(y = 0; y < leng_pts; y = y + 1) pts[y][x]] - ) - ] + leng_pts = len(pts) ) - [ - for(y = 0; y < len(sf[0]); y = y + 1) - [ - for(x = 0; x < len(sf); x = x + 1) - sf[x][y] - ] - ]; \ No newline at end of file + m_transpose([for(x = 0; x < leng_pts0; x = x + 1) + bezier_curve( + t_step, + [for(y = 0; y < leng_pts; y = y + 1) pts[y][x]] + ) + ]); \ No newline at end of file diff --git a/src/surface/sf_splines.scad b/src/surface/sf_splines.scad index 808b6f8a..b69285af 100644 --- a/src/surface/sf_splines.scad +++ b/src/surface/sf_splines.scad @@ -8,6 +8,8 @@ * **/ +use ; + function sf_splines(ctrl_pts, row_spline, column_spline) = let( leng_ctrl_pts = len(ctrl_pts), @@ -17,16 +19,9 @@ function sf_splines(ctrl_pts, row_spline, column_spline) = row_spline(ctrl_pts[r]) ], leng_r_pts0 = len(r_pts[0]), - leng_r_pts = len(r_pts), - sf = [ - for(c = 0; c < leng_r_pts0; c = c + 1) - cspline([for(r = 0; r < leng_r_pts; r = r + 1) r_pts[r][c]]) - ] + leng_r_pts = len(r_pts) ) - [ - for(y = 0; y < len(sf[0]); y = y + 1) - [ - for(x = 0; x < len(sf); x = x + 1) - sf[x][y] - ] - ]; \ No newline at end of file + m_transpose([ + for(c = 0; c < leng_r_pts0; c = c + 1) + cspline([for(r = 0; r < leng_r_pts; r = r + 1) r_pts[r][c]]) + ]);