# [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])/len(data) )
delta*(data[i]-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])
>   scale([(data[target] - delta)/data[target], (data[target] -
> delta)/data[target], 1])
>   translate(-data[target])
>
>   intersection()
>   {
>     gen_node(data[target], data[target], data[target]);
>     linear_extrude(height=1000)
>     projection()
>     {
>       difference()
>       {
>         gen_node(data[target], data[target], data[target]);
>         for(i=[0:len(data)])
>         {
>           if(i != target)
>           {
>             gen_node(data[i], data[i], data[i]);
>           }
>         }
>       }
>     }
>   }
> }
>
> 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.
>
>
>
> --