//////////////////////////////////////////////// // gnuMaset // Parametritza un maset o caseta d'eines característiques // de les Terres de l'Ebre // v0.1 20210502 //////////////////////////////////////////////// // Paràmetres geomètrics bàsics a=5.0; b=4.0; c1=2.5; c2=3.5; tm=0.45; t_llosa=0.15; ts=0.12; // Terreny virtual tv=2.0; tvg=0.01; // Porta p1=1.0; p2=2.0; p3=2.0; palpha=0; tpi=0.08; // Obertura frontal f1=0.4; f2=0.6; f3=1.0; f4=2.2; // Obertura mur esquerre g1=0.4; g2=0.6; g3=1.0; g4=2.5; // Banquet 1 b1x=1.8; b1y=0.45; b1z=0.45; b1pos=3.2; // Cabirons i llates cab_a=0.15; cab_b=0.15; cab_s=0.55; llat_a=0.08; llat_b=0.04; llat_s=0.3; mao_t=0.02; // Pallissa esquerra palli1=1.2; palli2=0.05; palli3=2.0; pcab_a=0.12; pcab_b=0.12; pcab_n=3; pcab_enc=0.25; // Paràmetres auxiliars cm=tm*(c2-c1)/a; alpha=atan((c2-c1)/a); echo ("alpha=", alpha); s_lliure=sqrt((a-2*tm)*(a-2*tm)+(c2-c1-2*cm)*(c2-c1-2*cm)); cab_n=ceil((s_lliure+cab_a)/cab_s)-2; cab_ini=(tm/cos(alpha))+cab_s-0.5*cab_a; cab_dv=(mao_t+llat_b+cab_b)/cos(alpha); echo ("cab_n=", cab_n); echo ("cab_ini=", cab_ini); llat_lliu=b-2*tm; llat_n=ceil(llat_lliu/llat_s); llat_lat=0.5*(llat_lliu-((llat_n)-1)*llat_s); echo ("llat_n=", llat_n); echo ("llat_lat=", llat_lat); llat_desx=tm*(1-0.3*cos(alpha)); llat_z1=(mao_t+llat_b)/cos(alpha); llat_z2=llat_desx*tan(alpha); llat_desz=llat_z1+llat_z2; pcab_sep=(palli1-pcab_a)/(pcab_n-1); // Paràmetres de control de visibilitat terrev_vis=0; llosa_vis=1; murf_vis=0; murp_vis=0; murd_vis=1; mure_vis=1; teulat_vis=0; omf_vis=0; ome_vis=1; ban1_vis=1; portai_vis=1; cabi_vis=1; llat_vis=1; palli_vis=1; //////////////////////////////////////////////// // Dibuixar //////////////////////////////////////////////// if (terrev_vis==1) { // Terreny virtual color ([0,1,0]) translate([-tv,-tv,-tvg]) cube([a+2*tv,b+2*tv,tvg]); } //////////////////////////////////////////////// // Llosa //////////////////////////////////////////////// if (llosa_vis==1) { color ([0.8,0.8,0.8]) translate([0,0,-t_llosa+0.001]) cube([a,b,t_llosa]); } //////////////////////////////////////////////// // Paret F //////////////////////////////////////////////// if (murf_vis==1) { //difference () { //union () { // Polyhedron (mur frontal) mur_f = [ [ 0,0,0 ], //0 [ a,0,0 ], //1 [ a,tm,0 ], //2 [ 0,tm,0 ], //3 [ 0,0,c2], //4 [ a,0,c1], //5 [ a,tm,c1], //6 [ 0,tm,c2]]; //7 mur_fo = [ [0,1,2,3], // bottom [4,5,1,0], // front [7,6,5,4], // top [5,6,2,1], // right [6,7,3,2], // back [7,4,0,3]]; // left difference () { // Mur frontal color ([0.9,0.8,0.3], 1) translate ([0,0,0]) rotate ([0,0,0]) polyhedron (mur_f, mur_fo); // Porta a mur frontal color([1,1,1]) translate ([a-p3-p1,-0.05*tm,0]) cube([p1,tm*1.1,p2]); if (omf_vis==1) { // Obertura a mur frontal color([1,1,1]) translate ([f3,-0.05*tm,f4]) cube([f1,tm*1.1,f2]); } } } //////////////////////////////////////////////// // Polyhedron (mur posterior) //////////////////////////////////////////////// if (murp_vis==1) { mur_p = [ [ 0,0,0 ], //0 [ a,0,0 ], //1 [ a,tm,0 ], //2 [ 0,tm,0 ], //3 [ 0,0,c2], //4 [ a,0,c1], //5 [ a,tm,c1], //6 [ 0,tm,c2]]; //7 mur_po = [ [0,1,2,3], // bottom [4,5,1,0], // front [7,6,5,4], // top [5,6,2,1], // right [6,7,3,2], // back [7,4,0,3]]; // left color ([0.9,0.8,0.3], 1) translate ([0,b-tm,0]) rotate ([0,0,0]) polyhedron (mur_p, mur_po); } //////////////////////////////////////////////// // Polyhedron (mur dreta) //////////////////////////////////////////////// if (murd_vis==1) { mur_d = [ [ a-tm,0,0 ], //0 [ a,0,0 ], //1 [ a,b,0 ], //2 [ a-tm,b,0 ], //3 [ a-tm,0,c1+cm], //4 [ a,0,c1], //5 [ a,b,c1], //6 [ a-tm,b,c1+cm]]; //7 mur_do = [ [0,1,2,3], // bottom [4,5,1,0], // front [7,6,5,4], // top [5,6,2,1], // right [6,7,3,2], // back [7,4,0,3]]; // left color ([0.9,0.8,0.3], 1) translate ([0,0,0]) rotate ([0,0,0]) polyhedron (mur_d, mur_do); } //////////////////////////////////////////////// // Polyhedron (mur esquerra) //////////////////////////////////////////////// if (mure_vis==1) { mur_e = [ [ a-tm,0,0 ], //0 [ a,0,0 ], //1 [ a,b,0 ], //2 [ a-tm,b,0 ], //3 [ a-tm,0,c2], //4 [ a,0,c2-cm], //5 [ a,b,c2-cm], //6 [ a-tm,b,c2]]; //7 mur_eo = [ [0,1,2,3], // bottom [4,5,1,0], // front [7,6,5,4], // top [5,6,2,1], // right [6,7,3,2], // back [7,4,0,3]]; // left difference () { // Mur esquerre color ([0.9,0.8,0.3], 1) translate ([-a+tm,0,0]) rotate ([0,0,0]) polyhedron (mur_e, mur_eo); // Finestra a mur esquerre if (ome_vis==1) { color([1,1,1]) translate ([-tm*0.05,b-g3-g1,g4]) cube([tm*1.1,g1,g2]); } } } //////////////////////////////////////////////// // Teulat //////////////////////////////////////////////// if (teulat_vis==1) { // Polyhedron (teulat) teulat = [ [ 0,0,c2 ], //0 [ a,0,c1 ], //1 [ a,b,c1 ], //2 [ 0,b,c2 ], //3 [ 0,0,c2+ts], //4 [ a,0,c1+ts], //5 [ a,b,c1+ts], //6 [ 0,b,c2+ts]]; //7 teulat_o = [ [0,1,2,3], // bottom [4,5,1,0], // front [7,6,5,4], // top [5,6,2,1], // right [6,7,3,2], // back [7,4,0,3]]; // left color ([0.9,0.3,0.3], 1) translate ([0,0,0]) rotate ([0,0,0]) polyhedron (teulat, teulat_o); } //////////////////////////////////////////////// // Pedrís (banquet) 1 //////////////////////////////////////////////// if (ban1_vis==1) { color ([0.9,0.8,0.7], 1) translate ([b1pos,-b1y,0]) cube ([b1x,b1y,b1z]); } //////////////////////////////////////////////// // Porta insterior //////////////////////////////////////////////// if (portai_vis==1) { translate ([0,tm,0]) color ([1,0.2,0.3], 1) translate ([a-p3-p1,0,0]) rotate ([0,0,palpha]) translate ([0,-tpi,0]) cube([p1,tpi,p2]); } //////////////////////////////////////////////// // Cabirons (bigues principals) //////////////////////////////////////////////// if (cabi_vis==1) { translate([0,0,c2-cab_dv]) rotate([0,alpha,0]) for (i=[0:cab_n]) color ([0.5,0.3,0.3], 1) translate ([cab_ini-0.5*cab_a+i*cab_s,tm*0.3,0]) cube([cab_a,b-tm*0.6,cab_b]); } //////////////////////////////////////////////// // Llates (bigues secundàries perpendiculars) //////////////////////////////////////////////// if (llat_vis==1) { translate([llat_desx,0,c2-llat_desz]) rotate([0,alpha,0]) for (j=[0:llat_n-1]) color ([0.5,0.5,0.4], 1) translate ([0,tm+llat_lat-0.5*llat_a+llat_s*j,0]) cube([s_lliure+0.6*tm,llat_a,llat_b]); } //////////////////////////////////////////////// // Pallissa a l'esquerra //////////////////////////////////////////////// if (palli_vis==1) { color ([0.2,0.8,0.4]) translate ([tm,tm,palli3-palli2]) cube([palli1,b-2*tm,palli2]); for (k=[0:pcab_n-1]) color ([0.4,0.4,0.6]) translate ([tm+k*pcab_sep,tm-pcab_enc,palli3-palli2-pcab_b]) cube([pcab_a,b-2*(tm-pcab_enc),pcab_b]); }