From a81c8dd7aaf50664cac608e5e8ae4f02c19c1282 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 22 Mar 2020 07:36:19 +0800 Subject: [PATCH] rename --- .../_impl/_marching_squares_impl.scad | 64 +++++++++---------- src/experimental/marching_squares.scad | 8 +-- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/experimental/_impl/_marching_squares_impl.scad b/src/experimental/_impl/_marching_squares_impl.scad index f339c2c1..61d75dbf 100644 --- a/src/experimental/_impl/_marching_squares_impl.scad +++ b/src/experimental/_impl/_marching_squares_impl.scad @@ -1,10 +1,10 @@ -function _contours_pn_label(pts, sigma) = +function _isolines_pn_label(pts, sigma) = [ for(row = pts) [for(p = row) [p[0], p[1], p[2], p[2] - sigma >= 0]] ]; -function _contours_corner_value(cell_pts) = +function _isolines_corner_value(cell_pts) = let( c0 = cell_pts[0][3] ? 1 : 0, c1 = cell_pts[1][3] ? 2 : 0, @@ -23,23 +23,23 @@ function interpolated_pt(p0, p1, sigma) = ) [x0 + v[0] * t, y0 + v[1] * t]; -function _case1_contours(cell_pts, sigma) = [ +function _case1_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)] ]; -function _case2_contours(cell_pts, sigma) = [ +function _case2_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)] ]; -function _case3_contours(cell_pts, sigma) = [ +function _case3_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)] ]; -function _case4_contours(cell_pts, sigma) = [ +function _case4_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)] ]; -function _case5_contours(cell_pts, sigma) = +function _case5_isolines(cell_pts, sigma) = let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2]) mdpz >= sigma ? [ @@ -52,19 +52,19 @@ function _case5_contours(cell_pts, sigma) = [interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)] ]; -function _case6_contours(cell_pts, sigma) = [ +function _case6_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)] ]; -function _case7_contours(cell_pts, sigma) = [ +function _case7_isolines(cell_pts, sigma) = [ [interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[1], cell_pts[2], sigma)] ]; -function _case8_contours(cell_pts, sigma) = _case7_contours(cell_pts, sigma); +function _case8_isolines(cell_pts, sigma) = _case7_isolines(cell_pts, sigma); -function _case9_contours(cell_pts, sigma) = _case6_contours(cell_pts, sigma); +function _case9_isolines(cell_pts, sigma) = _case6_isolines(cell_pts, sigma); -function _case10_contours(cell_pts, sigma) = +function _case10_isolines(cell_pts, sigma) = let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2]) mdpz >= sigma ? [ @@ -77,28 +77,28 @@ function _case10_contours(cell_pts, sigma) = [interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)] ]; -function _case11_contours(cell_pts, sigma) = _case4_contours(cell_pts, sigma); +function _case11_isolines(cell_pts, sigma) = _case4_isolines(cell_pts, sigma); -function _case12_contours(cell_pts, sigma) = _case3_contours(cell_pts, sigma); +function _case12_isolines(cell_pts, sigma) = _case3_isolines(cell_pts, sigma); -function _case13_contours(cell_pts, sigma) = _case2_contours(cell_pts, sigma); +function _case13_isolines(cell_pts, sigma) = _case2_isolines(cell_pts, sigma); -function _case14_contours(cell_pts, sigma) = _case1_contours(cell_pts, sigma); +function _case14_isolines(cell_pts, sigma) = _case1_isolines(cell_pts, sigma); -function _contours_of(cell_pts, sigma) = - let(cv = _contours_corner_value(cell_pts)) +function _isolines_of(cell_pts, sigma) = + let(cv = _isolines_corner_value(cell_pts)) cv == 0 ? [] : - cv == 1 ? _case1_contours(cell_pts, sigma) : - cv == 8 ? _case2_contours(cell_pts, sigma) : - cv == 9 ? _case3_contours(cell_pts, sigma) : - cv == 4 ? _case4_contours(cell_pts, sigma) : - cv == 5 ? _case5_contours(cell_pts, sigma) : - cv == 12 ? _case6_contours(cell_pts, sigma) : - cv == 13 ? _case7_contours(cell_pts, sigma) : - cv == 2 ? _case8_contours(cell_pts, sigma) : - cv == 3 ? _case9_contours(cell_pts, sigma) : - cv == 10 ? _case10_contours(cell_pts, sigma) : - cv == 11 ? _case11_contours(cell_pts, sigma) : - cv == 6 ? _case12_contours(cell_pts, sigma) : - cv == 7 ? _case13_contours(cell_pts, sigma) : - cv == 14 ? _case14_contours(cell_pts, sigma) : []; + cv == 1 ? _case1_isolines(cell_pts, sigma) : + cv == 8 ? _case2_isolines(cell_pts, sigma) : + cv == 9 ? _case3_isolines(cell_pts, sigma) : + cv == 4 ? _case4_isolines(cell_pts, sigma) : + cv == 5 ? _case5_isolines(cell_pts, sigma) : + cv == 12 ? _case6_isolines(cell_pts, sigma) : + cv == 13 ? _case7_isolines(cell_pts, sigma) : + cv == 2 ? _case8_isolines(cell_pts, sigma) : + cv == 3 ? _case9_isolines(cell_pts, sigma) : + cv == 10 ? _case10_isolines(cell_pts, sigma) : + cv == 11 ? _case11_isolines(cell_pts, sigma) : + cv == 6 ? _case12_isolines(cell_pts, sigma) : + cv == 7 ? _case13_isolines(cell_pts, sigma) : + cv == 14 ? _case14_isolines(cell_pts, sigma) : []; diff --git a/src/experimental/marching_squares.scad b/src/experimental/marching_squares.scad index 2c20812b..14d4d289 100644 --- a/src/experimental/marching_squares.scad +++ b/src/experimental/marching_squares.scad @@ -1,7 +1,7 @@ use ; function marching_squares(points, sigma) = - let(labeled_pts = _contours_pn_label(points, sigma)) + let(labeled_pts = _isolines_pn_label(points, sigma)) [ for(y = [0:len(labeled_pts) - 2]) [ @@ -12,9 +12,9 @@ function marching_squares(points, sigma) = p2 = labeled_pts[y + 1][x + 1], p3 = labeled_pts[y][x + 1], cell_pts = [p0, p1, p2, p3], - contours_lt = _contours_of(cell_pts, sigma) + isolines_lt = _isolines_of(cell_pts, sigma) ) - if(contours_lt != []) - each contours_lt + if(isolines_lt != []) + each isolines_lt ] ]; \ No newline at end of file