-
The following code produces three cylinders with spheres at their ends: Union([
Rotate([0, 1, 0], -20, Translate([7, 2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -30, Translate([0, 2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -40, Translate([-7, 2, 0], RoundedEndCylinder(6, 9))),
]);
function RoundedEndCylinder(radius, height, centered = false) {
return Union([
Cylinder(radius, height, centered),
Translate([0, 0, height], Sphere(radius)),
Translate([0, 0, 0], Sphere(radius)),
]);
} However, if I change the Union([
Rotate([0, 1, 0], -20, Translate([4, 2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -30, Translate([0, 2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -40, Translate([-4, 2, 0], RoundedEndCylinder(6, 9))),
]);
function RoundedEndCylinder(radius, height, centered = false) {
return Union([
Cylinder(radius, height, centered),
Translate([0, 0, height], Sphere(radius)),
Translate([0, 0, 0], Sphere(radius)),
]);
} I'm not sure whether this is a bug, or just a misunderstanding of something on my part. I tried disabling the cache and adjusting the resolution slider, but neither seemed to change anything. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I performed some experiments with your code. Indeed some strange things happen. Consider the following code: // input variables
let r = 6; // radius of rounded cylinder
let h = 9; // height of rounded cylinder
let d = 4; // shift between the three cylinders
let t1 = 40; // lateral shift in y-direction of shapes created directly
let t2 = 2; // lateral shift in y-direction of shapes created from function
// let pil = Union([
// Cylinder(r, h, false),
// Translate([0, 0, h], Sphere(r)),
// Translate([0, 0, 0], Sphere(r)),
// ]);
let pil = RoundedEndCylinder(r,h);
let pil1 = Rotate([0,1,0],-20,Translate([d,t1,0],pil,true));
let pil2 = Rotate([0,1,0],-30,Translate([0,t1,0],pil,true));
let pil3 = Rotate([0,1,0],-40,Translate([-d,t1,0],pil,false));
let pilcombination = Union([pil1,pil2,pil3]);
Union([
Rotate([0, 1, 0], -20, Translate([d, t2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -30, Translate([0, t2, 0], RoundedEndCylinder(6, 9))),
Rotate([0, 1, 0], -40, Translate([-d, t2, 0], RoundedEndCylinder(6, 9)))
]);
function RoundedEndCylinder(radius, height, centered = false) {
return Union([
Cylinder(radius, height, centered),
Translate([0, 0, height], Sphere(radius)),
Translate([0, 0, 0], Sphere(radius))
]);
} If you create the shape first and then perform translations, rotations and unions it all works perfectly. By using the function inside the Union strange things seem to happen. Originally I thought that it might have something to do with overlapping faces in the Union. But if you change the lateral displacement of your trio of RoundedCylinders (change t2 in the code above to 20) the same strange things happen although the relative position between the three shapes is not changed. So I would say it is a bug. |
Beta Was this translation helpful? Give feedback.
I performed some experiments with your code. Indeed some strange things happen. Consider the following code: