aboutsummaryrefslogtreecommitdiff
path: root/chess/rook.scad
diff options
context:
space:
mode:
Diffstat (limited to 'chess/rook.scad')
-rw-r--r--chess/rook.scad22
1 files changed, 17 insertions, 5 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]);
}
}