Skip to content
\n

\"Screenshot

\n

However, if I change the 7s to 4s in the translations (moving them closer together), the middle cylinder vanishes:

\n
Union([\n    Rotate([0, 1, 0], -20, Translate([4, 2, 0], RoundedEndCylinder(6, 9))),\n    Rotate([0, 1, 0], -30, Translate([0, 2, 0], RoundedEndCylinder(6, 9))),\n    Rotate([0, 1, 0], -40, Translate([-4, 2, 0], RoundedEndCylinder(6, 9))),\n]);\n\nfunction RoundedEndCylinder(radius, height, centered = false) {\n    return Union([\n        Cylinder(radius, height, centered),\n        Translate([0, 0, height], Sphere(radius)),\n        Translate([0, 0, 0], Sphere(radius)),\n    ]);\n}
\n

\"Screenshot

\n

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.

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

I performed some experiments with your code. Indeed some strange things happen. Consider the following code:

\n
// input variables\nlet r = 6;      // radius of rounded cylinder\nlet h = 9;      // height of rounded cylinder\nlet d = 4;      // shift between the three cylinders\nlet t1 = 40;    // lateral shift in y-direction of shapes created directly\nlet t2 = 2;     // lateral shift in y-direction of shapes created from function\n\n// let pil = Union([\n//         Cylinder(r, h, false),\n//         Translate([0, 0, h], Sphere(r)),\n//         Translate([0, 0, 0], Sphere(r)),\n//     ]);\n\nlet pil = RoundedEndCylinder(r,h);\n\nlet pil1 = Rotate([0,1,0],-20,Translate([d,t1,0],pil,true));\nlet pil2 = Rotate([0,1,0],-30,Translate([0,t1,0],pil,true));\nlet pil3 = Rotate([0,1,0],-40,Translate([-d,t1,0],pil,false));\n\nlet pilcombination = Union([pil1,pil2,pil3]); \n\nUnion([\n    Rotate([0, 1, 0], -20, Translate([d, t2, 0], RoundedEndCylinder(6, 9))),\n    Rotate([0, 1, 0], -30, Translate([0, t2, 0], RoundedEndCylinder(6, 9))),\n    Rotate([0, 1, 0], -40, Translate([-d, t2, 0], RoundedEndCylinder(6, 9)))\n]);\n\n\nfunction RoundedEndCylinder(radius, height, centered = false) {\n    return Union([\n        Cylinder(radius, height, centered),\n        Translate([0, 0, height], Sphere(radius)),\n        Translate([0, 0, 0], Sphere(radius))\n    ]);\n}
\n

\"test-union\"

\n

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.

","upvoteCount":2,"url":"https://github.com/zalo/CascadeStudio/discussions/131#discussioncomment-2620282"}}}
Discussion options

You must be logged in to vote

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([

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DanTup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants