diff options
Diffstat (limited to 'chess')
-rw-r--r-- | chess/rook.scad | 22 | ||||
-rw-r--r-- | chess/rook_alt.scad | 17 |
2 files changed, 28 insertions, 11 deletions
diff --git a/chess/rook.scad b/chess/rook.scad index e8801dc..c38bcc7 100644 --- a/chess/rook.scad +++ b/chess/rook.scad @@ -35,24 +35,36 @@ head_radius = 1; head_height = 1; stem_height = total_height - base_height - (head_height / 2); +// Can set ridge_count to a coefficient or ratio of $fn or a static number +ridge_count = $fn/2; +ridge_angle_1 = 360 / ridge_count; +ridge_angle_2 = (360 / ridge_count) / 2; +ridge_angle_4 = (360 / ridge_count) / 4; + // ridge_offset will set the ridges to go over the corners ridge_offset_check = 0; -ridge_offset = ridge_offset_check * ((360/$fn)/2); +ridge_offset = ridge_offset_check * -ridge_angle_4; +// Base cylinder(base_height/2, r = base_radius); translate([0, 0, base_height/2]) cylinder(base_height/2, base_radius, stem_base_radius); + +// Column translate([0, 0, base_height]) cylinder(stem_height, stem_base_radius, stem_radius); + +// Head difference() { translate([0, 0, total_height - head_height]) cylinder(head_height, r = head_radius); + + // Ridges translate([0, 0, total_height - (head_height/4)]) { cylinder(head_height, r = head_radius * 0.75); - // this rotation will work for $fn = 8 or 6 - for (i = [0:(($fn/2)-1)]) { - rotate([0, 0, (i * (360/($fn/2))) - ridge_offset]) - rotate_extrude(angle = 360/$fn) + for (i = [1:ridge_count]) { + rotate([0, 0, (i * ridge_angle_1) - ridge_offset]) + rotate_extrude(angle = ridge_angle_2) square([head_radius + 0.25, head_height]); } } diff --git a/chess/rook_alt.scad b/chess/rook_alt.scad index a1d2f2b..ecc0219 100644 --- a/chess/rook_alt.scad +++ b/chess/rook_alt.scad @@ -53,9 +53,15 @@ head_radius = 1; head_height = 1; stem_height = total_height - base_height - (head_height / 2); +// Can set ridge_count to a coefficient or ratio of $fn or a static number +ridge_count = $fn; +ridge_angle_1 = 360 / ridge_count; +ridge_angle_2 = (360 / ridge_count) / 2; +ridge_width = (head_radius/ridge_count)*2; + // ridge_offset will set the ridges to go over the corners ridge_offset_check = 1; -ridge_offset = ridge_offset_check * ((360/$fn)/2); +ridge_offset = ridge_offset_check * ridge_angle_2; cylinder(base_height/2, r = base_radius); translate([0, 0, base_height/2]) @@ -67,11 +73,10 @@ difference() { cylinder(head_height, r = head_radius); translate([0, 0, total_height - (head_height/4)]) { cylinder(head_height, r = head_radius * 0.75); - // this rotation will work for $fn = 8 or 6 - for (i = [0:$fn]) { - rotate([0, 0, (i * (360/($fn))) - ridge_offset]) - rotate_extrude(angle = 360/$fn) - square([head_radius, head_height]); + for (i = [1:ridge_count]) { + rotate([0, 0, (i * ridge_angle_1) - ridge_offset]) + translate([0, -(ridge_width / 2), 0]) + cube([head_radius, ridge_width, head_height], false); } } } |