diff --git a/src/experimental/_impl/_px_surround_impl.scad b/src/experimental/_impl/_px_contour_impl.scad similarity index 65% rename from src/experimental/_impl/_px_surround_impl.scad rename to src/experimental/_impl/_px_contour_impl.scad index 96cae427..4c42ac8e 100644 --- a/src/experimental/_impl/_px_surround_impl.scad +++ b/src/experimental/_impl/_px_contour_impl.scad @@ -1,6 +1,6 @@ use ; -function _px_surround_corner_value(pts, x, y) = +function _px_contour_corner_value(pts, x, y) = let( c1 = has(pts, [x, y - 1], sorted = true) || has(pts, [x - 1, y - 1], sorted = true) ? 1 : 0, c2 = has(pts, [x - 1, y], sorted = true) || has(pts, [x - 1, y + 1], sorted = true) ? 2 : 0, @@ -9,27 +9,27 @@ function _px_surround_corner_value(pts, x, y) = ) c1 + c2 + c3 + c4; -_px_surround_dir_table = [ +_px_contour_dir_table = [ [4, 0], [6, 0], [7, 0], // RIGHT [8, 1], [12, 1], [14, 1], // DOWN [2, 2], [3, 2], [11, 2], // UP [1, 3], [9, 3], [13, 3] // LEFT ]; -function _px_surround_dir(cr_value) = - lookup(cr_value, _px_surround_dir_table); +function _px_contour_dir(cr_value) = + lookup(cr_value, _px_contour_dir_table); -_px_surround_nxt_offset = [ +_px_contour_nxt_offset = [ [1, 0], // RIGHT [0, -1], // DOWN [0, 1], // UP [-1, 0] // LEFT ]; -function _px_surround_travel(pts, p, fst) = +function _px_contour_travel(pts, p, fst) = let( - dir_i = _px_surround_dir(_px_surround_corner_value(pts, p[0], p[1])), - nxt_p = p + _px_surround_nxt_offset[dir_i] + dir_i = _px_contour_dir(_px_contour_corner_value(pts, p[0], p[1])), + nxt_p = p + _px_contour_nxt_offset[dir_i] ) nxt_p == fst ? [p] : concat( - [p], _px_surround_travel(pts, nxt_p, fst) + [p], _px_contour_travel(pts, nxt_p, fst) ); diff --git a/src/experimental/demo/px_surround_demo.scad b/src/experimental/demo/px_contour_demo.scad similarity index 78% rename from src/experimental/demo/px_surround_demo.scad rename to src/experimental/demo/px_contour_demo.scad index 643f4eef..47657b7b 100644 --- a/src/experimental/demo/px_surround_demo.scad +++ b/src/experimental/demo/px_contour_demo.scad @@ -2,14 +2,14 @@ use ; use ; use ; use ; -use ; +use ; pts = px_circle(10, true); for(p = pts) { translate(p) square(1, center = true); } -#hull_polyline2d(px_surround(pts), width = .1); +#hull_polyline2d(px_contour(pts), width = .1); pentagram = [ @@ -23,5 +23,5 @@ translate([30, 0]) { linear_extrude(1, scale = 0.5) square(1, center = true); } - #hull_polyline2d(px_surround(pts2), width = .1); + #hull_polyline2d(px_contour(pts2), width = .1); } \ No newline at end of file diff --git a/src/experimental/px_surround.scad b/src/experimental/px_contour.scad similarity index 57% rename from src/experimental/px_surround.scad rename to src/experimental/px_contour.scad index e27f774b..6bae9188 100644 --- a/src/experimental/px_surround.scad +++ b/src/experimental/px_contour.scad @@ -1,10 +1,10 @@ -use ; +use ; use ; -function px_surround(points) = +function px_contour(points) = let( // always start from the left-bottom pt sortedXY = sort(points, by = "vt"), fst = sortedXY[0] + [-1, -1] ) - _px_surround_travel(sortedXY, fst, fst); \ No newline at end of file + _px_contour_travel(sortedXY, fst, fst); \ No newline at end of file