From 8f76446bd8c033ac3595e34e75509d18dd3fa6d9 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 28 Feb 2022 11:05:50 +0800 Subject: [PATCH] use [each lt, v] to replace concat(lt, [v]) --- examples/dragon/dragon_claw.scad | 16 +++++++++++++- examples/dragon/dragon_scales.scad | 12 +++++----- examples/dragon/hilbert_dragon.scad | 6 +---- examples/dragon/hilbert_dragon_low_poly.scad | 12 +++++----- .../dragon/torus_knot_dragon_low_poly.scad | 2 +- examples/hollow_out/hollow_out_cylinder.scad | 22 +++++++++---------- examples/hollow_out/hollow_out_holder.scad | 10 ++++----- examples/hollow_out/hollow_out_starburst.scad | 12 +++++----- examples/hollow_out/hollow_out_vase.scad | 17 +++++++------- 9 files changed, 58 insertions(+), 51 deletions(-) diff --git a/examples/dragon/dragon_claw.scad b/examples/dragon/dragon_claw.scad index 188b6fae..16a31b00 100644 --- a/examples/dragon/dragon_claw.scad +++ b/examples/dragon/dragon_claw.scad @@ -36,6 +36,20 @@ module dragon_claw() { rotate_extrude($fn = 7) polygon(pts); linear_extrude(5) - polygon(dedup(concat(claw_path1, claw_path2, claw_path3, claw_path4, [[-2, -.75], [-1.45, -1.45]], claw_path5, [[1.45, -1.45], [2, -.75]]))); + polygon( + dedup( + [ + each claw_path1, + each claw_path2, + each claw_path3, + each claw_path4, + [-2, -.75], + [-1.45, -1.45], + each claw_path5, + [1.45, -1.45], + [2, -.75] + ] + ) + ); } } \ No newline at end of file diff --git a/examples/dragon/dragon_scales.scad b/examples/dragon/dragon_scales.scad index 9a0cdb65..7793b2f3 100644 --- a/examples/dragon/dragon_scales.scad +++ b/examples/dragon/dragon_scales.scad @@ -9,14 +9,14 @@ function one_body_scale(body_r, body_fn, scale_fn, scale_tilt_a) = scale_r = PI * body_r / body_fn, double_scale_r = scale_r * 2, shape_scale = shape_circle(scale_r, $fn = scale_fn), - scale_pts = concat( - [[0, 0, scale_r / 2 + body_r]], - [ + scale_pts = [ + [0, 0, scale_r / 2 + body_r], + each [ for(p = shape_scale) ptf_rotate([p[0], p[1] * 2.01, body_r], [scale_tilt_a, 0, 0]) - ], - [for(p = shape_scale) [p[0], p[1] * 2.01, 0]] - ) + ], + each [for(p = shape_scale) [p[0], p[1] * 2.01, 0]] + ] ) convex_hull3(scale_pts); diff --git a/examples/dragon/hilbert_dragon.scad b/examples/dragon/hilbert_dragon.scad index 4eac5762..4aca37b4 100644 --- a/examples/dragon/hilbert_dragon.scad +++ b/examples/dragon/hilbert_dragon.scad @@ -34,11 +34,7 @@ module hilbert_dragon() { scale_tilt_a = -3; lines = hilbert_curve(); - hilbert_path = dedup( - concat( - [for(line = lines) line[0]], - [lines[len(lines) - 1][1]]) - ); + hilbert_path = dedup([each [for(line = lines) line[0]], lines[len(lines) - 1][1]]); smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.45, t_step = 0.15); dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); diff --git a/examples/dragon/hilbert_dragon_low_poly.scad b/examples/dragon/hilbert_dragon_low_poly.scad index 05386d25..7ac6361a 100644 --- a/examples/dragon/hilbert_dragon_low_poly.scad +++ b/examples/dragon/hilbert_dragon_low_poly.scad @@ -11,11 +11,7 @@ hilbert_dragon_low_poly(); module hilbert_dragon_low_poly() { lines = hilbert_curve(); - hilbert_path = dedup( - concat( - [for(line = lines) line[0]], - [lines[len(lines) - 1][1]]) - ); + hilbert_path = dedup([each [for(line = lines) line[0]], lines[len(lines) - 1][1]]); smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.48, t_step = 0.2); dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); @@ -37,7 +33,11 @@ module hilbert_dragon_low_poly() { pts = [for(p = body_shape) p * 0.007]; p = dragon_body_path[0]; - path_extrude(pts, concat([p + [0.0155, 0, 0.175]], [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]), scale = 0.9); + path_extrude( + pts, + [p + [0.0155, 0, 0.175], each [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]], + scale = 0.9 + ); translate([0.125, 0, -2.73]) scale(0.009) diff --git a/examples/dragon/torus_knot_dragon_low_poly.scad b/examples/dragon/torus_knot_dragon_low_poly.scad index 860f98df..5288e003 100644 --- a/examples/dragon/torus_knot_dragon_low_poly.scad +++ b/examples/dragon/torus_knot_dragon_low_poly.scad @@ -31,7 +31,7 @@ module torus_knot_dragon_low_poly() { pts = [for(p = body_shape) p * 0.015]; p = dragon_body_path[0]; - path_extrude(pts, concat([p + [0.00001, 0.0000055, 0.000008]], dragon_body_path), scale = 0.9); + path_extrude(pts, [p + [0.00001, 0.0000055, 0.000008], each dragon_body_path], scale = 0.9); translate([2.975, -0.75, -0.75]) scale(0.01825) diff --git a/examples/hollow_out/hollow_out_cylinder.scad b/examples/hollow_out/hollow_out_cylinder.scad index a270bd14..96ed5998 100644 --- a/examples/hollow_out/hollow_out_cylinder.scad +++ b/examples/hollow_out/hollow_out_cylinder.scad @@ -14,17 +14,15 @@ ys = rands(0, size[1], pt_nums); half_fn = fn / 2; dx = size[0] / fn; dy = size[1] / half_fn; -points = concat( - [ - [0, 0], [size[0], 0], - [size[0], size[1]], [0, size[1]] - ], - [for(i = [1:fn - 1]) [i * dx, 0]], - [for(i = [1:fn - 1]) [i * dx, size[1]]], - [for(i = [1:half_fn - 1]) [0, dy * i]], - [for(i = [1:half_fn - 1]) [size[0], dy * i]], - [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]] -); +points = [ + [0, 0], [size[0], 0], + [size[0], size[1]], [0, size[1]], + each [for(i = [1:fn - 1]) [i * dx, 0]], + each [for(i = [1:fn - 1]) [i * dx, size[1]]], + each [for(i = [1:half_fn - 1]) [0, dy * i]], + each [for(i = [1:half_fn - 1]) [size[0], dy * i]], + each [for(i = [0:len(xs) - 1]) [xs[i], ys[i]]] +]; bisectors = [ for(tri = tri_delaunay(points)) @@ -33,6 +31,6 @@ bisectors = [ for(line = bisectors) { pts = [for(p = line) ptf_bend(size, p, radius, 360)]; - polyline_join(concat(pts, [pts[0]])) + polyline_join([each pts, pts[0]]) sphere(d = line_diameter, $fn = 4); } \ No newline at end of file diff --git a/examples/hollow_out/hollow_out_holder.scad b/examples/hollow_out/hollow_out_holder.scad index c5b74ad6..09a0d13f 100644 --- a/examples/hollow_out/hollow_out_holder.scad +++ b/examples/hollow_out/hollow_out_holder.scad @@ -9,12 +9,10 @@ radius = 30; angle = 360; diameter = 2; -lines = concat( - hollow_out_square([columns, rows], width), - [[ - for(x = [0:width:width * columns]) [x, rows * width] - ]] -); +lines = [ + each hollow_out_square([columns, rows], width), + [for(x = [0:width:width * columns]) [x, rows * width]] +]; for(line = lines) { transformed = [for(pt = line) ptf_bend([columns * width, rows * width], pt, radius, angle)]; diff --git a/examples/hollow_out/hollow_out_starburst.scad b/examples/hollow_out/hollow_out_starburst.scad index d3552bbf..e3969d44 100644 --- a/examples/hollow_out/hollow_out_starburst.scad +++ b/examples/hollow_out/hollow_out_starburst.scad @@ -12,17 +12,17 @@ half = true; module hollow_out_starburst(r1, r2, h, n, line_diameter, half = false) { star = [for(p = shape_star(r1, r2, n)) [p[0], p[1], 0]]; leng = len(star); - tris = concat( - [for(i = [0:leng - 2]) [[0, 0, h], star[i], star[i + 1]]], - [[[0, 0, h], star[leng - 1], star[0]]] - ); + tris = [ + each [for(i = [0:leng - 2]) [[0, 0, h], star[i], star[i + 1]]], + [[0, 0, h], star[leng - 1], star[0]] + ]; module half_star() { for(tri = tris) { - polyline_join(concat(tri, [tri[0]])) + polyline_join([each tri, tri[0]]) sphere(d = line_diameter); for(line = tri_bisectors(tri)) { - polyline_join(concat(line, [line[0]])) + polyline_join([each line, line[0]]) sphere(d = line_diameter); } } diff --git a/examples/hollow_out/hollow_out_vase.scad b/examples/hollow_out/hollow_out_vase.scad index b7efef49..e67b3f64 100644 --- a/examples/hollow_out/hollow_out_vase.scad +++ b/examples/hollow_out/hollow_out_vase.scad @@ -39,10 +39,11 @@ module hollow_out_vase(ctrl_pts, t_step, line_diameter, fn, line_style) { // bottom fst_sect = sects[0]; - fst_tris = concat( - [for(i = [0:leng_sect - 2]) [[0, 0, 0], fst_sect[i], fst_sect[i + 1]]], - [[[0, 0, 0], fst_sect[leng_sect - 1], fst_sect[0]]] - ); + fst_tris = [ + each [for(i = [0:leng_sect - 2]) [[0, 0, 0], fst_sect[i], fst_sect[i + 1]]], + [[0, 0, 0], fst_sect[leng_sect - 1], fst_sect[0]] + ]; + for(tri = fst_tris) { lines = tri_bisectors(tri); for(line = lines) { @@ -55,10 +56,10 @@ module hollow_out_vase(ctrl_pts, t_step, line_diameter, fn, line_style) { // mouth lst_sect = sects[len(sects) - 1]; - lst_tris = concat( - [for(i = [0:leng_sect - 2]) [[0, 0, fpt[2]], lst_sect[i], lst_sect[i + 1]]], - [[[0, 0, fpt[2]], lst_sect[leng_sect - 1], lst_sect[0]]] - ); + lst_tris = [ + each [for(i = [0:leng_sect - 2]) [[0, 0, fpt[2]], lst_sect[i], lst_sect[i + 1]]], + [[0, 0, fpt[2]], lst_sect[leng_sect - 1], lst_sect[0]] + ]; dangling_pts = [for(tri = lst_tris) tri_bisectors(tri)[1][1]]; offset_z = [0, 0, line_diameter]; for(i = [0: leng_sect - 1]) {