diff options
author | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-01 04:43:07 (GMT) |
---|---|---|
committer | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-01 04:43:07 (GMT) |
commit | ad427bd869aa4be40de44c798e498d474efef26f (patch) | |
tree | f2495aed73e31b1c55a3e9c74b65b35a1ed2771c /libraries | |
parent | 5dbf13c49f110646593c2ccdc3aa049f1fb7d0fb (diff) |
clarify, simplify
git-svn-id: http://svn.clifford.at/openscad/trunk@400 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/shapes.scad | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/libraries/shapes.scad b/libraries/shapes.scad index 60c71e7..109903b 100644 --- a/libraries/shapes.scad +++ b/libraries/shapes.scad @@ -71,42 +71,32 @@ module ovalTube(height, rx, ry, wall) { } } -module hexagon(height, depth) { - boxWidth = height/1.75; - union() { - box(boxWidth, height, depth); - rotate([0,0,60]) box(boxWidth, height, depth); - rotate([0,0,-60]) box(boxWidth, height, depth); - } +module hexagon(size, depth) { + boxWidth = size/1.75; + for (r = [-60, 0, 60]) rotate([0,0,r]) cube([boxWidth, size, depth], true); } -module octagon(height, depth) { +module octagon(size, depth) { intersection() { - box(height, height, depth); - rotate([0,0,45]) box(height, height, depth); + cube([size, size, depth], true); + rotate([0,0,45]) cube([size, size, depth], true); } } -module dodecagon(height, depth) { +module dodecagon(size, depth) { intersection() { - hexagon(height, depth); - rotate([0,0,90]) hexagon(height, depth); + hexagon(size, depth); + rotate([0,0,90]) hexagon(size, depth); } } -module hexagram(height, depth) { - boxWidth=height/1.75; - intersection() { - box(height, boxWidth, depth); - rotate([0,0,60]) box(height, boxWidth, depth); - } - intersection() { - box(height, boxWidth, depth); - rotate([0,0,-60]) box(height, boxWidth, depth); - } - intersection() { - rotate([0,0,60]) box(height, boxWidth, depth); - rotate([0,0,-60]) box(height, boxWidth, depth); +module hexagram(size, depth) { + boxWidth=size/1.75; + for (v = [[0,1],[0,-1],[1,-1]]) { + intersection() { + rotate([0,0,60*v[0]]) cube([size, boxWidth, depth], true); + rotate([0,0,60*v[1]]) cube([size, boxWidth, depth], true); + } } } @@ -129,11 +119,11 @@ module equiTriangle(side, depth) { } } -module 12ptStar(height, depth) { +module 12ptStar(size, depth) { starNum=3; starAngle=360/starNum; for (s=[1:starNum]) { - rotate([0, 0, s*starAngle]) box(height, height, depth); + rotate([0, 0, s*starAngle]) box(size, size, depth); } } @@ -141,13 +131,13 @@ module 12ptStar(height, depth) { //MOVES THE ROTATION AXIS OF A BOX FROM ITS CENTER TO THE BOTTOM LEFT CORNER //FIXME: Why are the dimensions changed? // why not just translate([0,0,-d/2]) cube([w,h,d]); -module dislocateBox(w,h,d){ - translate([w/2,h,0]){ - difference(){ - box(w, h*2, d+1); - translate([-w,0,0]) box(w, h*2, d+1); - } - } +module dislocateBox(w,h,d) { + translate([w/2,h,0]) { + difference() { + box(w, h*2, d+1); + translate([-w,0,0]) box(w, h*2, d+1); + } + } } |