From dc72cafb0e1bcfeb2b18b03e595c6a1cfb30109f Mon Sep 17 00:00:00 2001
From: Christian Hodgden <chrhodgden@gmail.com>
Date: Wed, 24 Jul 2024 09:11:37 -0500
Subject: chess: completed rook model

---
 chess/rook.scad | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

(limited to 'chess/rook.scad')

diff --git a/chess/rook.scad b/chess/rook.scad
index b75476f..e8801dc 100644
--- a/chess/rook.scad
+++ b/chess/rook.scad
@@ -35,15 +35,25 @@ head_radius = 1;
 head_height = 1;
 stem_height = total_height - base_height - (head_height / 2);
 
+// ridge_offset will set the ridges to go over the corners
+ridge_offset_check = 0;
+ridge_offset = ridge_offset_check * ((360/$fn)/2);
+
 cylinder(base_height/2, r = base_radius);
 translate([0, 0, base_height/2]) 
 	cylinder(base_height/2, base_radius, stem_base_radius);
 translate([0, 0, base_height])
 	cylinder(stem_height, stem_base_radius, stem_radius);
-translate([0, 0, total_height - head_height])
-	cylinder(head_height/2, r = head_radius);
-translate([0, 0, total_height - (head_height/2)])
-	// I think I might try rotate_extrude
-	// take a differemce with an internal cylinder as well
-	%cylinder(head_height/2, r = head_radius);
-
+difference() {
+	translate([0, 0, total_height - head_height])
+		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/2)-1)]) {
+			rotate([0, 0, (i * (360/($fn/2))) - ridge_offset])
+				rotate_extrude(angle = 360/$fn)
+					square([head_radius + 0.25, head_height]);
+		}		
+	}
+}
-- 
cgit v1.2.3