From c2fe99b4cc5b765e8bc543dba957bc21f48010ff Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 22 Dec 2024 01:07:14 +1030 Subject: [PATCH] CFTubes 01 print --- CFTubes.scad | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ common.scad | 32 +++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 CFTubes.scad diff --git a/CFTubes.scad b/CFTubes.scad new file mode 100644 index 0000000..7531296 --- /dev/null +++ b/CFTubes.scad @@ -0,0 +1,109 @@ +include +Guitar_Scale_Length_mm = 610; // millimetres, slightly over 24inch (609.6mm) Jaguar scale, should be fine for guitar and u-bass +assert(fret_scale_length(0) == 610); // Make sure the function correctly uses our changed global + +CF_Tube_Dia = 5.0; +CF_Square_Width = 6.0; + +// Philippians 4:8 +// Gideon 真実な, 尊ぶべき, 正しい, 清い, 愛すべき, 評判の良い, 徳とされる, 称賛に値する +// ShinKaiYaku65 最後に、兄弟たち。すべての真実なこと、すべての誉れあること、すべての正しいこと、すべてのきよいこと、すべての愛すべきこと、すべての評判の良いこと、そのほか徳と言われること、称賛に値することがあるならば、そのようなことに心を留めなさい。 +// I swapped 愛 and 評判 because 12th fret should be the biggest marker, and having only 15 as a 2char marker would be too disorienting +// going with 良 for 21 +fret_inlays = [[3, "真"], [5, "尊"], [7, "正"], [9, "清"], [12, "評判"], [15, "愛"], [17, "徳"], [19, "賛"], [21, "良"], [24, "主イエス"]]; + + + +module neck(string_spacing=18, string_margin=5, num_strings=3, target_neck_thickness=15, scallop_depth=3, num_frets=24, fret_width=2.4) { + neck_length = fret_scale_length(0)+fret_width/2; + neck_width = (num_strings-1)*string_spacing + string_margin*2; + // Could do some trig to work out exactly how much to add for the scallop depth, but we're subtracting anyway + angle_excess = 20; + module neck_stock() { + rotate([-90, 0, 0]) + linear_extrude(neck_length) + polygon([for (a = [90-angle_excess:1:270+angle_excess]) [neck_width*0.5*sin(a), -target_neck_thickness*cos(a)]]); + } + module scallops() { + for (fret = [0:num_frets]) { + x0 = fret_scale_length(fret-1) - fret_width/2; + x1 = fret_scale_length(fret) + fret_width/2; + xmid = lerp(x0, x1, 0.5); + // Radius it? + arc = arc_points([[x0, scallop_depth], [x1, scallop_depth], [xmid, 0]]); + echo(arc); + rotate([90, 0, 90]) linear_extrude(neck_width, center=true) polygon(arc); + } + } + module fret_bumps() { + for (fret = [0:num_frets]) { + translate([0, fret_scale_length(fret), scallop_depth]) + rotate([0, 90]) cylinder(d=fret_width, h = neck_width, center = true, $fn=200); + } + } + module fret_inlays() { + for (num_text = fret_inlays) { + fret = num_text[0]; + x0 = fret_scale_length(fret-1); + x1 = fret_scale_length(fret); + diff = x0 - x1; + translate([0, lerp(x0, x1, 0.5), -0.5]) + linear_extrude(30) + text(text = num_text[1], font = JP_Serif_Font, halign = "center", valign = "center", size = clamp(2, diff-fret_width*2-2, 10)); + } + } + module fret_side_markers() { + for (num_text = fret_inlays) { + fret = num_text[0]; + x0 = fret_scale_length(fret-1); + x1 = fret_scale_length(fret); + diff = x0 - x1; + rotate([0, -90, 0]) + translate([0, x1, neck_width/2-3]) + linear_extrude(50) + rotate(-35) + text(text = str(fret), font = JP_Serif_Font, halign = "right", valign = "center", size = 5); + } + } + // scallops(); + render() difference() { + neck_stock(); + scallops(); + fret_inlays(); + fret_side_markers(); + translate([-neck_width, 0, scallop_depth]) cube([neck_width*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]); + } + intersection() { + fret_bumps(); + neck_stock(); + } +} + +module cf_tube(tolerance = 0.1) { + rotate([-90,0,0]) + cylinder(h=Guitar_Scale_Length_mm+10, d=CF_Tube_Dia+tolerance, $fn=360); +} + +module cf_square(tolerance = 0.1) { + x = CF_Square_Width+tolerance; + translate([-x/2, 0, -x/2]) + cube([x, Guitar_Scale_Length_mm+10, x]); +} + +difference() { + neck(); + for (i = [-1:2:1]) + translate([i*15, 0, -4]) + cf_tube(); + for (i = [-1:2:1]) + translate([i*7.5, 0, -7]) + cf_square(); + translate([0, 0, -10]) + cf_tube(); + + echo(fret_scale_length(0) - fret_scale_length(8)); // 225.724 + echo(fret_scale_length(8) - fret_scale_length(25)); // 240.335 + segment_cut = fret_scale_length(8)-1.2; + translate([-50, 0, -50]) cube([100, segment_cut, 100]); + rotate([90, 0, 0]) linear_extrude((segment_cut+0.3)*2, center=true) text(text = "01", font = JP_Serif_Font, halign = "center", valign = "center", size = 4); +} diff --git a/common.scad b/common.scad index 719a8b3..8e55b99 100644 --- a/common.scad +++ b/common.scad @@ -4,3 +4,35 @@ function log2(x) = ln(x)/ln2; function fret_scale_length(n) = Guitar_Scale_Length_mm * 2^(-n/12); function mm_to_fret_number(mm) = -log2(mm/Guitar_Scale_Length_mm)*12; function lerp(start, end, amount) = start + (end-start)*amount; +function clamp(minimum, value, maximum) = min(max(minimum, value), maximum); + +function tri_circumcenter(pts) = + let( + v0 = pts[1] - pts[0], + v1 = pts[2] - pts[1], + d0 = (pts[1] + pts[0])/2 * v0, + d1 = (pts[2] + pts[1])/2 * v1, + det = -cross(v0, v1) + ) + [cross([d1, d0], [v1.y, v0.y]), cross([d0, d1], [v0.x, v1.x])] / det; + +// Create a circle containing all 3 points, then plot the arc between the first two points +function arc_points(tri_points, fragments_per_mm=5) = + let( + cc = tri_circumcenter(tri_points), + r = norm(tri_points[0] - cc), + steps = ceil((norm(tri_points[2] - tri_points[0]) + norm(tri_points[2] - tri_points[1]))*fragments_per_mm), + normalized0 = (tri_points[0] - cc)/r, + normalized1 = (tri_points[1] - cc)/r, + a_start = atan2(normalized0[1], normalized0[0]), + a_end = atan2(normalized1[1], normalized1[0]), + a_sweep = a_end - a_start, + a_step = a_sweep/steps + ) + [for (i = [0:steps]) r*[cos(a_start+i*a_step), sin(a_start+i*a_step)] + cc]; + +// We can't use Droid Sans Japanese because the rendering library is really dumb and will pick the wrong Droid Sans. CJK fonts must be singular files. +JP_Serif_Font = "New Tegomin"; +JP_Sans_Font = "Yuji Boku"; +JP_Fat_Sans_Font = ["Potta One", "Yusei Magic"]; +JP_Light_Sans_Fonts = ["Hachi Maru Pop", "MotoyaLMaru", "Rounded MPlus 1c"];