mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Corrected processing of $fn for round_corners, added two examples
to skin (from list comp demos) and added another error check to zip.
This commit is contained in:
parent
78197e1909
commit
c0d18ab0b1
3 changed files with 34 additions and 8 deletions
|
@ -847,17 +847,16 @@ function triplet_wrap(v) =
|
|||
function zip(vecs, v2, v3, fit=false, fill=undef) =
|
||||
(v3!=undef)? zip([vecs,v2,v3], fit=fit, fill=fill) :
|
||||
(v2!=undef)? zip([vecs,v2], fit=fit, fill=fill) :
|
||||
assert(in_list(fit, [false, "short", "long"]))
|
||||
assert(all( [for(v=vecs) is_list(v)]), "One of the inputs to zip is not a vector")
|
||||
let(
|
||||
dummy1 = assert(in_list(fit, [false, "short", "long"])),
|
||||
minlen = list_shortest(vecs),
|
||||
maxlen = list_longest(vecs),
|
||||
dummy2 = (fit==false)? assert(minlen==maxlen, "Input vectors must have the same length") : 0
|
||||
dummy = (fit==false)? assert(minlen==maxlen, "Input vectors to zip must have the same length") : 0
|
||||
) (fit == "long")?
|
||||
[for(i=[0:1:maxlen-1]) [for(v=vecs) for(x=(i<len(v)? v[i] : (fill==undef)? [fill] : fill)) x] ] :
|
||||
[for(i=[0:1:minlen-1]) [for(v=vecs) for(x=v[i]) x] ];
|
||||
|
||||
|
||||
|
||||
// Function: array_group()
|
||||
// Description:
|
||||
// Takes a flat array of values, and groups items in sets of `cnt` length.
|
||||
|
|
|
@ -327,6 +327,7 @@ function _bezcorner(points, parm) =
|
|||
function _circlecorner(points, parm) =
|
||||
let(
|
||||
angle = vector_angle(points)/2,
|
||||
df=echo(angle=angle),
|
||||
d = parm[0],
|
||||
r = parm[1],
|
||||
prev = normalize(points[0]-points[1]),
|
||||
|
@ -335,7 +336,7 @@ function _circlecorner(points, parm) =
|
|||
start = points[1]+prev*d,
|
||||
end = points[1]+next*d
|
||||
)
|
||||
arc(segs(norm(start-center)), cp=center, points=[start,end]);
|
||||
arc(max(3,angle/180*segs(norm(start-center))), cp=center, points=[start,end]);
|
||||
|
||||
|
||||
// Module: offset_sweep()
|
||||
|
|
32
skin.scad
32
skin.scad
|
@ -40,9 +40,9 @@ include <vnf.scad>
|
|||
// matching = Specifies the algorithm used to match up vertices between profiles, to create faces. Given as a string, one of `"distance"`, `"angle"`, or `"evenly"`. If given as a list of strings, equal in number to the number of profile transitions, lets you specify the algorithm used for each transition. Default: "distance"
|
||||
// Example(FlatSpin):
|
||||
// skin([
|
||||
// move([0,0, 0], p=scale([2,1,1], p=path3d(circle(d=100,$fn=48)))),
|
||||
// move([0,0,100], p=path3d(circle(d=100,$fn=4))),
|
||||
// move([0,0,200], p=path3d(circle(d=100,$fn=12))),
|
||||
// scale([2,1,1], p=path3d(circle(d=100,$fn=48))),
|
||||
// path3d(circle(d=100,$fn=4),100),
|
||||
// path3d(circle(d=100,$fn=12),200),
|
||||
// ]);
|
||||
// Example(FlatSpin):
|
||||
// skin([
|
||||
|
@ -74,6 +74,32 @@ include <vnf.scad>
|
|||
// move([0,0, 0], p=scale([1,2,1],p=path3d(circle(d=50,$fn=36)))),
|
||||
// move([0,0,100], p=scale([2,1,1],p=path3d(circle(d=50,$fn=36))))
|
||||
// ], matching="evenly");
|
||||
// Example:
|
||||
// fn=32;
|
||||
// base = round_corners(square([2,4],center=true), measure="radius", size=0.5, $fn=fn);
|
||||
// skin([
|
||||
// path3d(base,0),
|
||||
// path3d(base,2),
|
||||
// path3d(circle($fn=fn,r=0.5),3),
|
||||
// path3d(circle($fn=fn,r=0.5),4),
|
||||
// path3d(circle($fn=fn,r=0.6),4),
|
||||
// path3d(circle($fn=fn,r=0.5),5),
|
||||
// path3d(circle($fn=fn,r=0.6),5),
|
||||
// path3d(circle($fn=fn,r=0.5),6),
|
||||
// path3d(circle($fn=fn,r=0.6),6),
|
||||
// path3d(circle($fn=fn,r=0.5),7),
|
||||
// ],matching="evenly");
|
||||
// Example: Forma Candle Holder
|
||||
// r = 50;
|
||||
// height = 140;
|
||||
// layers = 10;
|
||||
// wallthickness = 5;
|
||||
// holeradius = r - wallthickness;
|
||||
// difference() {
|
||||
// skin([for (i=[0:layers-1])
|
||||
// zrot(-30*i,p=path3d(hexagon(ir=r),i*height/layers))]);
|
||||
// up(height/layers) cylinder(r=holeradius, h=height);
|
||||
// }
|
||||
// Example: Beware Self-intersecting Creases!
|
||||
// skin([
|
||||
// for (a = [0:30:180]) let(
|
||||
|
|
Loading…
Reference in a new issue