Explorar o código

some code cleanups, finish up the final render of the microphone and individual parts for printing

Fernando Pablo Lopez-Lezcano %!s(int64=11) %!d(string=hai) anos
pai
achega
5121c53229
Modificáronse 1 ficheiros con 28 adicións e 87 borrados
  1. 28 87
      first_order.scad

+ 28 - 87
first_order.scad

@@ -21,14 +21,18 @@ capsule_radius = 5;
 capsule_height = 4.5;
 
 // distance between face of capsule and center of array
-mic_radius = 10;
+mic_radius = 10.5;
 
 // dimensions of capsule holder connection legs
 leg_width = 4;
 leg_thick = 2.5;
 
+// width of the ridge that connects to the mount
+ridge_width = 2;
+ridge_length = 3;
+
 // dimensions of microphone holder
-mount_radius = 3;
+mount_radius = 3.5;
 
 // height of mount
 mount_height = 4;
@@ -48,7 +52,7 @@ renderset = 0;
 // 0 -> original cylinder beams
 // 1 -> interlocking beams (out)
 // 2 -> interlocking beams (in)
-connect = 1;
+connect = 2;
 
 //// end of rendering control
 ////
@@ -66,10 +70,6 @@ wall = 1;
 // number of facets for cylinders
 facets = 64;
 
-// width of the ridge that connects to the mount
-ridge_width = 2;
-ridge_length = 3;
-
 // the rest of the leg geometry
 tetra = atan(sqrt(2));
 leg_length = 
@@ -91,8 +91,8 @@ capsule_bottom = mic_radius * cos(tetra) + capsule_radius * sin(tetra);
 
 // azimuth: orientation of the capsule
 // elevation: orientation of the capsure
-// twist: adjust the angle of the mounts so they match
-// mounts: number of mounts to create (2 or 3)
+// twist: adjust the angle of the mounts
+// mounts: number of mounts to create (2 for the bottom mics, 3 for the top)
 
 module capsule (azimuth, elevation, twist, mounts) {
 	rotate([0, 0, azimuth]) {
@@ -104,7 +104,7 @@ module capsule (azimuth, elevation, twist, mounts) {
 						// main capsule holder
 						cylinder(r = capsule_radius + wall, h = capsule_height, $fn = facets);	
 						// the attachment point to the other capsules
-						for (rot = [-120 : 120 : mounts == 2 ? 0 : 120]) {
+						for (rot = mounts == 2 ? [-120, 120] : [-120, 0, 120]) {
 							rotate(a = rot + twist, v = [0, 0, 1]) {
 								// connect with cylindrical beams, very pretty
 								if (connect == 0) {
@@ -146,7 +146,7 @@ module capsule (azimuth, elevation, twist, mounts) {
 						}
 						// add ridges for microphone mount
 						if (mounts == 2) {
-							rotate(a = 120 + twist, v = [0, 0, 1]) {
+							rotate([0, 0, twist]) {
 								translate([capsule_radius + fudge, - wall , 0]) {
 									difference() {
 										cube([ridge_length, ridge_width, capsule_height], center = false);
@@ -176,7 +176,7 @@ module capsule (azimuth, elevation, twist, mounts) {
 
 // microphone mount
 
-module mount (radius, length, wall, separation) {
+module mount (wall, separation) {
 	translate([0, 0, -(separation + 1)]) {
 		difference() {
 			union() {
@@ -206,87 +206,28 @@ module mount (radius, length, wall, separation) {
 	}
 }
 
-module mount_old (radius, length, wall, separation) {
-	// mounting ring
-	translate([0, 0, -separation]) {
-		difference() {
-			union() {
-				cylinder(h = length, r = radius, center = true, $fn=128);
-
-				// connection ridges
-				for (rot = [0 : 180 : 360]) {
-					rotate([0, 0, rot - 45]) {
-						translate([0, - wall * 3 - fit, - length / 2]) {
-							difference() {
-								cube([wall * 6, wall * 2, length], center = false);
-							}
-						}
-						translate([0, wall + fit, - length / 2]) {
-							difference() {
-								cube([wall * 6, wall * 2, length], center = false);
-							}
-						}
-					}
-				}
-			}
-			// the bore of the ring
-			cylinder(h = length, r = radius - wall, center = true, $fn=128);
-			// create the slopes in the ridges
-			for (rot = [0 : 180 : 360]) {
-				rotate([0, 0, rot]) {
-					translate([- radius, radius, 3.5]) {
-						rotate([tetra, 0, 45]) {
-							cube([radius * 3, radius, radius * 3], center = true);
-						}
-					}
-				}
-			}
-		}
-	}
-}
-
-// some constants
-vang = atan(sqrt(2));
-
-// vectors pointing in the directions of the four capsules
-direction1 = [1, 1, 1];
-direction2 = [-1, 1, -1];
-direction3 = [-1, -1, 1];
-direction4 = [1, -1, -1];
-
-dist = sqrt(3);
+// elevation angle for capsule holders
+elev = asin(1 / sqrt(3));
 
-// azimuths
-az1 = atan2(1, 1);
-az2 = atan2(1, -1);
-az3 = atan2(-1, -1);
-az4 = atan2(-1, 1);
-
-// elevations
-el1 = asin(1/dist);
-el2 = -asin(1/dist);
-el3 = asin(1/dist);
-el4 = -asin(1/dist);
-
-// connect the four instances together
+// render a complete microphone
 if (rendermic == 1) {
-	capsule(az1, el1, 60, 3);
-	capsule(az2, el2, 240, 2);
-	capsule(az3, el3, 60, 3);
-	capsule(az4, el4, 240, 2);
+	capsule(45, elev, 60, 3);
+	capsule(-45, -elev, 0, 2);
+	capsule(-135, elev, 60, 3);
+	capsule(135, -elev, 0, 2);
 	// the mount
-	mount(hold_radius, capsule_height, 1, capsule_bottom);
+	mount(1, capsule_bottom);
 }
 
+// print all the parts separately
 part_sep = capsule_radius * 2 * 3;
-
-echo("az = ", az1, az2, az3, az4, "elev = ", el1, el2, el3, el4);
-
-// just one to test
 if (rendermic == 0) {
-	capsule(0, 90, 0, 3);
-	//translate([0, part_sep, 0]) { capsule(0, 270, height, capsule_radius, capsule_height, 1, 0); }
-	//translate([part_sep, 0, 0]) { capsule(0, 270, height, capsule_radius, capsule_height, 1, 0); }
-	//translate([part_sep, part_sep]) { capsule(0, 270, height, capsule_radius, capsule_height, 1, 0); }
+	capsule(0, -90, 0, 3);
+    if (renderset != 0) {
+        translate([0, part_sep, 0]) { capsule(0, -90, 0, 3); }
+        translate([part_sep, 0, 0]) { capsule(0, -90, 0, 2); }
+        translate([part_sep, part_sep]) { capsule(0, -90, 0, 2); }
+        translate([part_sep / 2, -part_sep, 0]) { mount(1, 0); }
+    }
 }