discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fillet With Internal Angles

M
marno11
Wed, Apr 27, 2016 6:07 AM

Hi All,

I'm trying to create an instruction to use an arbitrary 2D polygon to create
a fillet. It works fairly well when there are no internal angles, but I do
need it to handle internal angles.

If you take a look at the following, it should give an idea what I'm trying
to do and how:


STPS = 10;      //Number of steps to do the fillet over
RADS = 5;      //Radius of the fillet

union() {
translate([-30,-30,0])
cube([60,60,5]);

//This works fine
translate([12,12,5]) {
    ninteyDegFillet(RADS,STPS)
        circle(10);
    translate([0,0,RADS])
        linear_extrude(5)
            circle(10);
}

//This doesn't work quite like I hope (when I have hull turned on in the

fillet module)
translate([-20,-20,5]){
ninteyDegFillet(RADS,STPS)
a_profile();
translate([0,0,RADS])
linear_extrude(5)
a_profile();
}
}

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

module ninteyDegFillet(r,n) {
/*
r - fllet radius
n - number of steps
*/
s = r/n;                    //step size
for(i = [0:s:r]) {
difference() {
//hull() {
translate([0,0,i-s])
linear_extrude(height = s)
offset(r = r-sqrt(pow(r,2) - pow((i-r),2)))
children(0);
translate([0,0,i])
linear_extrude(height = s)
offset(r = r-sqrt(pow(r,2) - pow((i+s-r),2)))
children(0);
}
translate([0,0,-s])
linear_extrude(height = s)
offset(r = r-sqrt(pow(r,2) - pow((-r),2)))
children(0);
//}
}
}


I wanted to use the hull() to smooth things out, but perhaps there's a
better way to do this.

The parameters I would like to be able to do this within is by specifying a
2D profile and a radius.

on another note, is there a way to define 2, 2D profiles offset in some
direction and have them create a top and bottom to a 3D polygon?

Cheers,
Marno

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

Hi All, I'm trying to create an instruction to use an arbitrary 2D polygon to create a fillet. It works fairly well when there are no internal angles, but I do need it to handle internal angles. If you take a look at the following, it should give an idea what I'm trying to do and how: ---------------------------------------------------------------- STPS = 10; //Number of steps to do the fillet over RADS = 5; //Radius of the fillet union() { translate([-30,-30,0]) cube([60,60,5]); //This works fine translate([12,12,5]) { ninteyDegFillet(RADS,STPS) circle(10); translate([0,0,RADS]) linear_extrude(5) circle(10); } //This doesn't work quite like I hope (when I have hull turned on in the fillet module) translate([-20,-20,5]){ ninteyDegFillet(RADS,STPS) a_profile(); translate([0,0,RADS]) linear_extrude(5) a_profile(); } } module a_profile(){ difference() { square(15); translate([3,3,0]) circle(5); } } module ninteyDegFillet(r,n) { /* r - fllet radius n - number of steps */ s = r/n; //step size for(i = [0:s:r]) { difference() { //hull() { translate([0,0,i-s]) linear_extrude(height = s) offset(r = r-sqrt(pow(r,2) - pow((i-r),2))) children(0); translate([0,0,i]) linear_extrude(height = s) offset(r = r-sqrt(pow(r,2) - pow((i+s-r),2))) children(0); } translate([0,0,-s]) linear_extrude(height = s) offset(r = r-sqrt(pow(r,2) - pow((-r),2))) children(0); //} } } ---------------------------------------------------------------- I wanted to use the hull() to smooth things out, but perhaps there's a better way to do this. The parameters I would like to be able to do this within is by specifying a 2D profile and a radius. on another note, is there a way to define 2, 2D profiles offset in some direction and have them create a top and bottom to a 3D polygon? Cheers, Marno -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201.html Sent from the OpenSCAD mailing list archive at Nabble.com.
T
Trygon
Wed, Apr 27, 2016 7:27 AM

Hi Marno,

This might help:

$fn=40;
points=[[0,0],[20,0],[20,10],[10,10],[10,20],[0,20]];
polygon(points);
translate([30,0,0]) offset(r=3) offset(delta=-3) polygon(points);
translate([0,30,0]) offset(r=-3) offset(delta=3) polygon(points);
translate([30,30,0]) offset(r=-3) offset(delta=3)
offset(r=3) offset(delta=-3) polygon(points);

Cheers,
Trygon

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

Hi Marno, This might help: $fn=40; points=[[0,0],[20,0],[20,10],[10,10],[10,20],[0,20]]; polygon(points); translate([30,0,0]) offset(r=3) offset(delta=-3) polygon(points); translate([0,30,0]) offset(r=-3) offset(delta=3) polygon(points); translate([30,30,0]) offset(r=-3) offset(delta=3) offset(r=3) offset(delta=-3) polygon(points); Cheers, Trygon -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17203.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Wed, Apr 27, 2016 7:45 AM

I think this does what you want but is very slow.

module ninteyDegFillet(r,n) {
/*
r - fllet radius
n - number of steps
*/
function rad(x) = r - sqrt(pow(r,2) - pow(x - r, 2));
s = r/n;            //step size
eps = 0.001;        // a little overlap between slices
for(i = [0 : s : r - s]) {
translate([0, 0, i])
minkowski() {
linear_extrude(height = eps)
children();
cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32);
}
}
}

I think interpolating between two 2D shapes to make a 3D shape is known as
loft. It would be nice to have one in OpenScad.

On 27 April 2016 at 08:27, Trygon db5765@outlook.com wrote:

Hi Marno,

This might help:

$fn=40;
points=[[0,0],[20,0],[20,10],[10,10],[10,20],[0,20]];
polygon(points);
translate([30,0,0]) offset(r=3) offset(delta=-3) polygon(points);
translate([0,30,0]) offset(r=-3) offset(delta=3) polygon(points);
translate([30,30,0]) offset(r=-3) offset(delta=3)
offset(r=3) offset(delta=-3) polygon(points);

Cheers,
Trygon

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17203.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 think this does what you want but is very slow. module ninteyDegFillet(r,n) { /* r - fllet radius n - number of steps */ function rad(x) = r - sqrt(pow(r,2) - pow(x - r, 2)); s = r/n; //step size eps = 0.001; // a little overlap between slices for(i = [0 : s : r - s]) { translate([0, 0, i]) minkowski() { linear_extrude(height = eps) children(); cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32); } } } I think interpolating between two 2D shapes to make a 3D shape is known as loft. It would be nice to have one in OpenScad. ​ On 27 April 2016 at 08:27, Trygon <db5765@outlook.com> wrote: > Hi Marno, > > This might help: > > $fn=40; > points=[[0,0],[20,0],[20,10],[10,10],[10,20],[0,20]]; > polygon(points); > translate([30,0,0]) offset(r=3) offset(delta=-3) polygon(points); > translate([0,30,0]) offset(r=-3) offset(delta=3) polygon(points); > translate([30,30,0]) offset(r=-3) offset(delta=3) > offset(r=3) offset(delta=-3) polygon(points); > > > Cheers, > Trygon > > > > -- > View this message in context: > http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17203.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 >
T
Trygon
Wed, Apr 27, 2016 8:28 AM

Very nice, Nophead.

I guess this could also be accomplished using skin.scad in the
list-comprehension demos:

https://github.com/openscad/list-comprehension-demos

That should be a bit quicker.

-Trygon

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

Very nice, Nophead. I guess this could also be accomplished using skin.scad in the list-comprehension demos: https://github.com/openscad/list-comprehension-demos That should be a bit quicker. -Trygon -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17205.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Wed, Apr 27, 2016 8:40 AM

Yes but that requires a numerical definition of the profile as a polygon or
a way to convert a 2D shape to a vertex list. If you make your 2D profile
with boolean combinations of circles and squares you need loft which would
take arbitrary 2D shapes like linear extrude.

On 27 April 2016 at 09:28, Trygon db5765@outlook.com wrote:

Very nice, Nophead.

I guess this could also be accomplished using skin.scad in the
list-comprehension demos:

https://github.com/openscad/list-comprehension-demos

That should be a bit quicker.

-Trygon

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17205.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

Yes but that requires a numerical definition of the profile as a polygon or a way to convert a 2D shape to a vertex list. If you make your 2D profile with boolean combinations of circles and squares you need loft which would take arbitrary 2D shapes like linear extrude. On 27 April 2016 at 09:28, Trygon <db5765@outlook.com> wrote: > Very nice, Nophead. > > I guess this could also be accomplished using skin.scad in the > list-comprehension demos: > > https://github.com/openscad/list-comprehension-demos > > That should be a bit quicker. > > -Trygon > > > > -- > View this message in context: > http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17205.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 >
M
marno11
Wed, Apr 27, 2016 1:37 PM

Thanks Nophead,

Very cool; so you are using minkowski to run a truncated cone around a
sliver of each 'profile step'.

I did want to try do this without using minkowski - but unless I or someone
can think of an alternative way (that works well) this is how I'll do it.

-Marno

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

Thanks Nophead, Very cool; so you are using minkowski to run a truncated cone around a sliver of each 'profile step'. I did want to try do this without using minkowski - but unless I or someone can think of an alternative way (that works well) this is how I'll do it. -Marno -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17210.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Wed, Apr 27, 2016 2:04 PM

Yes 3D minkowski is very slow, but only when the shape is concave. When it
is convex is is probably as fast as hull because I think later versions of
OpenScad shortcut it to a hull.

On 27 April 2016 at 14:37, marno11 jordan.marano11@gmail.com wrote:

Thanks Nophead,

Very cool; so you are using minkowski to run a truncated cone around a
sliver of each 'profile step'.

I did want to try do this without using minkowski - but unless I or someone
can think of an alternative way (that works well) this is how I'll do it.

-Marno

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17210.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

Yes 3D minkowski is very slow, but only when the shape is concave. When it is convex is is probably as fast as hull because I think later versions of OpenScad shortcut it to a hull. On 27 April 2016 at 14:37, marno11 <jordan.marano11@gmail.com> wrote: > Thanks Nophead, > > Very cool; so you are using minkowski to run a truncated cone around a > sliver of each 'profile step'. > > I did want to try do this without using minkowski - but unless I or someone > can think of an alternative way (that works well) this is how I'll do it. > > -Marno > > > > -- > View this message in context: > http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17210.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 >
R
Ronaldo
Thu, Apr 28, 2016 10:18 PM

Very nice solution, nophead! I have worked a little on it and tried a
factorization of the Minkowski operation expecting a better performance:

module ninteyDegFillet2(r,n) {
/*
r - fllet radius
n - number of steps
*/
function rad(x) = 10 - sqrt(pow(10,2) - pow(x - 10, 2));
s = r/n;            //step size
eps = 0.001;        // a small thickness of children()
minkowski() {
linear_extrude(height = eps)
children();
for(i = [0 : s : r - s]) {
translate([0, 0, i])
cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32);
}
}
}

For my surprise, ninteyDegFillet2 spent 34 sec to render while
ninteyDegFillet took just 14sec. Have you an explanation for this?

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

Very nice solution, nophead! I have worked a little on it and tried a factorization of the Minkowski operation expecting a better performance: > module ninteyDegFillet2(r,n) { > /* > r - fllet radius > n - number of steps > */ > function rad(x) = 10 - sqrt(pow(10,2) - pow(x - 10, 2)); > s = r/n; //step size > eps = 0.001; // a small thickness of children() > minkowski() { > linear_extrude(height = eps) > children(); > for(i = [0 : s : r - s]) { > translate([0, 0, i]) > cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32); > } > } > } For my surprise, ninteyDegFillet2 spent 34 sec to render while ninteyDegFillet took just 14sec. Have you an explanation for this? -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17221.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Thu, Apr 28, 2016 10:42 PM

You seem to have replaced r with 10 in rad(). When I put it back to r they
both take roughly the same amount of time.

On 28 April 2016 at 23:18, Ronaldo rcmpersiano@gmail.com wrote:

Very nice solution, nophead! I have worked a little on it and tried a
factorization of the Minkowski operation expecting a better performance:

module ninteyDegFillet2(r,n) {
/*
r - fllet radius
n - number of steps
*/
function rad(x) = 10 - sqrt(pow(10,2) - pow(x - 10, 2));
s = r/n;            //step size
eps = 0.001;        // a small thickness of children()
minkowski() {
linear_extrude(height = eps)
children();
for(i = [0 : s : r - s]) {
translate([0, 0, i])
cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32);
}
}
}

For my surprise, ninteyDegFillet2 spent 34 sec to render while
ninteyDegFillet took just 14sec. Have you an explanation for this?

--
View this message in context:
http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17221.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

You seem to have replaced r with 10 in rad(). When I put it back to r they both take roughly the same amount of time. On 28 April 2016 at 23:18, Ronaldo <rcmpersiano@gmail.com> wrote: > Very nice solution, nophead! I have worked a little on it and tried a > factorization of the Minkowski operation expecting a better performance: > > > module ninteyDegFillet2(r,n) { > > /* > > r - fllet radius > > n - number of steps > > */ > > function rad(x) = 10 - sqrt(pow(10,2) - pow(x - 10, 2)); > > s = r/n; //step size > > eps = 0.001; // a small thickness of children() > > minkowski() { > > linear_extrude(height = eps) > > children(); > > for(i = [0 : s : r - s]) { > > translate([0, 0, i]) > > cylinder(r1 = rad(i), r2 = rad(i + s), h = s, $fn = 32); > > } > > } > > } > > For my surprise, ninteyDegFillet2 spent 34 sec to render while > ninteyDegFillet took just 14sec. Have you an explanation for this? > > > > > -- > View this message in context: > http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17221.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 >
R
Ronaldo
Fri, Apr 29, 2016 2:02 AM

Right, I made a transcription error. But oddly my version still spends more
than double the time of yours to render. Besides, the preview of my code is
as lengthy as the render.

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

Right, I made a transcription error. But oddly my version still spends more than double the time of yours to render. Besides, the preview of my code is as lengthy as the render. -- View this message in context: http://forum.openscad.org/Fillet-With-Internal-Angles-tp17201p17223.html Sent from the OpenSCAD mailing list archive at Nabble.com.