[OpenSCAD] Fillet With Internal Angles

Ronaldo rcmpersiano at gmail.com
Tue Oct 25 19:59:25 EDT 2016


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.




More information about the Discuss mailing list