Softening a polygon

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Softening a polygon

gounthar
This post was updated on .
Hi List, I'm trying to code a toy bus that I made (in wood) years ago when my kids were young, just to see if my (cheapo) CNC could make a miniature version.
the bus
For the time being, I have mostly entered dimensions, and made the bottom part. I am now trying to code the rear block, and I want to soften the polygon lines, like I did with the wood and the big disc sander. I thought of using a Béziers curve, and I found a library with a function that returns a set of points corresponding to the Béziers curve. Now, I can't seem to be able to create a polygon from this list, so for the time being (bear with me, my code is terrible) I have used a linear_extrude of a projection of a hull_polyline3d.

It's not really what I was aiming for. Would there be a more "openScad" way of concatenating a polygon with a softened version of a part of itself? I will have to do it in other places too, like the top for example...
Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Softening a polygon

TLC123
Hi gounthar
Rounding is one of the most asked questions.

Short answer for 3d boolean operations union difference  and intersection:
There is none as most think of them.

Now there are a bunch of work arounds.
Best but limited is to do all the heavy lifting in 2d.

There are many but two common methods is the Round_Anything library or using a triplet of 2d offsets.

2d offsets.
First offset out 1=r, then offset in r=2 , last offset out r=1.
That get you outer and inner radii of 1.
For thin features <r this method will fail

Round_Anything.   https://github.com/Irev-Dev/Round-Anything
Round_Anything, witch i recommend, don't have the same drawbacks.
In general very powerful, offers individual radius for each point, but is slightly more involved to use.

And then there are the very slow minkowski operation. could be used in a pinch but realistically only on low polygon geometry.

For your case id suggest making three 2d sketches on for each top side and front view.
Top and front views are symmetrical and is best drawn such on centreline.
Then linear_extrude each sketch and 3d rotate into place.
For side view you want to invoke the linear_extrude with the center=true  option.

These three extrusions can then be enclosed in a intersection block.
The result should be as if you had cut them out on a band saw in three planes.

As shown in the image  there are no rounding on the edge where the planes intersect.

As a finishing step each sketch can individually be given a negative offset of some radius.
Then a minkowski operation can compose the intersection with a sphere of the same radius.

Best of luck.
 <nabble_img />
 

Reply | Threaded
Open this post in threaded view
|

Re: Softening a polygon

gounthar
Thank you so much TLC123 for taking the time to explain these methods with great details.
I will give them a try.
Reply | Threaded
Open this post in threaded view
|

Re: Softening a polygon

TLC123
It's all my pleasure.
One tip is to give the techniques  a practice run on some simple stuff before your real project,
The rotation of the three 2d sketches was  somewhat confusing the first time i tried.
Best of luck.
```
    translate([-10,0,0])
        intersect_planes(h=26){
         
          square([40,8],center=true);       //XY
          circle(5.5);                      //YZ
          text("OK!",halign="center",valign="center"); // XZ
        }
    translate([30,0,0])
        show_intersect_planes(h=26){
          text("XY",halign="center",valign="center"); 
          text("YZ",halign="center",valign="center"); 
          text("XZ",halign="center",valign="center"); 
        }

    module intersect_planes(h ){
    intersection(){
    color("blue") 
        linear_extrude(h,center=true,convexity=20)children(0);
    color("red") rotate([0,-90,0])rotate(-90)
        linear_extrude(h,center=true,convexity=20)children(1);
    color("green")   rotate([90,0,0]) 
        linear_extrude(h,center=true,convexity=20)children(2);
    }    }
        
    module show_intersect_planes(){  
    union(){
    color("blue") 
        linear_extrude(h,center=true,convexity=20)children(0);
    color("red") rotate([0,-90,0])rotate(-90)
        linear_extrude(h,center=true,convexity=20)children(1);
    color("green")  rotate([90,0,0]) 
        linear_extrude(h,center=true,convexity=20)children(2);
    }
    }
```