Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $fn = 100;
- /*
- A spotify cipher wheel.
- 0th=spotify logo.
- 1st=1
- 24th=1
- 12th=7
- should generate a "valid" code
- */
- module arcz(radius = 10, angle = 90, thickness = 2, steps = 100, center = [0, 0]) {
- r1 = radius;
- r2 = radius - thickness;
- outer_points = [
- for (i = [0 : steps])
- let(a = -angle / 2 + i * angle / steps)
- [r1 * cos(a), r1 * sin(a)]
- ];
- inner_points = [
- for (i = [steps : 0 : -1])
- let(a = -angle / 2 + i * angle / steps)
- [r2 * cos(a), r2 * sin(a)]
- ];
- polygon_points = concat(outer_points, inner_points);
- translate(center)
- polygon(points = polygon_points);
- }
- //--- Main difference block ---
- difference() {
- // Background cylinder
- cylinder(h = 10, r = 10, $fn = 100);
- // Arc 1
- translate([-6, 0, 0])
- linear_extrude(10)
- difference() {
- arcz(radius = 6, angle = 120, thickness = 2);
- translate([-1, 0]) arcz(radius = 6, angle = 120, thickness = 2);
- }
- // Arc 2
- translate([-5, 0, 0])
- linear_extrude(10)
- difference() {
- arcz(radius = 8, angle = 120, thickness = 2);
- translate([-1, 0]) arcz(radius = 8, angle = 120, thickness = 2);
- }
- // Arc 3
- translate([-4, 0, 0])
- linear_extrude(10)
- difference() {
- arcz(radius = 10, angle = 120, thickness = 2);
- translate([-1, 0]) arcz(radius = 10, angle = 120, thickness = 2);
- }
- }
- module hullz(length = 1, w = 3, h = 1) {
- radius = w / 2;
- hull() {
- translate([-length / 2, 0, 0])
- cylinder(h = h, r = radius, $fn = 32);
- translate([length / 2, 0, 0])
- cylinder(h = h, r = radius, $fn = 32);
- }
- }
- module ringz(count, ring_width = 10, height = 10, margin = 0.3) {
- for (i = [2 : count+1]) {
- outer_radius = i * (ring_width + margin);
- inner_radius = outer_radius - ring_width;
- mid_radius = (outer_radius + inner_radius) / 2;
- difference() {
- // Main ring body
- cylinder(h = height, r = outer_radius, $fn = 100);
- cylinder(h = height + 0.1, r = inner_radius, $fn = 100);
- // 8 slots per ring
- for (j = [0 : 7]) {
- angle = j * 45;
- len = j + 2;
- rotate([0, 0, angle])
- translate([mid_radius, 0, 0])
- rotate([0, 0, 90])
- hullz(length = len, w = 3 / sqrt(2), h = height + 0.5);
- }
- }
- }
- }
- ringz(24);
- /*
- module hullz(length = 1, w = 3, h = 1) {
- // Calculate radius to ensure total width is exactly 3 mm
- radius = abs(width - length) / 2;
- if (radius <= 0) {
- echo("Error: length must be less than or equal to width");
- } else {
- hull() {
- translate([0, 0, 0])
- cylinder(h = height, r = w, $fn = 32);
- translate([length, 0, 0])
- cylinder(h = height, r = w, $fn = 32);
- }
- }
- }
- module note(length){
- for(i = [1:1:8]){
- translate([0,i*8,0]) hullz(length = i);
- }
- }
- module ringz(count, ring_width = 10, height = 10, margin = 1) {
- for (i = [2 : count]) {
- outer_radius = i * (ring_width + margin);
- inner_radius = outer_radius - ring_width;
- difference() {
- cylinder(h = height, r = outer_radius, $fn = 100);
- cylinder(h = height + 0.1, r = inner_radius, $fn = 100);
- }
- }
- }
- module arcz(radius = 10, angle = 90, thickness = 2, steps = 100, center = [0, 0]) {
- r1 = radius; // outer radius
- r2 = radius - thickness; // inner radius
- outer_points = [
- for (i = [0 : steps])
- let(a = -angle / 2 + i * angle / steps)
- [r1 * cos(a), r1 * sin(a)]
- ];
- inner_points = [
- for (i = [steps : 0 : -1])
- let(a = -angle / 2 + i * angle / steps)
- [r2 * cos(a), r2 * sin(a)]
- ];
- polygon_points = concat(outer_points, inner_points);
- translate(center)
- polygon(points = polygon_points);
- }
- //arcz();
- difference(){
- cylinder(10,22,22)
- linear_extrude(10){
- translate([-2,0,0]){
- difference(){
- arcz(radius = 6, angle = 120, thickness = 2, center = [0, 0]);
- translate([-1,0,0])
- arcz(radius = 6, angle = 120, thickness = 2, center = [0, 0]);
- }}}
- linear_extrude(10){
- translate([-1,0,0]){
- difference(){
- arcz(radius = 8, angle = 120, thickness = 2, center = [0, 0]);
- translate([-1,0,0])
- arcz(radius = 8, angle = 120, thickness = 2, center = [0, 0]);
- }}}
- linear_extrude(10){
- translate([0,0,0]){
- difference(){
- arcz(radius = 10, angle = 120, thickness = 2, center = [0, 0]);
- translate([-1,0,0])
- arcz(radius = 10, angle = 120, thickness = 2, center = [0, 0]);
- }}}
- }
- */
Add Comment
Please, Sign In to add comment