mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 01:04:07 +02:00
use [each lt, v] to replace concat(lt, [v])
This commit is contained in:
@@ -20,32 +20,29 @@ Drive a turtle with `["forward", length]` or `["turn", angle]`. This function is
|
||||
ta = fa / 2,
|
||||
leng = sin(ta) * radius * 2
|
||||
)
|
||||
concat(
|
||||
[["turn", ta]],
|
||||
[
|
||||
[
|
||||
["turn", ta],
|
||||
each [
|
||||
for(i = [0:steps - 2])
|
||||
each [["forward", leng], ["turn", fa]]
|
||||
],
|
||||
[["forward", leng], ["turn", ta]]
|
||||
);
|
||||
["forward", leng],
|
||||
["turn", ta]
|
||||
];
|
||||
|
||||
poly = footprints2(
|
||||
concat(
|
||||
[
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10]
|
||||
],
|
||||
arc_cmds(5, 180, 12),
|
||||
[
|
||||
["turn", -90],
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10]
|
||||
]
|
||||
)
|
||||
[
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10],
|
||||
each arc_cmds(5, 180, 12),
|
||||
["turn", -90],
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10]
|
||||
]
|
||||
);
|
||||
|
||||
polyline_join(poly)
|
||||
|
@@ -20,33 +20,28 @@ A 3D verion of [footprint2](https://openhome.cc/eGossip/OpenSCAD/lib3x-footprint
|
||||
ta = fa / 2,
|
||||
leng = sin(ta) * radius * 2
|
||||
)
|
||||
concat(
|
||||
[["turn", ta]],
|
||||
[
|
||||
[
|
||||
["turn", ta],
|
||||
each [
|
||||
for(i = [0:steps - 2])
|
||||
each [["forward", leng], ["turn", fa]]
|
||||
],
|
||||
[["forward", leng], ["turn", ta]]
|
||||
);
|
||||
["forward", leng],
|
||||
["turn", ta]
|
||||
];
|
||||
|
||||
poly = footprints3(
|
||||
concat(
|
||||
[
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10]
|
||||
],
|
||||
xy_arc_cmds(5, 180, 12),
|
||||
[
|
||||
["pitch", 90],
|
||||
["forward", 10],
|
||||
["roll", 90]
|
||||
],
|
||||
xy_arc_cmds(5, 180, 12),
|
||||
[
|
||||
["forward", 10]
|
||||
]
|
||||
)
|
||||
[
|
||||
["forward", 10],
|
||||
["turn", 90],
|
||||
["forward", 10],
|
||||
each xy_arc_cmds(5, 180, 12),
|
||||
["pitch", 90],
|
||||
["forward", 10],
|
||||
["roll", 90],
|
||||
each xy_arc_cmds(5, 180, 12),
|
||||
["forward", 10]
|
||||
]
|
||||
);
|
||||
|
||||
polyline_join(poly)
|
||||
|
@@ -54,7 +54,7 @@ Want to simulate class-based OO in OpenSCAD? Here's my experiment.
|
||||
function clz_list(data) = function(name) _(name,
|
||||
methods([
|
||||
["get", function(i) data[i]],
|
||||
["append", function(n) clz_list(concat(data, [n]))]
|
||||
["append", function(n) clz_list([each data, n])]
|
||||
])
|
||||
);
|
||||
|
||||
|
@@ -257,7 +257,7 @@ So, which is the correct method? Both methods are correct when you provide only
|
||||
// not closed perfectly
|
||||
translate([-8, 0, 0]) path_extrude(
|
||||
shape_pentagram_pts,
|
||||
concat(pts, [pts[0]]),
|
||||
[each pts, pts[0]],
|
||||
closed = true,
|
||||
method = "AXIS_ANGLE"
|
||||
);
|
||||
@@ -265,7 +265,7 @@ So, which is the correct method? Both methods are correct when you provide only
|
||||
// adjust it
|
||||
path_extrude(
|
||||
shape_pentagram_pts,
|
||||
concat(pts, [pts[0]]),
|
||||
[each pts, pts[0]],
|
||||
closed = true,
|
||||
twist = 188,
|
||||
method = "AXIS_ANGLE"
|
||||
@@ -274,7 +274,7 @@ So, which is the correct method? Both methods are correct when you provide only
|
||||
// "EULER_ANGLE" is easy in this situation
|
||||
translate([0, 8, 0]) path_extrude(
|
||||
shape_pentagram_pts,
|
||||
concat(pts, [pts[0]]),
|
||||
[each pts, pts[0]],
|
||||
closed = true,
|
||||
method = "EULER_ANGLE"
|
||||
);
|
||||
|
@@ -29,7 +29,7 @@ Generate a path of [The (p,q)-torus knot](https://en.wikipedia.org/wiki/Torus_kn
|
||||
|
||||
path_extrude(
|
||||
shape_pentagram_pts,
|
||||
concat(pts, [pts[0]]),
|
||||
[each pts, pts[0]],
|
||||
closed = true,
|
||||
method = "EULER_ANGLE"
|
||||
);
|
||||
|
@@ -32,7 +32,7 @@ Join a set of points to make a [Delaunay triangulation](https://en.wikipedia.org
|
||||
color("red")
|
||||
linear_extrude(3)
|
||||
for(t = tri_delaunay(points, ret = "VORONOI_CELLS")) {
|
||||
polyline_join(concat(t, [t[0]]))
|
||||
polyline_join([each t, t[0]])
|
||||
circle(1);
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns the indices from
|
||||
color("red")
|
||||
linear_extrude(3)
|
||||
for(t = tri_delaunay_voronoi(delaunay)) {
|
||||
polyline_join(concat(t, [t[0]]))
|
||||
polyline_join([each t, t[0]])
|
||||
circle(1);
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns triangle shapes f
|
||||
color("red")
|
||||
linear_extrude(3)
|
||||
for(t = tri_delaunay_voronoi(delaunay)) {
|
||||
polyline_join(concat(t, [t[0]]))
|
||||
polyline_join([each t, t[0]])
|
||||
circle(1);
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns voronoi cells fro
|
||||
color("red")
|
||||
linear_extrude(3)
|
||||
for(t = tri_delaunay_voronoi(delaunay)) {
|
||||
polyline_join(concat(t, [t[0]]))
|
||||
polyline_join([each t, t[0]])
|
||||
circle(1);
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ Create cell shapes of Voronoi from a list of points.
|
||||
cell = cells[i];
|
||||
|
||||
linear_extrude(1)
|
||||
polyline_join(concat(cell, [cell[0]]))
|
||||
polyline_join([each cell, cell[0]])
|
||||
circle(.5);
|
||||
|
||||
color(rands(0, 1, 3))
|
||||
|
@@ -24,7 +24,7 @@ Create cell shapes of Voronoi in the first quadrant. You specify a space and a g
|
||||
cell_poly = cell[1];
|
||||
|
||||
linear_extrude(1)
|
||||
polyline_join(concat(cell_poly, [cell_poly[0]]))
|
||||
polyline_join([each cell_poly, cell_poly[0]])
|
||||
circle(.5);
|
||||
|
||||
color(rands(0, 1, 3))
|
||||
|
@@ -18,7 +18,7 @@ Given a list of points. `vx_polyline` returns points that can be used to draw a
|
||||
[round(pt.x), round(pt.y)]
|
||||
];
|
||||
|
||||
for(pt = vx_polyline(concat(pentagram, [pentagram[0]]))) {
|
||||
for(pt = vx_polyline([each pentagram, pentagram[0]])) {
|
||||
translate(pt)
|
||||
linear_extrude(1, scale = 0.5)
|
||||
square(1, center = true);
|
||||
|
Reference in New Issue
Block a user