2

I want to generate a self-similar, size-reduced, fixed-angle branching structure in OpenScad. The generated tree would simulate the lungs.

I managed to generate the first divisions ("generations") of the tree but I am stuck if I want to go further...

h = 0.79;
angle = 30;

diametreTubeBase = 13.5;
diametreTube = diametreTubeBase * 0.8 * 0.8; // deux niveau plus bas

diametreSphere = diametreTube*0.75;
rayonGrappe = 2.25*diametreSphere;

hFermeture = 3 ;
diamAimant = 4 + 0.2; // 0.2 pour l'épaisseur du matériel lors de l'impression
hAimant = 2 + 1;

resol = 18;

difference()
{

union(){
// 1ere génération
difference()
{
    cylinder(h=rayonGrappe*1.5, d=diametreTube, center=false, $fn=resol);
    {
    translate([0,0,rayonGrappe*1.5 - hAimant])
        cylinder(h=hAimant+1, d=diamAimant, center=false, $fn=resol);
    }
}

for(i = [2,3]){
    for(j = [1,pow(2,i-1)]){
               echo(pow(-1,j));
    translate([0,pow(-1,j)*(i-2)*sin(angle)*rayonGrappe*1.5*pow(h,i-2),-(i-2)*cos(angle)*rayonGrappe*1.5*pow(h,i-2)]){
rotate(a=[180,pow(-1,j)*angle,(i-2)*90+pow(-1,i)*90]){
cylinder(h=rayonGrappe*1.5*pow(h,i-1), d=diametreTube*pow(h,i-1), center=false, $fn=resol);
                         }
                 }
         }
}

}
}

I expect that I would be able to generate the other generations with fixed angle division (30°) and rotation of 90 compared with the previous axis.

Thanks you for your insights.

4

1 に答える 1