discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fillet With Internal Angles

N
nophead
Fri, Apr 29, 2016 7:21 AM

When you compose the cones together the resulting shape is concave, so it
will do a single slow minkowski. When you do each cone separately they are
convex, so if the profile is convex, it will do the fast minkowski, but lots
of them.

In the concave case it probably has to decompose the shapes into convex
parts, so perhaps it breaks the cones apart again and does effective what my
version did.

The reason preview is slow is because OpenCSG can't do minkowski or hull so
those are done with CGAL even during F5.

--
View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

When you compose the cones together the resulting shape is concave, so it will do a single slow minkowski. When you do each cone separately they are convex, so if the profile is convex, it will do the fast minkowski, but lots of them. In the concave case it probably has to decompose the shapes into convex parts, so perhaps it breaks the cones apart again and does effective what my version did. The reason preview is slow is because OpenCSG can't do minkowski or hull so those are done with CGAL even during F5. -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Fri, Apr 29, 2016 7:36 AM

Clear and sound. Thanks.

2016-04-29 4:21 GMT-03:00 nophead nop.head@gmail.com:

When you compose the cones together the resulting shape is concave, so it
will do a single slow minkowski. When you do each cone separately they are
convex, so if the profile is convex, it will do the fast minkowski, but
lots
of them.

In the concave case it probably has to decompose the shapes into convex
parts, so perhaps it breaks the cones apart again and does effective what
my
version did.

The reason preview is slow is because OpenCSG can't do minkowski or hull so
those are done with CGAL even during F5.

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Clear and sound. Thanks. 2016-04-29 4:21 GMT-03:00 nophead <nop.head@gmail.com>: > When you compose the cones together the resulting shape is concave, so it > will do a single slow minkowski. When you do each cone separately they are > convex, so if the profile is convex, it will do the fast minkowski, but > lots > of them. > > In the concave case it probably has to decompose the shapes into convex > parts, so perhaps it breaks the cones apart again and does effective what > my > version did. > > The reason preview is slow is because OpenCSG can't do minkowski or hull so > those are done with CGAL even during F5. > > > > > > -- > View this message in context: > http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Fri, Apr 29, 2016 7:47 AM

I am using version 2015.05.16 (git e673fff).

The cylinder takes 14 or 15 seconds. Both shapes together takes 1m11. I
can't explain why you get a big difference between methods and I get none.
Perhaps you have an older version of OpenScad.

On 29 April 2016 at 08:36, Ronaldo Persiano rcmpersiano@gmail.com wrote:

Clear and sound. Thanks.

2016-04-29 4:21 GMT-03:00 nophead nop.head@gmail.com:

When you compose the cones together the resulting shape is concave, so it
will do a single slow minkowski. When you do each cone separately they are
convex, so if the profile is convex, it will do the fast minkowski, but
lots
of them.

In the concave case it probably has to decompose the shapes into convex
parts, so perhaps it breaks the cones apart again and does effective what
my
version did.

The reason preview is slow is because OpenCSG can't do minkowski or hull
so
those are done with CGAL even during F5.

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I am using version 2015.05.16 (git e673fff). The cylinder takes 14 or 15 seconds. Both shapes together takes 1m11. I can't explain why you get a big difference between methods and I get none. Perhaps you have an older version of OpenScad. On 29 April 2016 at 08:36, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > Clear and sound. Thanks. > > 2016-04-29 4:21 GMT-03:00 nophead <nop.head@gmail.com>: > >> When you compose the cones together the resulting shape is concave, so it >> will do a single slow minkowski. When you do each cone separately they are >> convex, so if the profile is convex, it will do the fast minkowski, but >> lots >> of them. >> >> In the concave case it probably has to decompose the shapes into convex >> parts, so perhaps it breaks the cones apart again and does effective what >> my >> version did. >> >> The reason preview is slow is because OpenCSG can't do minkowski or hull >> so >> those are done with CGAL even during F5. >> >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17225.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
T
Trygon
Fri, Apr 29, 2016 9:38 AM

Nophead & Ronaldo, interesting discussion thanks.

I had pondered the same idea as you Ronaldo (code below), but it is still
slower than your version Nophead - i.e. very, very slow!  The only possible
advantage is that a 2D profile can easily be constructed with a boolean
combination of circles and squares to generate an arbitrary fillet shape.

-Trygon

http://forum.openscad.org/file/n17231/BlendFilletExtrude_test01.png

n=5; // number of steps in fillet
r=2; // fillet radius
h=8; // overall extrusion height

translate([-10,-10,-2]) cube([40,40,2]); //plate

BlendFilletExtrude(h,r,$fn=n*4) TestShape();

module TestShape(s=20,r=3,$fn=20){
FilletPolygon(r) difference(){
square(s);
translate([s/2,s/2]) square(s);
}
}

module FilletPolygon(r=2,internal=true,external=true){
if(internal && external){
offset(r=-r) offset(delta=r) offset(r=r) offset(delta=-r)
children();
} else if (external){
offset(r=r) offset(delta=-r) children();
} else if(internal){
offset(r=-r) offset(delta=r) children();
}else{
children();
}
}

// h        height of extrusion (from z=0)
// r        radius of fillet
// padding  distance fillet is extended below plane z=0
module BlendFilletExtrude(h=10,r=2,padding=0.1){
eps=0.001;
linear_extrude(height=h) children();
minkowski(){
rotate_extrude() difference(){
translate([0,-padding]) square([r,r+padding]);
translate([r,r])circle(r);
}
linear_extrude(height=eps) children();
}
}

--
View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17231.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Nophead & Ronaldo, interesting discussion thanks. I had pondered the same idea as you Ronaldo (code below), but it is still slower than your version Nophead - i.e. very, very slow! The only possible advantage is that a 2D profile can easily be constructed with a boolean combination of circles and squares to generate an arbitrary fillet shape. -Trygon <http://forum.openscad.org/file/n17231/BlendFilletExtrude_test01.png> n=5; // number of steps in fillet r=2; // fillet radius h=8; // overall extrusion height translate([-10,-10,-2]) cube([40,40,2]); //plate BlendFilletExtrude(h,r,$fn=n*4) TestShape(); module TestShape(s=20,r=3,$fn=20){ FilletPolygon(r) difference(){ square(s); translate([s/2,s/2]) square(s); } } module FilletPolygon(r=2,internal=true,external=true){ if(internal && external){ offset(r=-r) offset(delta=r) offset(r=r) offset(delta=-r) children(); } else if (external){ offset(r=r) offset(delta=-r) children(); } else if(internal){ offset(r=-r) offset(delta=r) children(); }else{ children(); } } // h height of extrusion (from z=0) // r radius of fillet // padding distance fillet is extended below plane z=0 module BlendFilletExtrude(h=10,r=2,padding=0.1){ eps=0.001; linear_extrude(height=h) children(); minkowski(){ rotate_extrude() difference(){ translate([0,-padding]) square([r,r+padding]); translate([r,r])circle(r); } linear_extrude(height=eps) children(); } } -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17231.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Tue, Oct 25, 2016 11:59 PM

The clever nophead's code to produce fillets from 2D shapes is restricted to
extrusions that are orthogonal to the base plane. I have faced the problem
to fillet a cylinder that makes an angle of 45 degrees to its base. A proper
modification of nophead's code allows it to handle such more general cases.

http://forum.openscad.org/file/n18807/fillets.png

RADS = 2.5; // Radius of the fillet
fn=24;      // control the fillet step size

union() {
// base
translate([-30,-30,0])
cube([60,60,5]);
// cylinder
angs = [45,0,0];
translate([12,12,5]) {
ninteyDegFillet(RADS,angs=angs,$fn=24)
circle(10,$fn=fn);
rotate(angs)
translate([0,0,-10.4])
cylinder(r=10,h=30,$fn=fn);
}
// generic shape
angs2 = [-20,0,30];
translate([-20,-20,5]){
ninteyDegFillet(RADS,angs2,$fn=24)
a_profile();
rotate(angs2)
translate([0,0,-10])
linear_extrude(30)
a_profile($fn=fn);
}
}

module a_profile(){
difference() {
square(15);
translate([12,3])
circle(5);
}
}

module ninteyDegFillet(r,angs=[0,0,0]) {
/*
r - fllet radius
$fn/4 - number of steps
/
function rad(x) = r - sqrt(pow(r,2) - pow(x - r, 2));
st  = r
4/$fn;  // step size
eps = 0.001;    // a little overlap between slices
a  = angs[0];
s  = sin(angs[2]);
c  = cos(angs[2]);
if (abs(cos(a))>0.05) {// avoid shallow angles to horizontal
rot = [[c,-s,0],[s,c,0],[0,0,1]];
m  = rot*[[1,0,0],[0,1/cos(a),-tan(a)],[0,0,1]];
multmatrix(m)
for(i = [0 : st : r - st])
translate([0,0, i])
minkowski() {
linear_extrude(height = eps)
children();
cylinder(r1=rad(i), r2=rad(i+st), h=st, $fn=fn);
}
}
}

The trick to get it done was to skew the fillet and rotate it. Note that
ninteyDegFillet() (what that name means after all?) now receives a list of
angles angs, the same list that is passed to rotate the extrusion. However,
the code considers only the x and z rotations which is enough for all cases.
Also, the fillet refinement is now controlled by $fn.

Interestingly, the hard and lengthy work of minkowski does depends only on
the shape and the refinement. After the first run, you may change the angles
and the preview is immediate.

--
View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p18807.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The clever nophead's code to produce fillets from 2D shapes is restricted to extrusions that are orthogonal to the base plane. I have faced the problem to fillet a cylinder that makes an angle of 45 degrees to its base. A proper modification of nophead's code allows it to handle such more general cases. <http://forum.openscad.org/file/n18807/fillets.png> > RADS = 2.5; // Radius of the fillet > fn=24; // control the fillet step size > > union() { > // base > translate([-30,-30,0]) > cube([60,60,5]); > // cylinder > angs = [45,0,0]; > translate([12,12,5]) { > ninteyDegFillet(RADS,angs=angs,$fn=24) > circle(10,$fn=fn); > rotate(angs) > translate([0,0,-10.4]) > cylinder(r=10,h=30,$fn=fn); > } > // generic shape > angs2 = [-20,0,30]; > translate([-20,-20,5]){ > ninteyDegFillet(RADS,angs2,$fn=24) > a_profile(); > rotate(angs2) > translate([0,0,-10]) > linear_extrude(30) > a_profile($fn=fn); > } > } > > module a_profile(){ > difference() { > square(15); > translate([12,3]) > circle(5); > } > } > > module ninteyDegFillet(r,angs=[0,0,0]) { > /* > r - fllet radius > $fn/4 - number of steps > */ > function rad(x) = r - sqrt(pow(r,2) - pow(x - r, 2)); > st = r*4/$fn; // step size > eps = 0.001; // a little overlap between slices > a = angs[0]; > s = sin(angs[2]); > c = cos(angs[2]); > if (abs(cos(a))>0.05) {// avoid shallow angles to horizontal > rot = [[c,-s,0],[s,c,0],[0,0,1]]; > m = rot*[[1,0,0],[0,1/cos(a),-tan(a)],[0,0,1]]; > multmatrix(m) > for(i = [0 : st : r - st]) > translate([0,0, i]) > minkowski() { > linear_extrude(height = eps) > children(); > cylinder(r1=rad(i), r2=rad(i+st), h=st, $fn=fn); > } > } > } The trick to get it done was to skew the fillet and rotate it. Note that ninteyDegFillet() (what that name means after all?) now receives a list of angles angs, the same list that is passed to rotate the extrusion. However, the code considers only the x and z rotations which is enough for all cases. Also, the fillet refinement is now controlled by $fn. Interestingly, the hard and lengthy work of minkowski does depends only on the shape and the refinement. After the first run, you may change the angles and the preview is immediate. -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p18807.html Sent from the OpenSCAD mailing list archive at Nabble.com.