[OpenSCAD] What's the best way to accomplish splitting these elements?

Ronaldo Persiano rcmpersiano at gmail.com
Mon Jul 8 09:00:21 EDT 2019


I don't think that changing the cone shapes is a good idea to get the
intended gap. And in some cases, there is no displacement of the
embeded(target) which produces a good gap, for instance when one cone base
is entirely inside another cone base. So, the general problem of finding
appropriate small cone displacement to get gaps has no solution. To find a
solution when one exists seems to be a hard problem.

I tried a heuristic strategy that does not work in many cases; change the
main code to:

delta = 0.02;


for(i = [0:len(data)-1])
{
  translate(displ(i))
  embedded(i);
}


where displ() is defined by:

function sum(l) =
  [for(i=[0:len(l)-1]) 1]*l;

function displ(i) =
  let( ctp = sum([for(di=data) di[0]])/len(data) )
  delta*(data[i][0]-ctp);


BTW, two 'for' in your code have an improper last index and I got a
warnings of undef values delivered to translate.
Correction:

        for(i=[0:len(data)-1])



Em seg, 8 de jul de 2019 às 10:31, guaranteed_interwoven <
kerryhall at gmail.com> escreveu:

> I think I'm closer with:
>
> $fn = 20;
> delta = 0.5;
>
> module gen_node(coords, d, h)
> {
>   translate(coords)
>   cylinder(d1=d, d2=0, h=h);
> }
>
> data = [
>   [[4, 5, 0], 10, 10],
>   [[0, 0, 0], 10, 20],
>   [[-5, 3, 0], 15, 10],
>   [[-2, 6, 0], 15, 7],
>   [[2, 16, 0], 20, 20],
> ];
>
> module embedded(target)
> {
>
>   translate(data[target][0])
>   scale([(data[target][1] - delta)/data[target][1], (data[target][1] -
> delta)/data[target][1], 1])
>   translate(-data[target][0])
>
>   intersection()
>   {
>     gen_node(data[target][0], data[target][1], data[target][2]);
>     linear_extrude(height=1000)
>     projection()
>     {
>       difference()
>       {
>         gen_node(data[target][0], data[target][1], data[target][2]);
>         for(i=[0:len(data)])
>         {
>           if(i != target)
>           {
>             gen_node(data[i][0], data[i][1], data[i][2]);
>           }
>         }
>       }
>     }
>   }
> }
>
> for(i = [0:len(data) - 1])
> {
>   embedded(i);
> }
> </file/t2594/example_06.png>
>
> This is at least consistent per edge, but not consistent per node or
> globally.
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190708/9ddf0851/attachment.html>


More information about the Discuss mailing list