diff --git a/konstrukt-beam.scad b/konstrukt-beam.scad index 9c180de..f8fdffb 100644 --- a/konstrukt-beam.scad +++ b/konstrukt-beam.scad @@ -1,94 +1,99 @@ -include <./measurements.scad>; -$fn=50; - -//konstrukt_beam_base_L(4,3); - -//konstrukt_beam_p(konstrukt_beam_arc(3,3,180)); -//konstrukt_beam_p(konstrukt_beam_circle(6,3)); - -//konstrukt_beam_p([[25,0]]); - -function konstrukt_beam_L(len1=4,len2=3)=[[len1,90],[len2,0]]; -function konstrukt_beam_arc(segments=3,length=2,angle=90) = [ for (i= [1:1:segments]) [length,angle/(segments) ]]; -function konstrukt_beam_circle(segments=3,length=2) = [ for (i= [1:1:segments]) [length,360/segments] ]; - -module konstrukt_beam_p(components=[[5,0]],height=KB_BEAM_HEIGHT) { - konstrukt_beam_base(components, height); - konstrukt_beam_holes(components, height); -} - -module konstrukt_beam(components=[[5,0]],height=KB_BEAM_HEIGHT) { - difference() { - konstrukt_beam_base(components, height); - konstrukt_beam_holes(components, height); - } -} - - - -module konstrukt_beam_base(subs=[[5,0]],height=KB_BEAM_HEIGHT,num=0) { - length = subs[num][0]; - angle = subs[num][1]; - konstrukt_beam_base_straight(length); - next = num+1; - if(next < len(subs)) { - translate(konstrukt_beam_move_holes(length)) { - rotate([0,0,angle]) { - konstrukt_beam_base(subs,height,next); - } - } - } -} - - -module konstrukt_beam_holes(subs=[[5,0]],height=KB_BEAM_HEIGHT,num=0) { - length = subs[num][0]; - angle = subs[num][1]; - - next = num+1; - if(next < len(subs)) { - konstrukt_beam_holes_straight(length-1); - translate(konstrukt_beam_move_holes(length)) { - rotate([0,0,angle]) { - konstrukt_beam_holes(subs,height,next); - } - } - } - konstrukt_beam_holes_straight(length); -} - -module konstrukt_beam_base_straight(l=2,h=KB_BEAM_HEIGHT) { - cube_length= (l-1)*KB_HOLE_SPACING; - union() { - cylinder(d=KB_BEAM_WIDTH, h=h); - translate([0,-KB_BEAM_WIDTH/2]) { - cube([cube_length, KB_BEAM_WIDTH, h]); - } - translate([cube_length,0]) { - cylinder(d=KB_BEAM_WIDTH, h=h); - } - } -} - -function konstrukt_beam_move_holes(len)=[(len-1)*KB_HOLE_SPACING,0]; - -/** - * Construct object to be substracted from base bean - * in order to create LEGO Technic compatible hole - * - * @param h Height of beam - **/ -module konstrukt_beam_hole(h=KB_BEAM_HEIGHT) { - union() { - cylinder(d=KB_HOLE_RING_DIAMETER, h=KB_HOLE_RING_DEPTH); - cylinder(d=KB_HOLE_INSIDE_DIAMETER, h=h ); - translate([0,0,h-KB_HOLE_RING_DEPTH]) - cylinder(d=KB_HOLE_RING_DIAMETER, h=KB_HOLE_RING_DEPTH); - } -} - -module konstrukt_beam_holes_straight(n=1,h=KB_BEAM_HEIGHT) { - for(i=[0:n-1]) - translate([i*KB_HOLE_SPACING,0]) - konstrukt_beam_hole(h); -} +include <./measurements.scad>; +$fn=50; + +//konstrukt_beam_base_L(4,3); + +konstrukt_beam(konstrukt_beam_rect(15,3)); +//konstrukt_beam_p(konstrukt_beam_circle(6,3)); + +//konstrukt_beam_p([[25,0]]); + + +function konstrukt_beam_rect(len1=4,len2=3)=[[len1,90],[len2,90],[len1,90],[len2,90]]; +function konstrukt_beam_L(len1=4,len2=3)=[[len1,90],[len2,0]]; +function konstrukt_beam_arc(segments=3,length=2,angle=90) = [ for (i= [1:1:segments]) [length,angle/(segments) ]]; + +function konstrukt_beam_arc2(segments=3,length=2,angle=90) = [ for (i= [1:1:segments]) [length,angle]]; + +function konstrukt_beam_circle(segments=3,length=2) = [ for (i= [1:1:segments]) [length,360/segments] ]; + +module konstrukt_beam_p(components=[[5,0]],height=KB_BEAM_HEIGHT) { + konstrukt_beam_base(components, height); + konstrukt_beam_holes(components, height); +} + +module konstrukt_beam(components=[[5,0]],height=KB_BEAM_HEIGHT) { + difference() { + konstrukt_beam_base(components, height); + konstrukt_beam_holes(components, height); + } +} + + + +module konstrukt_beam_base(subs=[[5,0]],height=KB_BEAM_HEIGHT,num=0) { + length = subs[num][0]; + angle = subs[num][1]; + konstrukt_beam_base_straight(length); + next = num+1; + if(next < len(subs)) { + translate(konstrukt_beam_move_holes(length)) { + rotate([0,0,angle]) { + konstrukt_beam_base(subs,height,next); + } + } + } +} + + +module konstrukt_beam_holes(subs=[[5,0]],height=KB_BEAM_HEIGHT,num=0) { + length = subs[num][0]; + angle = subs[num][1]; + + next = num+1; + if(next < len(subs)) { + konstrukt_beam_holes_straight(length-1); + translate(konstrukt_beam_move_holes(length)) { + rotate([0,0,angle]) { + konstrukt_beam_holes(subs,height,next); + } + } + } + konstrukt_beam_holes_straight(length); +} + +module konstrukt_beam_base_straight(l=2,h=KB_BEAM_HEIGHT) { + cube_length= (l-1)*KB_HOLE_SPACING; + union() { + cylinder(d=KB_BEAM_WIDTH, h=h); + translate([0,-KB_BEAM_WIDTH/2]) { + cube([cube_length, KB_BEAM_WIDTH, h]); + } + translate([cube_length,0]) { + cylinder(d=KB_BEAM_WIDTH, h=h); + } + } +} + +function konstrukt_beam_move_holes(len)=[(len-1)*KB_HOLE_SPACING,0]; + +/** + * Construct object to be substracted from base bean + * in order to create LEGO Technic compatible hole + * + * @param h Height of beam + **/ +module konstrukt_beam_hole(h=KB_BEAM_HEIGHT) { + union() { + translate([0,0,-0.5]) cylinder(d=KB_HOLE_RING_DIAMETER, h=KB_HOLE_RING_DEPTH+0.5); + cylinder(d=KB_HOLE_INSIDE_DIAMETER, h=h ); + translate([0,0,h-KB_HOLE_RING_DEPTH]) + cylinder(d=KB_HOLE_RING_DIAMETER, h=KB_HOLE_RING_DEPTH+0.5); + } +} + +module konstrukt_beam_holes_straight(n=1,h=KB_BEAM_HEIGHT) { + for(i=[0:n-1]) + translate([i*KB_HOLE_SPACING,0]) + konstrukt_beam_hole(h); +} diff --git a/konstrukt-beams.json b/konstrukt-beams.json new file mode 100644 index 0000000..30e516c --- /dev/null +++ b/konstrukt-beams.json @@ -0,0 +1,3 @@ +{ + "fileFormatVersion": "1" +} diff --git a/konstrukt-beams.scad b/konstrukt-beams.scad new file mode 100644 index 0000000..643fa62 --- /dev/null +++ b/konstrukt-beams.scad @@ -0,0 +1,3 @@ +include <./konstrukt-beam.scad>; + +konstrukt_beam_p(konstrukt_beam_arc(3,3,180));