From 711c9b902d41900bce7f41e6450fd17c5c2c6f27 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 13 Mar 2020 12:57:13 +0800 Subject: [PATCH] refactor --- src/experimental/mz_hamiltonian.scad | 2 +- src/experimental/px_surround.scad | 2 +- src/pixel/px_circle.scad | 2 +- src/pixel/px_cylinder.scad | 2 +- src/pixel/px_polygon.scad | 2 +- src/pixel/px_polyline.scad | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/experimental/mz_hamiltonian.scad b/src/experimental/mz_hamiltonian.scad index e3f062d9..f6ff3cf6 100644 --- a/src/experimental/mz_hamiltonian.scad +++ b/src/experimental/mz_hamiltonian.scad @@ -26,6 +26,6 @@ function mz_hamiltonian(rows, columns, start) = [for(x = [0:columns * 2 - 1]) [x, 0]], [for(y = [0:rows * 2 - 1]) [0, y]] ), - dot_pts = dedup(sort(sort(all, by = "x"), by = "y"), sorted = true) + dot_pts = dedup(sort(all, by = "vt"), sorted = true) ) _mz_hamiltonian_travel(dot_pts, start, rows * columns * 4); \ No newline at end of file diff --git a/src/experimental/px_surround.scad b/src/experimental/px_surround.scad index 5cb21245..e27f774b 100644 --- a/src/experimental/px_surround.scad +++ b/src/experimental/px_surround.scad @@ -4,7 +4,7 @@ use ; function px_surround(points) = let( // always start from the left-bottom pt - sortedXY = sort(sort(points, by = "x"), by = "y"), + sortedXY = sort(points, by = "vt"), fst = sortedXY[0] + [-1, -1] ) _px_surround_travel(sortedXY, fst, fst); \ No newline at end of file diff --git a/src/pixel/px_circle.scad b/src/pixel/px_circle.scad index 43b87746..7e8d6661 100644 --- a/src/pixel/px_circle.scad +++ b/src/pixel/px_circle.scad @@ -14,4 +14,4 @@ use ; function px_circle(radius, filled = false) = let(all = _px_circle_impl(radius, filled)) - dedup(sort(sort(all, by = "x"), by = "y"), sorted = true); \ No newline at end of file + dedup(sort(all, by = "vt"), sorted = true); \ No newline at end of file diff --git a/src/pixel/px_cylinder.scad b/src/pixel/px_cylinder.scad index d52ad88b..04a66be2 100644 --- a/src/pixel/px_cylinder.scad +++ b/src/pixel/px_cylinder.scad @@ -14,4 +14,4 @@ use ; function px_cylinder(r, h, filled = false, thickness = 1) = let(all = _px_cylinder_impl(r, h, filled, thickness)) - dedup(sort(sort(sort(all, by = "x"), by = "y"), by = "z"), sorted = true); \ No newline at end of file + dedup(sort(all, by = "vt"), sorted = true); \ No newline at end of file diff --git a/src/pixel/px_polygon.scad b/src/pixel/px_polygon.scad index 8c1d461e..bac65467 100644 --- a/src/pixel/px_polygon.scad +++ b/src/pixel/px_polygon.scad @@ -7,7 +7,7 @@ function px_polygon(points, filled = false) = let(contour = px_polyline(concat(points, [points[0]]))) !filled ? contour : let( - sortedXY = sort(sort(contour, by = "x"), by = "y"), + sortedXY = sort(contour, by = "vt"), ys = [for(p = sortedXY) p[1]], rows = [ for(y = [min(ys):max(ys)]) diff --git a/src/pixel/px_polyline.scad b/src/pixel/px_polyline.scad index 48873b22..dd0adb02 100644 --- a/src/pixel/px_polyline.scad +++ b/src/pixel/px_polyline.scad @@ -22,7 +22,7 @@ function px_polyline(points) = polyline = [for(line = __lines_from(pts)) each px_line(line[0], line[1])] ) dedup(is_2d ? - sort(sort([for(pt = polyline) __to2d(pt)], by = "x"), by = "y") + sort([for(pt = polyline) __to2d(pt)], by = "vt") : - sort(sort(sort(polyline, by = "x"), by = "y"), by = "z") + sort(polyline, by = "vt") , sorted = true); \ No newline at end of file