1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-15 11:14:17 +02:00

use [each lt, v] to replace concat(lt, [v])

This commit is contained in:
Justin Lin
2022-02-28 10:52:47 +08:00
parent 57f800f1fc
commit c9370160a7
8 changed files with 40 additions and 37 deletions

View File

@@ -23,12 +23,12 @@ module crystal_cluster(base_r, crystals) {
); );
polyhedron_hull( polyhedron_hull(
concat( [
[for(p = bottom_shape) [p.x, p.y, 0]], each [for(p = bottom_shape) [p.x, p.y, 0]],
[for(p = neck_shape) [p.x, p.y, rand(h * 0.7, h * 0.75)]], each [for(p = neck_shape) [p.x, p.y, rand(h * 0.7, h * 0.75)]],
[[rand(0, r * 0.1), rand(0, r * 0.1), rand(h * 0.8, h)]], [rand(0, r * 0.1), rand(0, r * 0.1), rand(h * 0.8, h)],
[for(i = [0:2]) if(rand(0, 1) > 0.5) [rand(0, r * 0.15), rand(0, r * 0.15), rand(h * 0.9, h * 1.05)]] each [for(i = [0:2]) if(rand(0, 1) > 0.5) [rand(0, r * 0.15), rand(0, r * 0.15), rand(h * 0.9, h * 1.05)]]
) ]
); );
} }

View File

@@ -57,20 +57,10 @@ module klein_bottle(radius1, radius2, bottom_height, thickness, t_step, fn) {
degree = 2; degree = 2;
bs_curve = bspline_curve(t_step, degree, mid_pts); bs_curve = bspline_curve(t_step, degree, mid_pts);
tube_path = [[0, 0, bottom_height], each bs_curve, [0, 0, 0]];
tube_path2 = [[0, 0, bottom_height - thickness], each bs_curve, [0, 0, -thickness]];
tube_path = concat( difference() {
[[0, 0, bottom_height]],
bs_curve,
[[0, 0, 0]]
);
tube_path2 = concat(
[[0, 0, bottom_height - thickness]],
bs_curve,
[[0, 0, -thickness]]
);
difference() {
union() { union() {
bottom(); bottom();

View File

@@ -13,7 +13,7 @@ shape_pentagram_pts = shape_pentagram(star_radius);
path_extrude( path_extrude(
shape_pentagram_pts, shape_pentagram_pts,
concat(pts, [pts[0]]), [each pts, pts[0]],
closed = true, closed = true,
method = "EULER_ANGLE" method = "EULER_ANGLE"
); );

View File

@@ -204,7 +204,20 @@ module owl(detail, head_angles) {
rotate_extrude($fn = 7) rotate_extrude($fn = 7)
polygon(pts); polygon(pts);
linear_extrude(5) linear_extrude(5)
polygon(dedup(concat(claw_path1, claw_path2, claw_path3, [[-2, -.75], [-1.45, -1.45]], claw_path4, [[1.45, -1.45], [2, -.75]]))); polygon(
dedup(
[
each claw_path1,
each claw_path2,
each claw_path3,
[-2, -.75],
[-1.45, -1.45],
each claw_path4,
[1.45, -1.45],
[2, -.75]
]
)
);
} }
} }

View File

@@ -45,7 +45,7 @@ function _packing_circles(size, min_radius, max_radius, total_circles, attempts,
i == total_circles ? circles : i == total_circles ? circles :
let(c = _packing_circles_new_circle(size, min_radius, max_radius, attempts, circles)) let(c = _packing_circles_new_circle(size, min_radius, max_radius, attempts, circles))
c == [] ? _packing_circles(size, min_radius, max_radius, total_circles, attempts, circles) : c == [] ? _packing_circles(size, min_radius, max_radius, total_circles, attempts, circles) :
_packing_circles(size, min_radius, max_radius, total_circles, attempts, concat(circles, [c]), i + 1); _packing_circles(size, min_radius, max_radius, total_circles, attempts, [each circles, c], i + 1);
function packing_circles(size, min_radius, max_radius, total_circles, attempts = 100) = function packing_circles(size, min_radius, max_radius, total_circles, attempts = 100) =
_packing_circles(is_num(size) ? [size, size] : size, min_radius, max_radius, total_circles, attempts); _packing_circles(is_num(size) ? [size, size] : size, min_radius, max_radius, total_circles, attempts);

View File

@@ -14,13 +14,10 @@ module perlin_noise_cylinder(radius, height, thickness_scale, step) {
surface_inside = [ surface_inside = [
for(y = [0:step:size[1]]) for(y = [0:step:size[1]])
concat( [
[ each [for(x = [0:step:size[0] - 1]) [x / 10, y / 10, 0]],
for(x = [0:step:size[0] - 1]) [size[0] / 10, y / 10, 0]
[x / 10, y / 10, 0] ]
],
[[size[0] / 10, y / 10, 0]]
)
]; ];
seed = rand(0, 256); seed = rand(0, 256);
@@ -29,7 +26,10 @@ module perlin_noise_cylinder(radius, height, thickness_scale, step) {
for(ri = [0:len(surface_inside) - 1]) for(ri = [0:len(surface_inside) - 1])
let( let(
row = surface_inside[ri], row = surface_inside[ri],
row_for_noise = concat(slice(row, 0, leng_row - 1), [[0, row[leng_row - 1][1], 0]]), row_for_noise = [
each slice(row, 0, leng_row - 1),
[0, row[leng_row - 1][1], 0]
],
ns = nz_perlin2s(row_for_noise, seed) ns = nz_perlin2s(row_for_noise, seed)
) )
[ [

View File

@@ -27,11 +27,11 @@ rotate([90, 0, 0])
linear_extrude(1, center = true) linear_extrude(1, center = true)
difference() { difference() {
square(120, center = true); square(120, center = true);
polyline_join(concat(shape, [shape[0]])) polyline_join([each shape, shape[0]])
circle(2.5); circle(2.5);
} }
wire = shape2wire(shape, 150); wire = shape2wire(shape, 150);
rotate(-$t * 360) rotate(-$t * 360)
polyline_join(concat(wire, [wire[0]])) polyline_join([each wire, wire[0]])
sphere(1.5); sphere(1.5);

View File

@@ -16,11 +16,11 @@ module wormhole(length, width, depth, thickness, hole_r) {
r2 = width / 4; r2 = width / 4;
half_thickness = thickness / 2; half_thickness = thickness / 2;
plane = concat( plane = [
[[length - r1, r1]], [length - r1, r1],
[for(a = [90:a_step:270]) r1 * [cos(a), sin(a)]], each [for(a = [90:a_step:270]) r1 * [cos(a), sin(a)]],
[[length - r1, -r1]] [length - r1, -r1]
); ];
difference() { difference() {
rotate([90, 0, 0]) rotate([90, 0, 0])