2025-01-26 16:02:07 +10:30
|
|
|
// Include after common.scad
|
|
|
|
|
|
|
|
module neck(string_spacing=18, string_margin=4.5, num_strings=3, target_neck_thickness=15, target_neck_thickness_additional_points=[], scallop_depth=3, num_frets=24, fret_width=2.4, filler=false, inlays_only=false, side_markers_only=false, fret_layers_only=false, remove_fret_layers=false, engrave_markers=true) {
|
|
|
|
fw2 = fret_width/2;
|
|
|
|
neck_length = fret_scale_length(0)+fw2;
|
|
|
|
neck_width = (num_strings-1)*string_spacing + string_margin*2;
|
|
|
|
module neck_stock() {
|
|
|
|
angle_excess = asin((scallop_depth+fw2)/target_neck_thickness);
|
|
|
|
a0 = 90-angle_excess;
|
|
|
|
a1 = 270+angle_excess;
|
|
|
|
rotate([-90, 0, 0])
|
|
|
|
if (len(target_neck_thickness_additional_points) < 1) {
|
|
|
|
linear_extrude(neck_length)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -target_neck_thickness*cos(a)]]); // Ellipse
|
|
|
|
} else {
|
|
|
|
pts = flatten([[[neck_length, target_neck_thickness]], target_neck_thickness_additional_points]);
|
|
|
|
echo(pts);
|
|
|
|
for (i = [0:len(pts)-2]) {
|
|
|
|
pt0 = pts[i];
|
|
|
|
pt1 = pts[i+1];
|
|
|
|
echo(i, pt0, pt1);
|
|
|
|
render() hull() {
|
|
|
|
translate([0,0,pt0[0]]) linear_extrude(0.01)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -pt0[1]*cos(a)]]); // Ellipse
|
|
|
|
translate([0,0,pt1[0]]) linear_extrude(0.01)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -pt1[1]*cos(a)]]); // Ellipse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module scallop(fret) {
|
|
|
|
x0 = fret_scale_length(fret-1) - fw2;
|
|
|
|
x1 = fret_scale_length(fret) + fw2;
|
|
|
|
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 scallops() {
|
|
|
|
for (fret = [0:num_frets]) {
|
|
|
|
scallop(fret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 intersect_fret_layers() {
|
|
|
|
for (fret = [0:num_frets]) {
|
|
|
|
translate([-500, fret_scale_length(fret)-fret_width/2, -500])
|
|
|
|
cube([1000, fret_width, 1000]);
|
|
|
|
}
|
|
|
|
// Some precision error with fret 0 :/
|
|
|
|
translate([-500, fret_scale_length(0)-fret_width/2+0.0006, -500])
|
|
|
|
cube([1000, fret_width, 1000]);
|
|
|
|
}
|
|
|
|
module fret_inlays() {
|
|
|
|
for (num_text = fret_inlays) {
|
|
|
|
fret = num_text[0];
|
|
|
|
if (fret <= num_frets) {
|
|
|
|
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_Sans_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];
|
|
|
|
if (fret <= num_frets) {
|
|
|
|
x0 = fret_scale_length(fret-1);
|
|
|
|
x1 = fret_scale_length(fret);
|
|
|
|
diff = x0 - x1;
|
|
|
|
mid = lerp(x0, x1, 0.67);
|
|
|
|
rotate([0, -94, 0])
|
|
|
|
translate([0, mid, neck_width/2-3])
|
|
|
|
linear_extrude(50)
|
|
|
|
rotate(-37)
|
|
|
|
text(text = str(fret), font = JP_Serif_Font, halign = "right", valign = "center", size = 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module carved_stock() {
|
|
|
|
render() difference() {
|
|
|
|
neck_stock();
|
|
|
|
scallops();
|
|
|
|
scallop(num_frets+1);
|
|
|
|
// Chop off anything above the frets
|
|
|
|
translate([-neck_width, 0, scallop_depth]) cube([neck_width*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]);
|
|
|
|
// Reduce rest of the body to 0
|
|
|
|
translate([-neck_width, 0, 0]) cube([neck_width*2, (fret_scale_length(num_frets)+fret_scale_length(num_frets+1))/2, target_neck_thickness*3]);
|
|
|
|
}
|
|
|
|
intersection() {
|
|
|
|
fret_bumps();
|
|
|
|
neck_stock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filler) { // Somewhat placeholder for now
|
|
|
|
difference() {
|
|
|
|
neck_stock();
|
|
|
|
scallop(25);
|
|
|
|
translate([-neck_width, 0, scallop_depth]) cube([neck_width*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]);
|
|
|
|
translate([-neck_width, 0, 0]) cube([neck_width*2, (fret_scale_length(25)+fret_scale_length(24))/2, target_neck_thickness*3]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
render() intersection() {
|
|
|
|
difference() {
|
|
|
|
carved_stock();
|
|
|
|
if (engrave_markers) {
|
|
|
|
fret_inlays();
|
|
|
|
fret_side_markers();
|
|
|
|
}
|
|
|
|
if (remove_fret_layers) intersect_fret_layers();
|
|
|
|
}
|
|
|
|
if (fret_layers_only || inlays_only || side_markers_only) union() {
|
|
|
|
if (fret_layers_only) intersect_fret_layers();
|
|
|
|
if (inlays_only) fret_inlays();
|
|
|
|
if (side_markers_only) fret_side_markers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-02-02 00:17:00 +10:30
|
|
|
|
|
|
|
module TaperNeck(
|
|
|
|
string_spacing_nut = 10.0,
|
|
|
|
string_spacing_bridge = 11.6,
|
|
|
|
num_strings = 6,
|
|
|
|
string_margin = 4.5,
|
|
|
|
target_neck_thickness = 15,
|
|
|
|
target_neck_thickness_additional_points = [],
|
|
|
|
scallop_depth = 2,
|
|
|
|
num_frets = 24,
|
|
|
|
fret_widths = [],
|
|
|
|
fret_angle = 60, // 90 is semicircle
|
|
|
|
filler = false,
|
|
|
|
include_colours = [0, 1, 2, 3], // 0: Base neck/fretboard 1: Frets 2: Inlays 3: Side markers
|
|
|
|
){
|
|
|
|
neck_length = fret_scale_length(0) + fret_widths[0]/2;
|
|
|
|
// neck_width = (num_strings-1)*string_spacing_nut + string_margin*2;
|
|
|
|
neck_width_nut = (num_strings-1)*string_spacing_nut + string_margin*2;
|
|
|
|
neck_width_bridge = (num_strings-1)*string_spacing_bridge + string_margin*2;
|
|
|
|
function neck_width(fret) = lerp(neck_width_bridge, neck_width_nut, 2^(-fret/12));
|
|
|
|
function neck_width_mm(mm) = lerp(neck_width_bridge, neck_width_nut, mm/fret_scale_length(0));
|
|
|
|
max_fret_width = max(fret_widths);
|
|
|
|
max_fret_height = sin(fret_angle) * max_fret_width/2;
|
|
|
|
|
|
|
|
module neck_stock() {
|
|
|
|
angle_excess = asin((scallop_depth + max_fret_height)/target_neck_thickness);
|
|
|
|
a0 = 90-angle_excess;
|
|
|
|
a1 = 270+angle_excess;
|
|
|
|
rotate([-90, 0, 0])
|
|
|
|
if (len(target_neck_thickness_additional_points) < 1) {
|
|
|
|
render() hull() {
|
|
|
|
translate([0,0,neck_length-0.0001]) linear_extrude(0.0001)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width_mm(neck_length)*0.5*sin(a), -target_neck_thickness*cos(a)]]); // Ellipse
|
|
|
|
translate([0,0,0]) linear_extrude(0.0001)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width_mm(0)*0.5*sin(a), -target_neck_thickness*cos(a)]]); // Ellipse
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pts = flatten([[[neck_length, target_neck_thickness]], target_neck_thickness_additional_points]);
|
|
|
|
echo(pts);
|
|
|
|
for (i = [0:len(pts)-2]) {
|
|
|
|
pt0 = pts[i];
|
|
|
|
pt1 = pts[i+1];
|
|
|
|
echo(i, pt0, pt1);
|
|
|
|
render() hull() {
|
|
|
|
translate([0,0,pt0[0]]) linear_extrude(0.01)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -pt0[1]*cos(a)]]); // Ellipse
|
|
|
|
translate([0,0,pt1[0]]) linear_extrude(0.01)
|
|
|
|
polygon([for (i = [0:300]) let(a=lerp(a0, a1, i/300.0)) [neck_width*0.5*sin(a), -pt1[1]*cos(a)]]); // Ellipse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module scallop(fret) {
|
|
|
|
x0 = fret_scale_length(fret-1) - fret_widths[max(0, fret-1)]/2;
|
|
|
|
x1 = fret_scale_length(fret) + fret_widths[min(num_frets, fret)]/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_bridge, center=true) polygon(arc);
|
|
|
|
}
|
|
|
|
module scallops() {
|
|
|
|
for (fret = [0:num_frets]) {
|
|
|
|
scallop(fret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module fret_bump(fw, a = fret_angle) {
|
|
|
|
// a must be in range (0,90] for correct geometry
|
|
|
|
fn = 50;
|
|
|
|
fn2 = fn * 2;
|
|
|
|
ca = cos(a);
|
|
|
|
sa = sin(a);
|
|
|
|
r = fw / (2*sa);
|
|
|
|
arc = [ for (i = [-fn:fn]) [fw*i/fn2, r*(sqrt(1 - pow(sa*(i/fn), 2))-ca)] ];
|
|
|
|
// echo("fret_bump", a, ca, arc);
|
|
|
|
rotate([90, 0, 90]) linear_extrude(neck_width_bridge, center=true) polygon(arc);
|
|
|
|
}
|
|
|
|
module fret_bumps() {
|
|
|
|
for (fret = [0:num_frets])
|
|
|
|
translate([0, fret_scale_length(fret), scallop_depth])
|
|
|
|
fret_bump(fret_widths[fret]);
|
|
|
|
}
|
|
|
|
module intersect_fret_layers() {
|
|
|
|
for (fret = [0:num_frets]) {
|
|
|
|
translate([-500, fret_scale_length(fret)-fret_widths[fret]/2, -500])
|
|
|
|
cube([1000, fret_widths[fret], 1000]);
|
|
|
|
}
|
|
|
|
// Some precision error with fret 0 :/
|
|
|
|
translate([-500, fret_scale_length(0)-fret_widths[0]/2+0.0006, -500])
|
|
|
|
cube([1000, fret_widths[0], 1000]);
|
|
|
|
}
|
|
|
|
module fret_inlays() {
|
|
|
|
for (num_text = fret_inlays) {
|
|
|
|
fret = num_text[0];
|
|
|
|
if (fret <= num_frets) {
|
|
|
|
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_Sans_Font, halign = "center", valign = "center", size = clamp(2, diff-fret_widths[fret]*2-2, 10));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module fret_side_markers() {
|
|
|
|
for (num_text = fret_inlays) {
|
|
|
|
fret = num_text[0];
|
|
|
|
if (fret <= num_frets) {
|
|
|
|
x0 = fret_scale_length(fret-1);
|
|
|
|
x1 = fret_scale_length(fret);
|
|
|
|
diff = x0 - x1;
|
|
|
|
mid = lerp(x0, x1, 0.67);
|
|
|
|
rotate([0, -94, 0])
|
|
|
|
translate([0, mid, neck_width_mm(mid)/2-3])
|
|
|
|
linear_extrude(50)
|
|
|
|
rotate(-37)
|
|
|
|
text(text = str(fret), font = JP_Serif_Font, halign = "right", valign = "center", size = 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module carved_stock() {
|
|
|
|
render() difference() {
|
|
|
|
neck_stock();
|
|
|
|
scallops();
|
|
|
|
scallop(num_frets+1);
|
|
|
|
// Chop off anything above the frets
|
|
|
|
translate([-neck_width_bridge, 0, scallop_depth]) cube([neck_width_bridge*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]);
|
|
|
|
// Reduce rest of the body to 0
|
|
|
|
translate([-neck_width_bridge, 0, 0]) cube([neck_width_bridge*2, (fret_scale_length(num_frets)+fret_scale_length(num_frets+1))/2, target_neck_thickness*3]);
|
|
|
|
}
|
|
|
|
intersection() {
|
|
|
|
fret_bumps();
|
|
|
|
neck_stock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filler) { // Somewhat placeholder for now
|
|
|
|
difference() {
|
|
|
|
neck_stock();
|
|
|
|
scallop(25);
|
|
|
|
translate([-neck_width_bridge, 0, scallop_depth]) cube([neck_width_bridge*2, Guitar_Scale_Length_mm*3, target_neck_thickness*3]);
|
|
|
|
translate([-neck_width_bridge, 0, 0]) cube([neck_width_bridge*2, (fret_scale_length(25)+fret_scale_length(24))/2, target_neck_thickness*3]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
has1 = list_has(include_colours, 1);
|
|
|
|
has2 = list_has(include_colours, 2);
|
|
|
|
has3 = list_has(include_colours, 3);
|
|
|
|
render() intersection() {
|
|
|
|
difference() {
|
|
|
|
carved_stock();
|
|
|
|
if (!has1) intersect_fret_layers();
|
|
|
|
if (!has2) fret_inlays();
|
|
|
|
if (!has3) fret_side_markers();
|
|
|
|
}
|
|
|
|
if (has1 || has2 || has3) union() {
|
|
|
|
if (has1) intersect_fret_layers();
|
|
|
|
if (has2) fret_inlays();
|
|
|
|
if (has3) fret_side_markers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|