From 95edbc60f922e5ec5afe2be387348f76704ca82b Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Tue, 2 Apr 2024 23:52:43 +1030 Subject: [PATCH] Fixed up profile scaling again --- T-riple.scad | 119 +++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 57 deletions(-) diff --git a/T-riple.scad b/T-riple.scad index 8f64ae1..f1dd4b3 100644 --- a/T-riple.scad +++ b/T-riple.scad @@ -16,30 +16,32 @@ fret_angle = 60; //Fret angle of 45° is normal, anything over 60 will not work tube_radius = Cap_Spine + T_circumcenter[0]; standard_profile_center_x = T_circumcenter[0]; x_min = standard_profile_center_x - tube_radius; -minimum_y_width = 26.4517; -standard_y_width = 28; -nut_spacing = 10; -bridge_spacing = 20; -y_width_extra_mm = standard_y_width - (2 * nut_spacing); -y_width_extra = y_width_extra_mm / (2 * nut_spacing); +// minimum_y_width = 26.4517; +// standard_y_width = 28; + + +module fret_tube(from_fret, to_fret, scale_offset = 0, nut_spacing = 10, bridge_spacing = 20, strings = 3, y_width_extra_mm = 8, fingerboard_min_thick = 2.5, fingerboard_max_thick = 5, place_on_z0 = false, string_mms = false) { + spacing_scale = bridge_spacing/nut_spacing; + y_width_extra = y_width_extra_mm / ((strings-1) * nut_spacing); + y_width_nut = ((strings-1) * nut_spacing) + y_width_extra_mm; + y_width_bridge = ((strings-1) * bridge_spacing) + y_width_extra_mm; + string_diameters = string_mms ? string_mms : [for (i=[1:strings]) 2]; -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); z0 = fsl(0); - function get_desired_width_scale(z) = let (spacing = 2.0-(z/z0)) (spacing + y_width_extra)/(1 + y_width_extra); - function get_desired_profile_radius(ws) = + z_min = fsl(to_fret) - fret_width/2; + z_max = fsl(from_fret) + zero_fret_width/2; + Cap_Length = z_max - z_min; + echo(str("Cap length from fret ", from_fret, " to ", to_fret, " is ", Cap_Length, "mm")); + + function get_desired_top_width(z) = lerp(y_width_bridge, y_width_nut, z/z0); + function get_desired_profile_radius(top_width) = let ( x = fingerboard_max_thick, - y = standard_y_width*0.5*ws, - cc = tri_circumcenter([[x, -y], [x, y], [x_min, 0]]) + cc = tri_circumcenter([[x, -top_width/2], [x, top_width/2], [x_min, 0]]) ) cc[0]-x_min; - z_min = fsl(to_fret) - fret_width/2; - z_max = fsl(from_fret) + zero_fret_width/2; - z_offset = z_min; - Cap_Length = z_max - z_min; - echo(str("Cap length from fret ", from_fret, " to ", to_fret, " is ", Cap_Length, "mm")); module solid_tube(cap_taper = 1.5) { function get_x_max(z) = @@ -50,8 +52,8 @@ module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, f nearest_fret_mm = fsl(nearest_fret) ) z; - module outline_xy(width_scale = 1.0, x_max = fingerboard_max_thick, rounding_radius = 1.5, backside = true, topside = true) { - profile_radius = get_desired_profile_radius(width_scale); + module outline_xy(top_width, x_max = fingerboard_max_thick, rounding_radius = 1.5, backside = true, topside = true) { + profile_radius = get_desired_profile_radius(top_width); profile_radius_scale = profile_radius / tube_radius; profile_center_x = (profile_radius_scale-1.0)*tube_radius + standard_profile_center_x; @@ -70,34 +72,31 @@ module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, f topside_points_2 = topside ? [for (i = [0:profile_arc_steps_topside]) pt(a_backside_end + i*a_topside_step)] : []; polygon(points = concat(topside_points_1, backside_points, topside_points_2)); - top_width = pt(a_topside_start)[1] * 2; - echo(WScale=width_scale, PScale=profile_radius_scale, r=profile_radius, TopWidth=top_width, StringSpacing=(top_width-y_width_extra_mm)/2, dv=top_width/width_scale, goal=standard_y_width); + top_width_actual = pt(a_topside_start)[1] * 2; + echo(TopWidthTarget=top_width, PScale=profile_radius_scale, r=profile_radius, TopWidth=top_width_actual, StringSpacing=(top_width-y_width_extra_mm)/(strings-1)); } module fret_bumps(w=100) { - translate([fingerboard_max_thick - fret_width/2, w/2, -z_offset + fsl(from_fret)]) + translate([fingerboard_max_thick - fret_width/2, w/2, fsl(from_fret)]) rotate([90,0,0]) cylinder(h = w, r = zero_fret_width/2, $fn=32); - translate([fingerboard_max_thick - fret_width/2, w/2, -z_offset]) + translate([fingerboard_max_thick - fret_width/2, w/2, 0]) 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) { - // for (fret = [from_fret:to_fret+1]) - for (fret = [from_fret:to_fret]) + o = fret_width/2 * sin(fret_angle); + y0 = fingerboard_min_thick; + y1 = fingerboard_max_thick - (fret_width/2 * cos(fret_angle)); + for (fret = [from_fret+1:to_fret]) let( - f_prev = fsl(fret-1) - z_offset, - f_next = fsl(fret) - z_offset, - o = fret_width/2 * sin(fret_angle), - x0 = f_prev - o, - x1 = f_next + o, + x0 = fsl(fret-1) - o, + x1 = fsl(fret) + o, x_mid = (x0+x1)/2, - y0 = fingerboard_min_thick, - y1 = fingerboard_max_thick - (fret_width/2 * cos(fret_angle)), pts = [[x0, y1], [x1, y1], [x_mid, y0]], cc = tri_circumcenter(pts), r = norm([x0, y1] - cc), - r2 = r^2, + // r2 = r^2, a_start = acos((x0 - cc[0])/r), a_end = acos((x1 - cc[0])/r), a_sweep = a_end - a_start, @@ -108,20 +107,20 @@ module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, f rotate([90,0,0]) // cylinder(h = w, r = r, center = true); linear_extrude(height = w, center = true) - // polygon([for (i = [0:10]) [-r*sin(a_start+i*a_step), r*cos(a_start+i*a_step)]]); - polygon([for (x = [x1-x_mid:0.05:x0-x_mid]) [-sqrt(r2 - x^2), x]]); + polygon([for (i = [0:10]) [-r*sin(a_start+i*a_step), r*cos(a_start+i*a_step)]]); + // polygon([for (x = [x1-x_mid:0.05:x0-x_mid]) [-sqrt(r2 - x^2), x]]); } } module basic_fretboard() { intersection() { hull() { - translate([0,0,Cap_Length]) linear_extrude(0.001) outline_xy(get_desired_width_scale(z_max), topside=true); - translate([0,0,0]) linear_extrude(0.001) outline_xy(get_desired_width_scale(z_min), topside=true); + translate([0,0,z_max]) linear_extrude(0.001) outline_xy(get_desired_top_width(z_max)); + translate([0,0,z_min]) linear_extrude(0.001) outline_xy(get_desired_top_width(z_min)); } union() { 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,z_min]) cube([50 + fingerboard_max_thick - (fret_width/2 * cos(fret_angle)), 100, Cap_Length]); } } } @@ -129,10 +128,7 @@ module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, f // Make a solid tube and then subtract the notches difference() { basic_fretboard(); - difference() { - color("red") scallops(); - color("blue") fret_bumps(); - } + color("red") scallops(); } // color("red") scallops(); } @@ -151,34 +147,43 @@ module tube(from_fret, to_fret, scale_offset = 0, fingerboard_min_thick = 2.5, f // for (fret = [from_fret:to_fret]) for (fret = [from_fret+1:to_fret]) { zn = fsl(fret); - pr = get_desired_profile_radius(get_desired_width_scale(zn)); + pr = get_desired_profile_radius(get_desired_top_width(zn)); p_x0 = pr+x_min; - translate([p_x0, 0, zn-z_offset]) rotate([90,25,-asin((p_x0+2)/pr)]) + translate([p_x0, 0, zn]) rotate([90,25,-asin((p_x0+2)/pr)]) translate([0, 0, pr-engrave_depth]) linear_extrude(engrave_depth+1) fret_number_text(fret); - translate([p_x0, 0, zn-z_offset]) rotate([90,-25,180+asin((p_x0+2)/pr)]) + translate([p_x0, 0, zn]) rotate([90,-25,180+asin((p_x0+2)/pr)]) translate([0, 0, pr-engrave_depth]) linear_extrude(engrave_depth+1) fret_number_text(fret); } } + translate([0, 0, place_on_z0 ? -z_min : 0]) difference() { solid_tube(1.5); - linear_extrude(Cap_Length) T_hole(); + linear_extrude(z_max+1) T_hole(); fret_number_markers(); - tapered_T_hole(z0 = 0, z1 = 3); - tapered_T_hole(z0 = Cap_Length-3, z1 = Cap_Length+0.0001, o0 = 0, o1 = 1); + tapered_T_hole(z0 = z_min, z1 = z_min+3); + tapered_T_hole(z0 = z_max-3, z1 = z_max+0.0001, o0 = 0, o1 = 1); // Version number - translate([-10,10,Cap_Length-0.5]) linear_extrude(1) text("06", size=5, halign="center", valign="center", font="Noto Sans"); + translate([-10,10,z_max-0.5]) linear_extrude(1) text("06", size=5, halign="center", valign="center", font="Noto Sans"); + } + + color("silver") + for (s = [0:strings-1]) { + t = s - (strings/2) + 0.5; + hull() { + translate([fingerboard_max_thick+7, t*bridge_spacing, 0]) cylinder(h = 0.01, d = string_diameters[s], $fn=24); + translate([fingerboard_max_thick+3, t*nut_spacing, fsl(0)]) cylinder(h = 0.01, d = string_diameters[s], $fn=24); + } } } - -tube(from_fret = 0, to_fret = 36, scale_offset = -5); -//translate([50, 0]) tube(from_fret = -4, to_fret = -3); -//translate([100, 0]) tube(from_fret = -2, to_fret = 0); -//translate([150, 0]) tube(from_fret = 1, to_fret = 3); -//translate([200, 0]) tube(from_fret = 4, to_fret = 7); -//translate([250, 0]) tube(from_fret = 8, to_fret = 12); -//translate([300, 0]) tube(from_fret = 13, to_fret = 19); -//translate([350, 0]) tube(from_fret = 20, to_fret = 30); +// Long Bass (34") +fret_tube(from_fret=0, to_fret=36, scale_offset=-5, nut_spacing=10, bridge_spacing=20, strings=3, string_mms=[2.54, 2.159, 1.651]); +// Strat scale (25.5") +translate([50, 0]) +fret_tube(from_fret=0, to_fret=30, scale_offset=0, nut_spacing=7, bridge_spacing=11, strings=6, string_mms=[0.8938, 0.8128, 0.6096, 0.4064, 0.2794, 0.2286]); +// Smaller +translate([100, 0]) +fret_tube(from_fret=0, to_fret=24, scale_offset=3, nut_spacing=7, bridge_spacing=11, strings=5, string_mms=[0.8938, 0.8128, 0.6096, 0.4064, 0.2794]);