Irev-Dev / Round-Anything

A set of OpenSCAD utilities for adding radii and fillets, that embodies a robust approach to developing OpenSCAD parts.
https://kurthutten.com/blog/round-anything-a-pragmatic-approach-to-openscad-design
MIT License
504 stars 47 forks source link

polyRoundRotate/rotate_extrudeWithRadius functionality #43

Open drf5n opened 2 years ago

drf5n commented 2 years ago

If I want to round the corners on a rotated solid polygon as is done with extrudeWithRadius(), is that possible with the library as-is?

I tried to illustrate what I'm looking for with this image and code-- I'd like the x=400 column to round the start,stop, and intermediate corners of the revolved solid in the X=300 column. Is this what beamChains can do?

image
use <Round-Anything/polyround.scad> // https://github.com/Irev-Dev/Round-Anything

function makeRadiiPoints(r1, r2)=[[0,0,0],[0,20,r1],[20,20,r1],[20,0,0]];

// radii are too large again and are reduced to fit, but keep their ratios.
// r1 will go from 10 to 4 and r2 will go from 40 to 16

translate([0,100,0])x0(); //initial shape
translate([100,100,0])x1(); // $fn=3 extrudeWithRadius polygon
translate([200,100,0])x2(); //  rotate_extrude polygon
translate([300,100,0])x3();

translate([0,200,0])c0(); // $fn=3 rotated circle
translate([100,200,0])c1(); // $fn=3 rotated circle
translate([200,200,0])c2(); // $fn=3 rotated circle
translate([300,200,0])c3(); // $fn=3 rotated circle

module x0(){
    polygon(polyRound(makeRadiiPoints(10,40),50));
}

module x1(){
    // from     https://learn.cadhub.xyz/docs/round-anything/api-reference/
    translate([25,0,0])x0();
}
module x2(){
    // 
    extrudeWithRadius(10,-2,2)x0();
}
module x3(){
    // 
    rotate_extrude(angle=180,$fn=8)x0();
}

module x4(){
    // 
    //rotate_extrudeWithRadius(angle=180,2,-2,2,$fn=8)x0();
}

module x5(){
    // 
    rotate_extrude($fn=3)x0();
}

module c0(){
    translate([25,0,0])circle(10);
}

module c1(){
    linear_extrude(10)c0();
}
module c2(){
    extrudeWithRadius(10,-2,2)c0();
}

module c3(){
    rotate_extrude(angle=180,$fn=8)c0();
}

module c4(){
   // rotate_extrudeWithRadius(angle=180,2,-2,2,$fn=8)c0();
}
drf5n commented 8 months ago

Apropos of nothing:

// Generate radiused regular polygons with a function

include <Round-Anything/polyround.scad>

function reg_radiipoints(sides,radius,rounds)=
[ for (th = [for(i =[0:sides-1]) i*(360/sides)]) [radius*cos(th), radius*sin(th),rounds] ];

plate();

module plate(){
    for (sides=[3:10]){
        translate([(sides-3)*20,0,0])polyBoss(sides,d=10,rounded=1);
    }    
}

module polyBoss(sides=6,d=10,h=10,r2=1,rounded=0){
    r=d/2;
    radiipoints = reg_radiipoints(sides,r,r2);
    if(rounded)polyRoundExtrude(radiipoints,h,r2,-r2);    
    if(!rounded)linear_extrude(h)polygon(polyRound(radiipoints,10));
}
image