Toying around with faster builds at the expense of complexity

This commit is contained in:
Luke Hubmayer-Werner 2024-04-01 20:19:34 +10:30
parent 6f7935e42f
commit 5cbeb28208
1 changed files with 58 additions and 39 deletions

View File

@ -5,43 +5,78 @@ semitone_strings = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X", "XI"]
octave_strings = ["", "˙", "¨", "¯"]; octave_strings = ["", "˙", "¨", "¯"];
octave_scales = [1.1, 1, 0.9, 0.8]; octave_scales = [1.1, 1, 0.9, 0.8];
z_resolution = $preview ? 0.5 : 0.1;
profile_arc_steps = $preview ? 10 : 180;
// $fn = $preview ? 32 : 512; // $fn = $preview ? 32 : 512;
// mink_fn = $preview ? 12 : 128; // mink_fn = $preview ? 12 : 128;
// mink_fn_2d = $preview ? 32 : 256; // mink_fn_2d = $preview ? 32 : 256;
$fn = 32; // $fn = 32;
mink_fn = 12; // mink_fn = 12;
mink_fn_2d = 32; // mink_fn_2d = 32;
fret_width = 2.4; //2.8; // Jumbo = 0.11", 0.055" tall fret_width = 2.4; //2.8; // Jumbo = 0.11", 0.055" tall
zero_fret_width = fret_width*1.5;
zero_fret_extra_height = 1.2;
fret_angle = 60; //Fret angle of 45° is normal, anything over 60 will not work correctly
tube_radius = Cap_Spine + T_circumcenter[0]; tube_radius = Cap_Spine + T_circumcenter[0];
standard_profile_center_x = T_circumcenter[0];
module tube(from_fret, to_fret, scale_offset = 0) { module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, fingerboard_max_thick = 5) {
function fsl(fret_number) = fret_scale_length(fret_number + scale_offset); function fsl(fret_number) = fret_scale_length(fret_number + scale_offset);
z_min = (fsl(to_fret) + fsl(to_fret+1))/2; // z_min = (fsl(to_fret) + fsl(to_fret+1))/2;
z_max = (fsl(from_fret) + fsl(from_fret-1))/2; // z_max = (fsl(from_fret) + fsl(from_fret-1))/2;
z_min = fsl(to_fret) - fret_width/2;
z_max = fsl(from_fret) + zero_fret_width/2;
z_offset = z_min; z_offset = z_min;
Cap_Length = z_max - z_min; Cap_Length = z_max - z_min;
echo(str("Cap length from fret ", from_fret, " to ", to_fret, " is ", Cap_Length, "mm")); echo(str("Cap length from fret ", from_fret, " to ", to_fret, " is ", Cap_Length, "mm"));
module solid_tube(cap_taper = 1.5, fingerboard_min_thick = 2.5, fingerboard_max_thick = 5, fret_angle = 60) { // Fret angle of 45° is normal, anything over 60 will not work correctly module solid_tube(cap_taper = 1.5) {
module cap_outline(profile_radius_scale = 1.0, rounding_radius = 1.5) { function get_x_max(z) =
minkowski($fn = mink_fn_2d) { let (
circle(r = rounding_radius); fret_num = mm_to_fret_number(z)-scale_offset,
difference() { nearest_fret = round(fret_num),
translate([(profile_radius_scale-1.0)*tube_radius, 0, 0]) translate(T_circumcenter) circle(r = tube_radius*profile_radius_scale - rounding_radius); nearest_fret_height = fingerboard_max_thick + ((nearest_fret == 0) ? zero_fret_extra_height : 0),
translate([fingerboard_max_thick - rounding_radius, -50]) square([100,100]); nearest_fret_mm = fsl(nearest_fret)
} )
} z;
module outline_xy(profile_radius_scale = 1.0, x_max = fingerboard_max_thick, rounding_radius = 1.5) {
profile_radius = profile_radius_scale * tube_radius;
profile_center_x = (profile_radius_scale-1.0)*tube_radius + standard_profile_center_x;
// minkowski method does exactly what we want, but it is slow (sweep a circle around the outline)
// minkowski($fn = mink_fn_2d) {
// circle(r = rounding_radius);
// difference() {
// translate([profile_center_x, 0, 0]) circle(r = tube_radius*profile_radius_scale - rounding_radius);
// translate([fingerboard_max_thick - rounding_radius, -50]) square([100,100]);
// }
// }
// make a circle and chop the top off (no edge rounding)
// difference() {
// translate([profile_center_x, 0, 0]) circle(r = profile_radius);
// translate([x_max, -50]) square([100,100]);
// }
a_start = acos((x_max-profile_center_x)/profile_radius);
a_end = 360 - a_start;
a_step = (a_end - a_start)/profile_arc_steps;
echo(str("profile_radius_scale is ", profile_radius_scale, " profile_center_x is ", profile_center_x, " a_start is ", a_start, " a_end is ", a_end));
function pt(a) = [profile_center_x + profile_radius*cos(a), profile_radius*sin(a)];
polygon(points = [for (i = [0:profile_arc_steps]) pt(a_start + i*a_step)]);
} }
module fret_bumps(w=100) { module fret_bumps(w=100) {
translate([0,0,-z_offset]) for (fret = [from_fret:to_fret]) translate([fingerboard_max_thick - fret_width/2, w/2, -z_offset + fsl(from_fret)])
translate([fingerboard_max_thick - fret_width/2, w/2, fsl(fret)]) rotate([90,0,0]) cylinder(h = w, r = zero_fret_width/2, $fn=32);
rotate([90,0,0]) cylinder(h = w, r = fret_width/2); translate([fingerboard_max_thick - fret_width/2, w/2, -z_offset])
for (fret = [from_fret+1:to_fret])
translate([0, 0, fsl(fret)])
rotate([90,0,0]) cylinder(h = w, r = fret_width/2, $fn=32);
} }
module scallops(w=100) { module scallops(w=100) {
for (fret = [from_fret:to_fret+1]) // for (fret = [from_fret:to_fret+1])
for (fret = [from_fret:to_fret])
let( let(
f_prev = fsl(fret-1) - z_offset, f_prev = fsl(fret-1) - z_offset,
f_next = fsl(fret) - z_offset, f_next = fsl(fret) - z_offset,
@ -62,27 +97,10 @@ module tube(from_fret, to_fret, scale_offset = 0) {
module basic_fretboard() { module basic_fretboard() {
intersection() { intersection() {
// hull() {
// minkowski($fn = mink_fn) {
// sphere(cap_taper, $fn = mink_fn);
// translate([0,0,cap_taper]) linear_extrude(0.01) offset(-cap_taper)
// cap_outline(fingerboard_min_thick = fingerboard_min_thick, fingerboard_max_thick = fingerboard_max_thick);
// }
// minkowski($fn = mink_fn) {
// sphere(cap_taper, $fn = mink_fn);
// translate([0,0,Cap_Length-cap_taper]) linear_extrude(0.01) offset(-cap_taper)
// cap_outline(fingerboard_min_thick = fingerboard_min_thick, fingerboard_max_thick = fingerboard_max_thick);
// }
// linear_extrude(Cap_Length) offset(-1) cap_outline();
// translate([0,0,cap_taper]) linear_extrude(Cap_Length-cap_taper*2)
// cap_outline(fingerboard_min_thick = fingerboard_min_thick, fingerboard_max_thick = fingerboard_max_thick);
// }
hull() { hull() {
translate([0,0,Cap_Length]) linear_extrude(0.001) cap_outline(1.0); translate([0,0,Cap_Length]) linear_extrude(0.001) outline_xy(1.0);
translate([0,0,0]) linear_extrude(0.001) cap_outline(1.75); translate([0,0,0]) linear_extrude(0.001) outline_xy(1.75);
} }
// linear_extrude(Cap_Length)
// cap_outline();
union() { union() {
color("black") fret_bumps(); color("black") fret_bumps();
color("white", alpha=0.01) translate([-50,-50,0]) cube([50 + fingerboard_max_thick - (fret_width/2 * cos(fret_angle)), 100, Cap_Length]); color("white", alpha=0.01) translate([-50,-50,0]) cube([50 + fingerboard_max_thick - (fret_width/2 * cos(fret_angle)), 100, Cap_Length]);
@ -110,7 +128,8 @@ module tube(from_fret, to_fret, scale_offset = 0) {
translate([-10,10,Cap_Length-0.5]) linear_extrude(1) text("06", size=5, halign="center", valign="center", font="Noto Sans"); translate([-10,10,Cap_Length-0.5]) linear_extrude(1) text("06", size=5, halign="center", valign="center", font="Noto Sans");
// Fret number markers // Fret number markers
color("black") color("black")
for (fret = [from_fret:to_fret]) // for (fret = [from_fret:to_fret])
for (fret = [from_fret+1:to_fret])
translate([-3,-16,fsl(fret)-z_offset]) rotate([90,25,16]) linear_extrude(40) { translate([-3,-16,fsl(fret)-z_offset]) rotate([90,25,16]) linear_extrude(40) {
octave = floor(fret/12); octave = floor(fret/12);
semitone = fret%12; semitone = fret%12;