I made a thing - unionRound / fillet union

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

I made a thing - unionRound / fillet union

TLC123
This post was updated on .
One of the most common request is boolean operations with fillet/chamfer/rounding/radius/smoothing . Most option so far has been unsatisfactory or glacially slow.
 
Enabled by fast convex + convex minkowski sum. Thanks whoever implemented that.

    Unions of simple operands has a general FAST solution in all cases where the joint area is convex

    For non convex operands, a simple masking system enable us to isolate out only local convex areas to process.
    Masks are in practice a common volume that both operands are first intersected by.


Though not a complete solution a good part of common cases can be filleted. (se limitations.)

With an exploit of fast convex + convex minkowski and the Theorem: Given any collection of convex sets, their intersection is itself a convex set.
The following became possible:
 



   
     ////////////////////////////////////////////////////////
    /*
    unionRound() 1.0 Module by Torleif Ceder - TLC123 late summer 2021
     Pretty fast Union with radius, But limited to a subset of cases
    Usage
     unionRound( radius , detail , epsilon )
        {
         YourObject();
         YourObject();
        }
    limitations:
     0. Only really fast when boolean operands are convex,
            Minkowski is fast in that case.
     1. Boolean operands may be concave but can only touch
            in a single convex area
     2. Radius is of elliptic type and is only approximate r
            were operand intersect at perpendicular angle.
    */
    ////////////////////////////////////////////////////////
    // Demo code
     unionRound(1.5, 5) {
     cube([10,10,2],true);
     rotate([20,-10,0])cylinder(5,1,1,$fn=12);
    }
    // end of demo code
    //
    module unionRound(r, detail = 5) {
        epsilon = 1e-6;
        children(0);
        children(1);
        step = 90 / detail;
      for (i = [0:  detail-1]) {
            {
                x = r - sin(i * step ) * r;
                y = r - cos(i * step ) * r;
                xi = r - sin((i * step + step)  ) * r;
                yi = r - cos((i * step + step)  ) * r;
                color(rands(0, 1, 3, i))
                hull() {
                    intersection() {
                        // shell(epsilon)
                        clad(x) children(0);
                        // shell(epsilon)
                        clad(y) children(1);
                    }
                    intersection() {
                        // shell(epsilon)
                        clad(xi) children(0);
                        // shell(epsilon)
                        clad(yi) children(1);
                    }
                }
            }
        }
    }
    // unionRound helper expand by r
    module clad(r) {
        minkowski() {
            children();
            //        icosphere(r,2);
             isosphere(r,70);
        }
    }
    // unionRound helper
    module shell(r) {
        difference() {
            clad(r) children();
            children();
        }
    }
 /*    
    // The following is a sphere with some equidistant properties.
    // Not strictly necessary

    Kogan, Jonathan (2017)
    "A New Computationally Efficient Method for Spacing n Points on a
    Sphere,"
    Rose-Hulman Undergraduate Mathematics Journal:
    Vol. 18 : Iss. 2 , Article 5.
    Available at:
    https://scholar.rose-hulman.edu/rhumj/vol18/iss2/5 */

    function sphericalcoordinate(x,y)=  [cos(x  )*cos(y  ), sin(x  )*cos(y  ), sin(y  )];
    function NX(n,x)=
    let(toDeg=57.2958,PI=acos(-1)/toDeg,
    start=(-1.+1./(n-1.)),increment=(2.-2./(n-1.))/(n-1.) )
    [ for (j= [0:n-1])let (s=start+j*increment )
    sphericalcoordinate(   s*x*toDeg,  PI/2.* sign(s)*(1.-sqrt(1.-abs(s)))*toDeg)];
    function generatepoints(n)= NX(n,0.1+1.2*n);
    module isosphere(r,detail){
    a= generatepoints(detail);
    scale(r)hull()polyhedron(a,[[for(i=[0:len(a)-1])i]]);
    }


 
[on Youtube] 
[on GitHub]

[on Thingiverse]


[on OpenSCAD Snippet Pad]


[on r /OpenSCAD]
 
Reply | Threaded
Open this post in threaded view
|

Re: I made a thing - unionRound / fillet union

MichaelAtOz
Administrator
I haven't tried it, but it looks nice, thanks.

a. Don't you want
      module unionRound(r, detail = 5, epsilon = 1e-6) {
   

b. The Forum is no longer linked to the Mailing-list. You should email a link to this post for people to see it.

I think you should not post here any more.

OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: I made a thing - unionRound / fillet union

TLC123
Hi, thanks for the feedback. It warms my heart.

a.
Yeah you're right. There are a bunch of function i held back. I tried to hold code lean for the first publishing to bolster understanding.
Shell module is really not needed in the base case. Hence neither epsilon.
I found a great deal of neat tricks with minkowski over epsilon slivers.

b. Mailing list are at best like telegraphing a crutch via amish buggy. I will not use it to chat.

I will cross post this finding and links in many places. Updates follow on github I realize this forum has no guarantee to be archived but a few people read it none the less. I leave a trace and crums to the new place when its decided on. Please send my love (and findings ) to the good people in the spruce submarine  :).

Best of luck.