summaryrefslogtreecommitdiffstats
path: root/wheel.scad
blob: f3b4a1925f1eafe0c65c6460dc90a93228d4f9a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$fn=100;

module wheel(radius, width, thickness, spokes) {
	union() {
		difference() {
			// basis for our wheel - a sphere
			sphere(radius);
			// upper cut-out
			translate([0,0,width/2])
				cylinder(radius-(width/2) +1, radius, radius, 0);
			// lower cut-out
			translate([0,0,-radius -1])
				cylinder(radius-(width/2) +1, radius, radius, 0);
			/*
				inner cut-out
				removing 1 from z on translate and making the cylinder
				higher by two to generate slightly more valid objects
			*/
			translate([0,0,-width/2 -1])
				cylinder(width+2, radius-thickness, radius-thickness, 0);
		}
		// spokes
		for (i = [0:(360/spokes):360]) {
			rotate([0,0,i])
				translate([-(radius-thickness),-(radius-thickness)/(spokes*2), -(width/2)])
					cube([(radius-thickness), (radius-thickness)/(spokes), width]);
		}
	}
}