From 3210d36f3f3839de3827ae1e1aa22f33b4695935 Mon Sep 17 00:00:00 2001 From: Jens Heinrich Date: Sun, 12 May 2019 23:55:58 +0200 Subject: [PATCH] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20polyhaus.?= =?UTF-8?q?scad=20fixed=20orientation=20of=20the=20outer=20wall=20elements?= =?UTF-8?q?=20added=20trigonometric=20helper=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- polyhaus.scad | 275 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 167 insertions(+), 108 deletions(-) diff --git a/polyhaus.scad b/polyhaus.scad index ae6501c..7714373 100644 --- a/polyhaus.scad +++ b/polyhaus.scad @@ -13,6 +13,38 @@ sides=6; outer_wall_woodwidth=50; outer_wall_strawwidth=1000; +// Reusable functions +// returns the inner circle radius given +// the angle +// wallstrengt +// and the diameter +// +// +function radius_in_circle(angle, diameter, wallstrength) =( + (cos(angle)*diameter)- + wallstrength +); + + +// returns the cleaned up value +// given +// angle, +// diameter, +// wallstrengt (measured 90° to the wall) +function radius_in_diameter(angle, wallstrength, diameter) = ( +radius_in_circle(angle=angle, diameter=diameter, wallstrength=wallstrength)/ cos(angle)); +// echo(radius_in_diameter(diameter=2,wallstrength=0,angle=45)); +// should return 2 + +// return the length of the inside of wall +// given +// angle +// wallstrengt +// diameter +function sidelength_inside(angle,diameter,wallstrength)=(abs(sin(angle)*radius_in_diameter(angle,diameter,wallstrength)*2)); +// echo(abs(sidelength_inside(diameter=2,wallstrength=0,angle=45))); +// should return 4 + // The House Modules module ngon( diameter=5, @@ -86,7 +118,7 @@ module living( radius_in_diameter=radius_in_circle/ sin(angle); side_length=2*acos(0.5*360/sides)*radius_in_circle; # - difference() { +difference() { %ring(); echo("DEBUG LIVING building inner ring"); translate([0,0,+floorstrength]) @@ -108,10 +140,10 @@ module spar( echo("DEBUG SPAR creating spar"); echo("DEBUG SPAR spar vars"); echo( - spar_width, - spar_depth, - spar_height -); + spar_width, + spar_depth, + spar_height + ); translate( [0.5*spar_width, @@ -126,6 +158,50 @@ module spar( ); } +module draw_spars( + spar_offset, + outer_wall_woodwidth, + wallstrength, + ringheigth +) +{ + echo("DEBUG draw_spars drawing spars"); + echo("DEBUG draw_spars vars:( spar_offset, outer_wall_woodwidth, wallstrength, ringheigth)"); + echo( + spar_offset, + outer_wall_woodwidth, + wallstrength, + ringheigth + ); + + // positive spar + translate ( + [ + spar_offset, + 0, + 0 + //radius_in_circle + ] ) + spar( + spar_width=outer_wall_woodwidth, + spar_depth=wallstrength, + spar_height=ringheigth + ); + // mirrored / negative spar + translate ( + [ + -spar_offset, + 0, + 0 + //radius_in_circle + ] ) + spar( + spar_width=outer_wall_woodwidth, + spar_depth=wallstrength, + spar_height=ringheigth + ); +} + module outer_wall( ringdiameter=ringdiameter, ringstrength=ringstrength, @@ -134,17 +210,24 @@ module outer_wall( ceilingstrength=ceilingstrength ) { + echo("DEBUG OUTER WALL building with ringdiameter, ringstrength,ringheigth,floorstrength,ceilingstrength"); + echo(ringdiameter, ringstrength,ringheigth,floorstrength,ceilingstrength); angle=0.5*360/sides; echo("DEBUG angle"); echo(angle); radius_in_circle=floor( - 0.5*(sin(angle)*ringdiameter)- - wallstrength + radius_in_circle(diameter=ringdiameter,angle=angle,wallstrength=wallstrength) + +// (cos(angle)*ringdiameter)- +// wallstrength ); echo("DEBUG radius_in_circle"); - echo(radius_in_circle); - side_length=round( - 2*cos(angle)*radius_in_circle + echo(radius_in_circle(diameter=ringdiameter,angle=angle,wallstrength=wallstrength)); + echo("DEBUG radius_in_diameter") + + echo(radius_in_diameter(diameter=ringdiameter,angle=angle,wallstrength=wallstrength)); + side_length=round(sidelength_inside(diameter=ringdiameter,angle=angle,wallstrength=wallstrength) + //2*cos(angle)*radius_in_circle ); echo("DEBUG side_lenght"); echo(side_length); @@ -153,109 +236,85 @@ module outer_wall( echo(elements); for(side=[1:sides] ) { - echo("DEBUG running through sides"); - echo(side); - rotate( - [0,0,2*angle] - ) - { - echo(" DEBUG OUTER WALL building spars") - if (elements%2==1) + // rotate the outerwall to every side of the building + rotate(angle+2*side*angle) + translate( + [ + radius_in_circle+ + wallstrength, + 0, + 0 + ] + ) { - echo("DEBUG uneven number"); - // center the middle modeline - for (spar= [0:elements]) - { - echo("DEBUG OUTER WALL planking"); - echo("DEBUG OUTER WALL spar"); - echo(spar); - offset = ( - 0.5* outer_wall_strawwidth + - spar*(outer_wall_woodwidth + - outer_wall_strawwidth) - ); - echo("DEBUG OUTER WALL offset for spar"); - echo(offset); - echo("DEBUG OUTER WALL spar vars"); - echo( - outer_wall_woodwidth, - wallstrength, - level - ); - translate ( - [ - 0, - offset, - radius_in_circle - ] ) - spar( - spar_width=outer_wall_woodwidth, - spar_depth=wallstrength, - spar_height=level - ); - translate ( - [ - 0, - -offset, - radius_in_circle - ] ) - spar( - spar_width=outer_wall_woodwidth, - spar_depth=wallstrength, - spar_height=level - ); - - } - } - if (elements%2==0) + echo("DEBUG running through sides"); + echo(side); + rotate( [0,0,90]) { - echo("DEBUG even number"); - // center the middle modeline - for (spar= [0:elements]) + echo("DEBUG OUTER WALL building spars"); + if (elements%2==1) { - echo("DEBUG OUTER WALL planking"); - echo("DEBUG OUTER WALL spar"); - echo(spar); - offset= (0.5* outer_wall_strawwidth + - spar*(outer_wall_woodwidth+ - outer_wall_strawwidth)); - echo("DEBUG OUTER WALL offset for spar"); - echo(offset); - echo("DEBUG OUTER WALL spar vars"); - echo( - outer_wall_woodwidth, - wallstrength, - level + echo("DEBUG uneven number"); + // center the middle modeline + for (spar= [0:elements/2]) + { + echo("DEBUG OUTER WALL planking"); + echo("DEBUG OUTER WALL spar"); + echo(spar); + offset = ( + 0.5* outer_wall_strawwidth + + spar*(outer_wall_woodwidth + + outer_wall_strawwidth) ); - // positive spar - translate ( - [ - offset, - 0, - radius_in_circle - ] ) - spar( - spar_width=outer_wall_woodwidth, - spar_depth=wallstrength, - spar_height=level - ); - // negative spar - translate ( - [ - -offset, - 0, - radius_in_circle - ] ) - spar( - spar_width=outer_wall_woodwidth, - spar_depth=wallstrength, - spar_height=level - ); - } + echo("DEBUG OUTER WALL offset for spar"); + echo(offset); + echo("DEBUG OUTER WALL spar vars"); + echo( + outer_wall_woodwidth, + wallstrength, + ringheigth + ); + draw_spars( + offset, + outer_wall_woodwidth, + wallstrength, + ringheigth + ); + } + } + if (elements%2==0) + { + echo("DEBUG even number"); + // center the middle modeline + for (spar= [0:elements/2]) + { + echo("DEBUG OUTER WALL planking"); + echo("DEBUG OUTER WALL spar"); + echo(spar); + // offset "along" the wall + offset= (0.5* outer_wall_strawwidth + + spar*(outer_wall_woodwidth+ + outer_wall_strawwidth)); + echo("DEBUG OUTER WALL offset for spar"); + echo(offset); + echo("DEBUG OUTER WALL spar vars"); + echo( + outer_wall_woodwidth, + wallstrength, + ringheigth + ); + draw_spars( + offset, + outer_wall_woodwidth, + wallstrength, + ringheigth=ringheigth + ); + } + } } - } - } -}; + } + }; +} living(); translate([0,0,level]) living();